For the purpose of Compilers II lesson in the CSE Dept @ University of Ioannina was developed an OOP language compiling to C code. In this repository the project is refactored from scratch according to the initial requirements.
class Fibonacci:
int x;;
def __init__(self): Fibonacci;;
def fib(self, int n): int
if(n <= 1):
return n;
endif;
return fib(n-1) + fib(n-2)
;;
class Main:
int x, y ;
Fibonacci f
;;
def main(self): -
$Fibonacci(self.f);
input self.x;
self.y = self.f.fib(self.x);
print self.y
;;
Download ANTLR4 jar and install python runtime
bash pip install antlr4-python3-runtime
docker run -it --rm thppn/antlr4-python:latest
bash java -jar antlr/antlr-4.13.2-complete.jar -Dlanguage=Python3 -o grammar ./ppp.g4
bash python main.py examples/<program>/<program>.ppp
bash gcc output.c && ./a.out
- error messages
- create more examples
- all types support
- arrays