Yet Another Compiler
A compiler from C Subset to Javascript
- Compile 'mycom.grm' file using 'mlyacc mycom.grm'
- Compile 'mycom.lex' file using 'mllex mycom.lex'
- Run myC.mlb using 'mlton myC.mlb'
- Run the output executable file. (./myC test1.c) The output would be in out.js file
- Control statements (if, else, break, continue)
- Loop (while)
- Variables
- Arithmetic operators(+, -, *, /, %)
- Logical operators(&&, ||)
- Assignment operator(=)
- Relational Operators(<, >, <=, >=, ==)
- Function defenitions
- Types(Int, Float, Char)
Contains the datatypes to encode the abstract syntax tree.
ML Basis file that contain all the source files of the project.
Describes the grammar of the language.
Rules for token matching.
Driver program. Join lex and yacc files. Initiates parsing.
Converts the ast to javascript code.
- print and return can support only with single variable.
- usage of print : print(variable);