https://github.com/leonardpepa/reverse-polish-notation
Reverse Polish notation lexer, parser and very small compiler that generates jvm assembly code. The programs just calculates the mathematical expression (+, -, * , /) and prints out the answer.
https://github.com/leonardpepa/reverse-polish-notation
c compiler-design jvm lexer lexer-parser parser programming-languages reverse-polish-notation
Last synced: 7 months ago
JSON representation
Reverse Polish notation lexer, parser and very small compiler that generates jvm assembly code. The programs just calculates the mathematical expression (+, -, * , /) and prints out the answer.
- Host: GitHub
- URL: https://github.com/leonardpepa/reverse-polish-notation
- Owner: Leonardpepa
- License: mit
- Created: 2022-07-15T18:32:50.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-19T15:03:12.000Z (about 3 years ago)
- Last Synced: 2025-01-17T08:45:45.830Z (9 months ago)
- Topics: c, compiler-design, jvm, lexer, lexer-parser, parser, programming-languages, reverse-polish-notation
- Language: C
- Homepage: https://github.com/Leonardpepa/Reverse-Polish-Notation
- Size: 365 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Reverse-Polish-Notation
Reverse Polish notation lexer, parser and very small compiler that generates jvm assembly code.
The programs just calculates the mathematical expression (+, -, * , /) and prints out the answer.# Project for learning and experimenting
the purpose of this project is to create this simple compiler without any compiler generator tools.
all the compoments are handwritten by me (simple lexer, top down parser and code generation)# Lexer
tokens:
* integers
* math op [+, -, *, /]
* keywords [start, end]
* semicolon [to seperate the expressions]
* EOF# Parser
Simple top down parser, implemented with recursive descent.# Code generation
code generated for jasmin assember that can run on the java virtual machine# Makefile
* make [Compiles the files needed for execution]
* make clean [cleans files]
# How to run
* ./run < filename > [only files without extension supported]# Prerequisite
* gcc compiler
* java
* jasmin [on linux you can just sudo apt install jasmin-sable]
* make [needed for make file otherwise you can compile the files by your self]# LL Grammar
* s ::= start stmts end
* stmts ::= stmt ; listStmts
* listStmts ::= stmts | EPSILON
* stmt ::= rev
* rev ::= num rec_rev
* rec_rev ::= rev op rec_rev | EPSILON