You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
||8 months ago|
|.gitattributes||5 years ago|
|.gitignore||8 months ago|
|AwesomePascal.cpp||8 months ago|
|AwesomePascal.vcxproj||8 months ago|
|InsertionSort.pas||8 months ago|
|LICENSE||4 years ago|
|NumericExpr.pas||8 months ago|
|README.md||8 months ago|
Another PL/0 language (https://en.wikipedia.org/wiki/PL/0) compiler and debugger that is written in C++.
This code came from my undergrad course project for compiler principles in 2015. The code quality is beyond horrible but it's some of my earliest big projects.
- The compiler uses SLR(1) parsing. The grammar is hard-coded in the form of an LR parsing table (
states) and the FOLLOW set (
follows) which is initialized in
- The compiler was written from the ground up without any third-party libraries except the standard C++ library.
- It contains:
- A lexer (
GETSYM()function) that processes the input into tokens and literals while constructing a symbol table
- A parser (
BLOCK()function) that uses shift/reduce-parsing to generate the target code (pseudo-assembly)
- An interpreter (
INTERPRET()function) that executes the pseudo-assembly code.
- A lexer (
- MSVC project: AwesomePascal.vcxproj
- GNU C++/Clang: compile AwesomePascal.cpp directly
- InsertionSort.pas: A simple program that takes 5 integers and sorts them in descending order.
- NumericExpr.pas: A simple program that contains numerical expressions and control flow.
$ g++ -O3 -DNDEBUG AwesomePascal.cpp -o BP
$ ./BP InsersionSort.pas