Nicolas Viennot Daniel Benamy 12 19 08 COMS W4115 Final report C Flat ltc Introduction The C Flat language is mostly a subset of the C language Some of the core functionalities of C has been stripped there is no preprocessor no structs no strings not even pointers It s goal is purely educational Originally Nico and Dan were working on two separate languages The two projects merged taking some features from each and this is the resulting language The ltc and C Flat language proposals are included in appendix A C Flat Tutorial C Flat is easy to use for any programmer familiar with a C like language The main differences from C are that there is only one type the integer variables don t have to be declared before use but there are no global variables and there are exceptions Hello World outputs 1 main out 1 Recursive Fibonacci fib n if n 3 return 1 else return fib n 1 fib n 2 main out fib in Iterative Fibonacci fib n if n 1 throw 1 a 1 last fib b 1 current fib for i 3 i n i temp b b a a temp return b main out fib in Language Manual The LRM is included in appendix B Project Plan Processes When we merged projects we decided to start off by implementing as much of the ltc proposal as possible and adding features from the original c flat proposal at the end if we had time The ltc proposal clearly laid out the subset of C which we would be implementing Since we were basing the language off of an existing one there wasn t very much planning that had to go into figuring out how the language would work as far as the users are concerned Our process for progressing through the project was to pick a feature that wasn t implemented and think through how exactly it should work and how it needed to be implemented We sometimes had to compile some test C programs and look at the assembly generated or look up instructions in the Intel x86 manuals to learn exactly how something would work Then we d implement the feature and some tests for it Sometimes we wrote the corresponding part of the LRM at that point and sometimes we filled it in later This normally wouldn t be a great idea but this language is small enough that it worked just fine We had an automated tester which would run a series of code snippets through the compiler run them and verify that the output or lack thereof was correct The tester was an improved version of the tester Dan used last fall in PLT Initially we were also running the test suite that professor Edwards supplied with microc but we eventually migrated to only our tester It was quicker and easier to write tests for this tester because they all go in one file After we did any work on the compiler we d run a quick make test and be able to verify that everything still worked correctly Programming Style Guide For the compiler we stuck with the style already used in microc More or less Indentation 2 spaces Indentation level is increased when declaring a non trivial function that is a function with at least one argument When matching each case should be on it s own line It also increase the indentation level Function names are in lower case with words separated by underscores Structures names and fields are lower case with works separated by underscores Types names lowercase possible values first letter uppercase Tester uses standard python style as outlined in PEP 8 http www python org dev peps pep 0008 Tests lower case variables and functions 2 space indentation For example this is a snippet from backend ml let rec eval expr to eax fdecl function Literal l sprintf mov eax d n l Assignop v o e let assign binop binop eval expr to eax fdecl Assignop v Assign Binop Id v binop e in match o with Assign eval expr to eax fdecl e sprintf mov ebp d eax n id to offset fdecl v Add assign assign binop Add Sub assign assign binop Sub Mult assign assign binop Mult Div assign assign binop Div Project Timeline October Proposals automated tester November Merged projects first assembly program generated skeleton functions basic operators I O if for and while LRM started December Week 1 Nothing Week 2 Many operators proper argument evaluation break continue exceptions Week 3 Static semantic analysis compiler completed LRM completed Roles and Responsibilities We worked together on most aspects of the project Nico implemented a number of language features on his own and Dan got the automated tester going Software Development Environment We are both running a linux OS with its standard tools Kate Vim and Nano Source code editing Ocaml Tool Suite Lexer parser static and semantic analysis backend top level compiler driver Gcc Compiling standard library which is C assembling output of the C Flat compiler linking object files Python Automated tester OpenOffice Report Lyx LRM GNU Make Project building Project Log We used git as a version control system The project history is Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Daniel Benamy Daniel Benamy Nicolas Viennot Daniel Benamy Nicolas Viennot Daniel Benamy Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot Nicolas Viennot 2008 12 18 2008 12 18 2008 12 18 2008 12 18 2008 12 18 2008 12 18 2008 12 17 2008 12 17 2008 12 17 2008 12 17 2008 12 17 2008 12 17 2008 12 17 2008 12 17 2008 12 17 2008 12 17 2008 12 17 2008 12 16 2008 12 16 2008 12 16 2008 12 16 2008 12 15 10 47 49 10 45 37 10 39 08 10 01 23 08 37 28 08 34 34 21 44 26 18 03 25 16 45 58 16 44 52 16 05 22 16 05 00 16 01 14 15 54 58 15 48 23 15 47 16 15 35 01 19 51 18 12 37 58 12 33 02 08 37 29 20 45 41 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 0500 Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas Nicolas 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 15 2008 12 14 2008 12 14 2008 12 14 2008 12 14 2008 12 14 2008 12 14 2008 12 14 2008 12 14 2008 12 13 2008 12 13 2008 12 13 2008 12 13 2008 12 13 2008 12 13 2008 12 13 2008 …
View Full Document
Unlocking...