{"id":1782,"date":"2017-02-05T16:17:08","date_gmt":"2017-02-05T15:17:08","guid":{"rendered":"https:\/\/blog.mi.hdm-stuttgart.de\/?p=1782"},"modified":"2023-06-07T15:22:50","modified_gmt":"2023-06-07T13:22:50","slug":"scheme_interpreter","status":"publish","type":"post","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2017\/02\/05\/scheme_interpreter\/","title":{"rendered":"Scheme Interpreter"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>In the the course <em>Software Engineering and Management<\/em> and <em>Design and implementation progressed programing languages <\/em>at Stuttgart Media University, I developed an own Interpreter.<\/p>\n<p>&nbsp;<\/p>\n<h3>About the Interpreter<\/h3>\n<p>The syntax of this interpreter is\u00a0based on the \u201elips\u201c family, a programming language which is structured in lists (<a href=\"https:\/\/de.wikipedia.org\/wiki\/Scheme\">definition<\/a>). This type of programming language is very simple to understand and fast implemented. An element of a scheme list exist of two part the first is the \u201eCAR\u201c &#8211; the value of the list and the second part is the \u201eCDR\u201c the link to the &#8220;CAR&#8221; of the next list element. If the list element is the last in the list than the value of &#8220;CAR&#8221; is Null. For more Inforamtion have a look to <a href=\"https:\/\/racket-lang.org\/\">dr. racket<\/a> or the <a href=\"http:\/\/www.iwriteiam.nl\/HaCAR_CDR.html\">origin of car and cdr<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h3>Projekt Setup<\/h3>\n<ul>\n<li>Programing language: C<\/li>\n<li>Compiler: Clang<\/li>\n<li>Environment: Eclipse CDT<\/li>\n<li>Continues delivery: Jenkins<\/li>\n<li>Version control: Git<\/li>\n<li>Repository: https:\/\/github.com\/HannesBuchwald\/HbScheme<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3>Development<\/h3>\n<p>The project was developed with the test-driven development approach. Befor a function is implemented a test has to be written for it. This approach improves the quality of the code a lot comapre to just straitforward coding without a testing structure. Aswell it was used Jenkins for contunius delivery.\u00a0 For this project only the standart &#8220;C&#8221; libiries where used. Therefore, played continues integration not a big role in this porject.<\/p>\n<p>&nbsp;<\/p>\n<h3>Develop Enviroment<\/h3>\n<p>All the code was developt in the Eclipse CDT envornment. This is an environment for C\/C++, it includes all code &#8220;highliting&#8221; alswell as a debug function and compiling envornment. For this project the Clang compiler was used. Aswell it is possible to compile the project with the standart GCC compiler.<\/p>\n<p>&nbsp;<\/p>\n<h3>\u00a0Version control and continues delivery<\/h3>\n<p>Git was used for version control. The source code is hosted on the github server as a <a href=\"https:\/\/github.com\/HannesBuchwald\/HbScheme\">public project<\/a>. To simplify the branches it is used two branches. A <em>master<\/em> and a <em>develop<\/em> branch. The active development take place on the develop branch. The continue delivery process was set up, that for every new git commit on the develop branch the build and deploy process in Jenkins was triggered. This was very easily set it up through the &#8220;GitHub hook trigger for GITScm polling&#8221; option in the project configuration in on the Jenkins server. When the build process was passed successful and Jenkins was able to execute the program than the Jenkins merged this stable commit to the origin master branch. With this simple process it was ensure that only a stable version of the program is on the master branch. As well I had Jenkins set up that I receive an email if the build is fail.<\/p>\n<p>&nbsp;<\/p>\n<h3>How<strong> to built execute a c project in Jenkins<\/strong><\/h3>\n<p>This project was built with <a href=\"https:\/\/www.gnu.org\/software\/make\/manual\/make.html\"><em>make<\/em><\/a>. <em>make<\/em> is great tool with a simple syntax to describe the build steps of program. Because of the small size of this project it was enough to use one Makefile for the build description. The below code is a extract of the important part of the Makefile for this project. As you can see in with a very few lines or description a the hole program was build.<\/p>\n<pre class=\"prettyprint lang-makefile\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">## Compiling files\n\nOBJS=hbscheme.o hbscheme_test.o \\\n\n     reader.o memory.o \\\n\n     utils.o\n\n\n## Clean up\n\nclean:\n\n        rm -f $(OBJS)\n\n\n## include main header file to all files\n\n$(OBJS): hbscheme.h\n\n\n## Linking all object files togehter\n\n$(APPLICATION): $(OBJS)\n\n        $(CC) $(DEBUG_FLAGS) -o $(APPLICATION) $(OBJS)\n\n\n## run make with \"make all\"\n\nall: $(APPLICATION)<\/pre>\n<p>To start this file also it needs only to cammands as you can see below.<\/p>\n<pre class=\"prettyprint lang-powershell\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\"># build hbScheme\n\nmake all\n\n\n# run hbScheme\n\n.\/hbScheme<\/pre>\n<p>This shell script commands where set up the project configuration in Jenkins. Now the Jenkins server could run the Makefile, after pulling the project and compile build and execute the program.<\/p>\n<p>&nbsp;<\/p>\n<h3>Testing<\/h3>\n<p>Also in C, there are many ways to do testing. For this project I only us unit and function tests. As mentioned earlier this is a very small standalone program, also there is no GUI implemented in. Integration and GUI testing are not needed. I played around with quite some c test frameworks, but in the end I wrote my own test cases and let them run before start the program. But why I did not use a test framework. I had a closer look a <a href=\"https:\/\/github.com\/google\/googletest\">googletest. <\/a>This framework is written in C++ and used from many others to do unit testing for c project. But for me it was to complicate to test C code with a C++ framework. I set it up in the eclipse environment and there is runs OK. But I had big issues to get it run in my Jenkins set up. So I decided to write all the test cases in strait forward c function and execute it after the program init its environment so I can do beside the unit test also function tests. For me this was a very simple but efficient way of testing. If a test fail the program will stop and the error will be print out on the command line.<\/p>\n<p>If it comes to Jenkins test report, ok this approach does not have a nice reporting like the xUnit plugin provides, but a simple print on the command line is enough for this size of program. When Jenkins is trying to build, and execute the program, the build process will fail if a test is failing. The reason where the test is failing is printed out on the command line, therefor I know where to debug. And if the build is failed there is also no merge to the master branch. So, there I had all the time a stable and executable version on the master branch is even the version on the develop branch is not. For sure the version on the master branch is only as stable as the test coverage. But with this problem every program should deal with. How to find the bug, which is outside the test range?<\/p>\n<p>The below testfile shows a snipet of the console print after Jenkins build compile and run sucsessfull a version of the program.<\/p>\n<pre class=\"prettyprint lang-powershell\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">...\n\nclang    -o hbScheme hbscheme.o hbscheme_test.o reader.o memory.o utils.o\n[hbScheme] $ \/bin\/sh -xe \/var\/folders\/jt\/r5k6nm0s74x547q27c824nym0000gn\/T\/jenkins5853669811710938112.sh\n+ .\/hbScheme\n\n\n**** Start (UnitTest) ****\nDone (a2l Test)\nDone (Integer TAG and Check Test)\nDone (True\/False TAG Test)\nDone (Symbol TAG Test)\n**** Done (UnitTest) ****\n\n**** Start (PerformanceTest)**** \ntime to add 10000 new symbols: 650ms \ntime to lookup 10000 existing symbols: 414ms\n**** Done (PerformanceTest) ****\n\nWelcome to our (incomplet) scheme\n\n &gt; git tag -l jenkins-hbScheme-66 # timeout=10\n &gt; git tag -a -f -m Jenkins Build #66 jenkins-hbScheme-66-SUCCESS # timeout=10\nPushing HEAD to branch master of origin repository\n &gt; git --version # timeout=10\n &gt; git push https:\/\/github.com\/HannesBuchwald\/HbScheme HEAD:master -f\nSending e-mails to: hannes.buchwald@gmail.com\nFinished: SUCCESS<\/pre>\n<p>This snipet below shows a console print of a not sucessfuly build version. In line 13 is seen the output from the faild test case.<\/p>\n<pre class=\"prettyprint lang-powershell\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"13\" data-caption=\"\">...\n\nclang    -o hbScheme hbscheme.o hbscheme_test.o reader.o memory.o utils.o\n[hbScheme] $ \/bin\/sh -xe \/var\/folders\/jt\/r5k6nm0s74x547q27c824nym0000gn\/T\/\njenkins8977720403703204312.sh\n+ .\/hbScheme\n\n\n**** Start (UnitTest) ****\nhbscheme_test.c:37 assertion failed: a2l error\/var\/folders\/jt\/\nr5k6nm0s74x547q27c824nym0000gn\/T\/\n\njenkins8977720403703204312.sh: line 3: 21054 Abort trap: 6           .\/hbScheme\n\nBuild step 'Shell ausf\u00fchren' marked build as failure\nBuild did not succeed and the project is configured to only push after a \nsuccessful build, so no pushing will occur.\nSending e-mails to: hannes.buchwald@gmail.com\nFinished: FAILURE<\/pre>\n<h3><\/h3>\n<h3>Result<\/h3>\n<p>Simple is better than complicated. I tried a lot with powerful test frameworks and blown up build processes. And in the end a small Makefile and simple test functions with no overhead test framework had brought me so far that I can continue to finish this this project will less effort. This was also my first time I used Jenkins. Even when the start was a bit rough. I think it is worthy even for a small project to set up this development process. Now I have all the time a very up to date stable version of the program. And because of the automation mechanism I do not have to spend time for it.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Hannes Buchwald (hb052@hdm-stuttgart.de)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In the the course Software Engineering and Management and Design and implementation progressed programing languages at Stuttgart Media University, I developed an own Interpreter. &nbsp; About the Interpreter The syntax of this interpreter is\u00a0based on the \u201elips\u201c family, a programming language which is structured in lists (definition). This type of programming language is very [&hellip;]<\/p>\n","protected":false},"author":219,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[651,2],"tags":[],"ppma_author":[713],"class_list":["post-1782","post","type-post","status-publish","format-standard","hentry","category-system-designs","category-system-engineering"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":20309,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/08\/14\/unsafe-programming-languages\/","url_meta":{"origin":1782,"position":0},"title":"Unsafe Languages, Inadequate Defense Mechanisms and Our Dangerous Addiction to Legacy Code","author":"Jan-Niklas Tille","date":"14. August 2021","format":false,"excerpt":"Over the last 20 years, developing secure software has become increasingly important. To this day, we write a significant amount of code in languages with manual memory management. However, the Peter Parker principle states that \u201cgreat power comes with great responsibility\u201d. Many scoring systems classify, enumerate and rank prevalence of\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1711,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2016\/11\/26\/snakes-exploring-pipelines-a-system-engineering-and-management-project\/","url_meta":{"origin":1782,"position":1},"title":"Snakes exploring Pipelines &#8211; A \u201cSystem Engineering and Management\u201d Project","author":"Yann Loic Philippczyk","date":"26. November 2016","format":false,"excerpt":"Part 0: Introduction This series of blog entries describes a student project focused on developing an application by using methods like pair programming, test driven development and deployment pipelines. Once upon a time, which was about one and a half months ago, an illustrious group of three students found together,\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"A python. (Because snakes. Not the language.) Source: https:\/\/rashmanly.files.wordpress.com\/2008\/10\/1439659.jpg","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2016\/11\/0_1-300x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":711,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2016\/06\/28\/the-elixir-programming-language\/","url_meta":{"origin":1782,"position":2},"title":"The Elixir Programming Language","author":"Yann Loic Philippczyk","date":"28. June 2016","format":false,"excerpt":"An introduction to the language, its main concepts and its potential. The number of security incidents has been on the rise for years, and the growth of the Internet of Things is unlikely to improve the situation. Successful attacks on all kinds of interconnected smart devices, from car locks over\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"elixir","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2016\/06\/elixir-flame-229x300.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2153,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2017\/03\/08\/of-apache-spark-hadoop-vagrant-virtualbox-and-ibm-bluemix-services-part-3-what-is-apache-spark\/","url_meta":{"origin":1782,"position":3},"title":"Of Apache Spark, Hadoop, Vagrant, VirtualBox and IBM Bluemix Services &#8211; Part 3 &#8211; What is Apache Spark?","author":"bh051, cz022, ds168","date":"8. March 2017","format":false,"excerpt":"Apache Spark is a framework for fast processing of large data on computer clusters. Spark applications can be written in Scala, Java, Python or R and can be executed in the cloud or on Hadoop (YARN) or Mesos cluster managers. It is also possible to run Spark applications standalone, that\u2026","rel":"","context":"In &quot;Student Projects&quot;","block_context":{"text":"Student Projects","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/student-projects\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/03\/spark-overview-768x195.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/03\/spark-overview-768x195.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/03\/spark-overview-768x195.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1758,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2017\/01\/12\/snakes-exploring-pipelines-a-system-engineering-and-management-project-5\/","url_meta":{"origin":1782,"position":4},"title":"Snakes exploring Pipelines &#8211; A \u201cSystem Engineering and Management\u201d Project","author":"Yann Loic Philippczyk","date":"12. January 2017","format":false,"excerpt":"Part 4: Jenkins and Wrap Up This series of blog entries describes a student project focused on developing an application by using methods like pair programming, test driven development and deployment pipelines. Our first blog entry for this year will at the same time be the final one for this\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/01\/jenkins_code-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/01\/jenkins_code-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2017\/01\/jenkins_code-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1004,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2016\/07\/21\/rust-fast-and-secure\/","url_meta":{"origin":1782,"position":5},"title":"Rust &#8211; fast and secure","author":"Jakob Schaal","date":"21. July 2016","format":false,"excerpt":"Rust, a fairly new programming language promises to be fast and secure. The following blog entry discusses how Rust tries to achieve these two goals. The key concept is that every resource always belongs to exactly one variable. More precisely one lifetime, which is normally automatically created on variable creation.\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2016\/07\/Rust_programming_language_black_logo.svg_.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"authors":[{"term_id":713,"user_id":219,"is_guest":0,"slug":"hb052","display_name":"hb052","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/5508020be59a4f175951b5aba01c29d51d5093a942399616f8eac61cf4cb55d2?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/1782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/users\/219"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/comments?post=1782"}],"version-history":[{"count":4,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/1782\/revisions"}],"predecessor-version":[{"id":2271,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/1782\/revisions\/2271"}],"wp:attachment":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/media?parent=1782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/categories?post=1782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/tags?post=1782"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/ppma_author?post=1782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}