erplag-cc is a compiler for the language ERPLAG
. (see specs), written in C. The compiler generates assembly code that can be run on a Linux machine. (NASM, v2.14.0, 64-bit)
The name erplag
is derived from names of these 6 Turing Award Winners:
E = Edsger W Dijkstra (1972)
R = Ritchie, Dennis (1983)
P = Patterson, David (2017)
L = Lamport, Leslie (2013)
A = Allen, Elizabeth (2006)
G = Geoffrey Hinton (2018)
Run make
to link and create the compiler executable
$ make
Execute the compiler with an erplag file, test.erplag
, and store the assembly code into code.asm
$ ./compiler test.erplag code.asm
Finally, use nasm to run the assembly code
$ nasm -felf64 code.asm && gcc -o exec code.o && ./exec
The compilation is broken into the following steps. (see Dragon Book):
- Lexer (tokenizer)
- Parser (and syntax checking)
- Abstract Syntax Tree (with ~60% compression)
- Symbol Table (and static type checking)
- Semantic Analysis
- Code Generation (and runtime checking)
Visualization for each of these steps is available. For instance, this is how a part of the Syntax Tree looks like:
Some salient features of ERPLAG
are:
- Scientific notation support for real numbers
- Dynamically created and bounded arrays
- Multiple function return values
- Indirect recursive calls
- Direct, user-prompt input support for arrays
Other features like loops, conditionals, scopes, declarations are similar to their Pascal/C counterparts.
- Ayush Jain (f20170093@pilani-bits-pilani.ac.in)
- Satvik Golechha (f20170117@pilani-bits-pilani.ac.in)
- Bharat Bhargava (f20170025@pilani-bits-pilani.ac.in)