ayushjain1144 / erplag-cc

Compiler for the custom language 'ERPLAG' in C.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

erplag-cc

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)

Build

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

Compilation Steps

The compilation is broken into the following steps. (see Dragon Book):

Visualization for each of these steps is available. For instance, this is how a part of the Syntax Tree looks like:

Features:

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.

Authors

Notes:

  • A big thanks to Divesh for his amazing AST visualiser.
  • This was an excellent reference.
  • A nice tutorial for nasm.
  • nasm docs.
  • nasm debugging guide

License

MPL-2.0

About

Compiler for the custom language 'ERPLAG' in C.

License:Mozilla Public License 2.0


Languages

Language:C 97.8%Language:C++ 1.7%Language:Makefile 0.5%