Skip to content

Ant0in/YaLCC-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖋️ YaLCC Compiler

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.

Parser demo

YaLCC Parser making the ParseTree for OneLiner.ycc

📜 Description

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 forest or tikz packages.

For more detailed problem specifications and additional information, please refer to: ./more/F403project2.pdf or to the report ./doc/report/infof403_part2_report.pdf.

⚙️ Installation

  1. Clone the repository:

    git clone git@github.com:Ant0in/YaLCC-Compiler.git
    cd YaLCC-Compiler
  2. Make sure you have Java JDK 17+ installed and JFlex. Those can be installed using pacman and yay:

    sudo pacman -S jdk17-openjdk
    yay -S jflex
  3. Compile the project using the provided Makefile:

    make

Alternatively, you can compile the project directly using javac.

🛠️ Usage

Running the Parser

To run the parser on a source file, use:

java -jar dist/part2.jar test/<sourcefile>.ycc

You will see the leftmost derivation rule numbers printed to the console.

Exporting LaTeX Parse Trees

Optionally, you can export the parse tree to a LaTeX file:

java -jar dist/part2.jar [-wt output.tex] test/<sourcefile>.ycc
  • output.tex will contain a complete LaTeX document with the parse tree visualization.
  • You can compile it using pdflatex or your preferred LaTeX engine.

📚 Documentation

The complete Javadoc is hosted on Github Pages. It is available here:

👉 View the Javadoc online

✨ Generating Javadoc

To generate the Javadoc, simply run:

make javadoc

Alternatively, 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.

🧪 Running Unit Tests

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 test

📄 License

This project is licensed under the MIT License. See the LICENSE file for more details.

🙏 Acknowledgements

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.

About

Yet Another Language for the Compiler Course (INFO—F403)

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •