The Aim of the project is to build a compiler from Scatch using tools such as ML-Lex and ML-Yacc. A Compiler for a simplified version of C, which creates an Abstract Parse Tree and Translates to JavaScript.
This can be further executed using Node.js or the Web Browser.
- mutable variables of type int and string
- arithmetic operations: + - / * % :=
- conditional operations: > < >= <= != = ! && ||
- if then clause
- if then else clause
- for loop
- while loop
- do while loop
- reading input from user
- printing output to user
- user-defined functions
- lexer.lex : Lexing tokens for the language
- grammar.grm : Grammar for the language
- ast.sml : The abstract syntax tree structure
- translate.sml : Translator to convert the language to JavaScript
- parse.sml : The driver program that parses and translates the source program
$ make
$ ./compiler filename.txt
- open
samples/index.html
- enter file name of the JS file
- Open Dev Console (CTRL + SHIFT + C) for the output
- Adrian McDonald Tariang - 111501001
- Sooraj Tom - 111501036
- Course on Compiler Design
- Modern Compiler Implementation in ML" by Andrew W. Appel