The Kompilattheur Compiler is "a MiniPython compiler designed to compile MiniPython. It translates MiniPython source code into intermediate representation.
- Baptiste JULLIEN
- Luca MANDRELLI
- Romain PONSON--LISSALDE
- Aristide URLI
- Rust.
- Why not ?
- Cross-platform: Runs on linux
- Optimization: None yet
- Error Reporting: Detailed syntax and semantic error message
- Analysis table generation: Generate analysis tables with the
print-analysis-table
andgenerate-analysis-table
commands - Runtime optional grammar parsing: You can use an alternative grammar at runtime with the
--alternative-grammar
option - Shell autocompletion: Generate autocompletion scripts for your shell
- Rust: Ensure you have a Rust compiler installed.
Clone the repository and install any required dependencies:
$ git clone https://gibson.telecomnancy.univ-lorraine.fr/projets/2425/compil/kompillatheur.git
$ cd kompillatheur
$ cargo install --path .
To compile the compiler without installing it, use :
For debug build :
cargo build
For release build :
cargo build --profile release
The compiler can generate auto-completion scripts for most shells :
For bash
kompilattheur generate-autocompletion bash > /usr/share/bash-completion/completions/kompilattheur.bash
kompilattheur generate-autocompletion zsh > /usr/local/share/zsh/site-functions/_kompilattheur
Currently supported shells are bash
, elvish
, fish
, powershell
and zsh
.
To install the auto-completion script, refer to your shell's manual.
To compile a MiniPython source file:
$ kompillatheur [source-file]
Use kompillatheur help
to see all command line options
You can generate an analysis table for a grammar with the generate-analysis-table
subcommand.
The grammar must be in a file that follows the grammophone syntax.
kompilattheur generate-analysis-table grammaire.txt -o src/analysis_table/generated_table.rs
Optionnaly, you can make the generator add comments to the file for easier debugging wiht the --with-comments
option.
You can print the compiler's analysis table or a generated analysis table with the print-analysis-table
subcommand.
Printing is supported in different formats :
plaintext
: Readable plain textmarkdown
: Markdown table format, most readable when renderedrust
: Rust source code, equivalent to usinggenerate-analysis-table
# Print the built-in analysis table in markdown format to the analysis table.md file
kompilattheur print-analysis-table --format markdown -o analysis_table.md
# Generate and print an analysis table for the grammar_ex.txt grammar
kompilattheur print-analysis-table -g grammaire_ex.txt
You can generate an analysis table to use for compilation from another grammar at runtime with the --alternative-grammar
option :
kompilattheur -g grammaire_ex.txt test_programs/arithmetic.smolpp
$ kompillatheur example.smolpp
For more examples, refer to the test_programs/
directory.
To run tests, use
$ cargo test
If you encounter any issues or have feature requests, please open an issue on the GitHub repository.
To ensure consistent code formatting, the project includes git hooks. After cloning, run:
./setup-hooks.sh
This will set up a pre-commit hook that runs cargo fmt --check
before each commit to ensure proper code formatting.