Skip to content

Latest commit

 

History

History
22 lines (13 loc) · 1.32 KB

README.md

File metadata and controls

22 lines (13 loc) · 1.32 KB

C-Compiler-

C program Compiler written in F#

  1. Is the input program a valid simple C program? True or false

  2. If the program is not valid, a syntax error message of the form “expecting X, but found Y”.

  3. If the program is valid, an equivalent simple ASM program. Note that “simple C” is really very simple C --- no pointers, no arrays, no types other than integer, no loops, very simple expressions, etc. Here’s an example simple C program

What A simple C program can look like:

Screen Shot 2019-05-15 at 7 58 21 AM

What the output of this F# program will be in case of #3 above: Screen Shot 2019-05-15 at 7 58 27 AM

Getting this output first we take the Simple C like above, and create the BNF Definition shown below: Screen Shot 2019-05-15 at 7 58 38 AM

Then we write a function for each rule or "Recursive descent parsing" which is done in F# in this case. Finally giving us the proper ASM program which was shown above as well.