Welcome to the YaLCC compiler! This project is part of the Language Theory course INFO—F403 at ULB. It implements the lexical analysis and the parsing, constructing the recursive descent parse trees for a toy programming language called YaLCC.
This Java project provides:
- A lexer generated with JFlex.
- Recursive-descent parser generating parse trees for YaLCC.
- Tracking of leftmost derivation rule numbers.
- Optional LaTeX export for visualizing parse trees using
forestortikzpackages.
For more detailed problem specifications and additional information, please refer to: ./more/F403project2.pdf or to the report ./doc/report/infof403_part2_report.pdf.
-
Clone the repository:
git clone git@github.com:Ant0in/YaLCC-Compiler.git cd YaLCC-Compiler -
Make sure you have Java JDK 17+ installed and JFlex. Those can be installed using
pacmanandyay:sudo pacman -S jdk17-openjdk yay -S jflex
-
Compile the project using the provided
Makefile:make
Alternatively, you can compile the project directly using javac.
To run the parser on a source file, use:
java -jar dist/part2.jar test/<sourcefile>.yccYou will see the leftmost derivation rule numbers printed to the console.
Optionally, you can export the parse tree to a LaTeX file:
java -jar dist/part2.jar [-wt output.tex] test/<sourcefile>.yccoutput.texwill contain a complete LaTeX document with the parse tree visualization.- You can compile it using
pdflatexor your preferred LaTeX engine.
The complete Javadoc is hosted on Github Pages. It is available here:
To generate the Javadoc, simply run:
make javadocAlternatively, you can do it by hand, using:
javadoc -Xdoclint:none -html5 -d doc src/*.java # use -private flag to show `all members`-d doc: output folder for HTML doc files.src/*.java: java files to generate doc from.
Once generated, open doc/index.html in a browser to explore the documentation.
To ensure the project works as expected, you can run the JUnit 5 tests for the YaLCC included in the repository.
The Makefile provides a test target. When executed, it will:
- Ensure the
lib/folder exists and download the JUnit 5 standalone JAR if missing. - Compile all test files located in
test/java/. - Run all tests automatically.
Simply run:
make testThis project is licensed under the MIT License. See the LICENSE file for more details.
This project was developed for the Introduction to language theory and compiling course INFO—F403. Special thanks to Gilles Geeraerts (ULB) and Arnaud Leponce (ULB) for their guidance and support.
