What is JST?
JST is a compiler for ANSI C written in Python using the PLY library. It is a group project for the Compiler Construction course taught by Dr. Fred Harris at the University of Nevada, Reno.
Requirements
- Python3.4+
sudo apt-get install python3 - PLY
pip3 install ply - bintrees
pip3 install bintrees - pylru
pip3 install ply
Features
- Variable declaration
int x; - Variable assignment
x = 5 + 7; - Conditional statements
if(x > 1) .. else if(x == 1) ... else - N-Dimensional Array declaration
char buffer[16]; - N-Dimensional Array access
buffer[0] = buffer[1]; - For loops
for(x = 0; x < 16; ++x) {} - While loops
- Do .. While loops
- Function declaration
long isWorking(); - Function implementation
long isWorking() { return 1; } - Function calls
isWorking(); - Recursive function calls
int isRecursive() { return isRecursive(); } - Functions that accept arrays as parameters
takeThisArray(int arrrrr[][]); - Library functions
print_string(hello_world); - Constant folding
int folded_at_compile_time = 5 + 10; - Fragmented strings
"This" "becomes" "one" "string";
Assumptions
- Programs are reasonably close to C syntax (as the grammar allows some very strange programs to be parsed)
- Every program must declare a main function with the signature
int main();
Restrictions
- Parse terminates if an error is raised
- Pointers are not implemented
- Typedefs are not implemented
- Structs and unions are not implemented
Future Work
- Flesh out floating point operations
- Make use of floating point and string
- More optimizations
- More of the basic language features
- Pointers
- Typedef
- Function pointers
- Structs
- Unions