Skip to content

none9632/tinyCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinyCompiler

This is a very small and simple compiler that implements basic arithmetic operations. This project was created in order to understand the basic principles of the compiler that will later be used to create myCompiler. An expression of type 1+1 ( or another expression that matches the grammar ) is fed to the compiler input and the output file output.asm in which this expression is implemented in NASM assembler.

Build and run

$ make
$ ./tinyCompiler [options] <expression>

Testing

$ make test

Grammar

<program> ::= <expr>

<expr>    ::= <term> { ( "+" | "-" ) <term> }
<term>    ::= <term> { ( "*" | "/" ) <term> }
<factor>  ::= <NUM> | "(" <expr> ")"

<NUM>     ::= <digit> { <digit> }
<digit>   ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0"

Author

Ivan Andreev
Email: ivanandreev1234@protonmail.com

Links

License

MIT License

Releases

No releases published

Packages

No packages published