My open course on Compilers, Grammars and Programming Languages
This repository contains the code I wrote for my self-inflicted class about Compilers https://pgrandinetti.github.io/compilers/.
Use it at your risks.
As side project for a MOOC on Compilers I built a new (basic) programming language. Turing-complete, but without supports for many things.
This repo contains the Grammar's specifications, as well as the compiler for this new language, written in C and organized in 4 modules:
- Lexical Analysis
- Parsing
- Semantic Analysis
- Code Generation
- Compile my Compiler! You'll need a C compiler, e.g.
gcc main.c cgen.c parser.c lexer.c
- Write your program in my language and place it in a text file. An example is offered in the repo with the file
code.e
. - Now compile your program with
./a.out ./code.e
.
The result is a Python executable script, by default ./out.py
. You can optionally run ./a.out ./code.e /home/user/result.py
, to specify the path for the output file.
- Why generated code is in Python?
- What is my language?
- How does the Compiler work?