PLD Compilateur By the super hexanome whatever its number is (kidding, its 4404).
You will first need to make sure that the Makefile is actually referencing your antlr-cpp runtime. Therefore, you will have to open the Makefile, and take a look at lines 36 through 39 :
ANTLR=/shares/public/tp/ANTLR4-CPP/bin/antlr4#The path to your antlr4 executable
ANTLRRUNTIME=/shares/public/tp/ANTLR4-CPP#Main folder of antlrcpp
ANTLRSRC=$(ANTLRRUNTIME)/antlr4-runtime#Same, but here the runtime is located
LDFLAGS=$(ANTLRRUNTIME)/lib/libantlr4-runtime.a
You may have to change ANTLR, ANTLRRUNTIME, ANTLRSRC and LDFLAGS such that they all point to your personnal antlr files or installation directories.
Remark : The current Makefile is already adapted to the INSA IT department's computers.
You will also need to create the build/ folder at the root of the project, among src/ and tests/. Otherwise, the Makefile won't be correctly executed.
First of all, make sure the grammar is up to date by running :
make Grammaire
Now, just run :
make
in order to build the whole executable. It will be named "./compiler"
Last but not least, if you want to run tests, you can either write :
make test
or
cd tests && bash mktest.sh && cd ..
Which is basically the content of the test target.
Just type :
./compiler
The compiler may take a few options to produce other outputs. Here follows the list of allowed options and their goal :
- -c : Produce assembly (.s) file
- -o : Proceed optimisation
- -a : Proceed static analysis
- -t : View the Tree structure of the Program
- -m : Produce assembly for MSP_430 target
Here's a description of the folder hierarchy :
- src : Source code
- parser : Every bit of code dealing with the antlr lexers and parsers. You'll find there the grammar (expr.g4) and the visitors' implementation (visitor.cpp)
- ast : You will find here every class modelling what our C program consists of, i.e. AST...
- ir : You will find every item about IR.
- main : This folder name is perhaps obvious about its content.
- tests : You will find here a list of tests that can be run with the command *make test*. Every category of test is arranged in subfolders.
- ValidPrograms : programs that should normally compile with our executable.
- LexError : Program generating a Lexer Error.
- SyntaxError : Same, with syntax.
- SemanticError : Same, with semantics.
- Moodle : All the tests that were downloaded from Moodle
- Front
- Back
- build : It's useless to take a look at it, unless you know how to read .o files.
Sure ! Please check tests/DemonstrationPrograms and run the compiler executable on every .c file !