This document explains how to compile a grammar and execute a test program using the Rationnel compiler and the MVaP virtual machine.
Prerequisites:
- ANTLR must be installed and configured.
- MVaP must be installed and added to the CLASSPATH.
- Java (JDK 8+) must be available.
See: - installAntlr.md - installMVaP.md
From inside the TP directory containing the grammar file (for example
Rationnel.g4), run:
antlr4 Rationnel.g4This generates the lexer and parser Java source files.
javac *.javaThis produces .class files for the parser and related components.
Assuming a test program is located in:
tests/test_program.rat
Run:
grun Rationnel start < tests/test_program.ratThis executes the compiler and generates the corresponding MVaP code
(typically out.mvap).
java -cp $CLASSPATH MVaPAssembler out.mvapThis produces:
out.mvap.cbap
which is the executable bytecode.
java -jar $HOME/bin/MVaP.jar out.mvap.cbapTo execute in debug mode:
java -jar $HOME/bin/MVaP.jar -d out.mvap.cbapThis displays step-by-step execution information.
- antlr4 Rationnel.g4\
- javac *.java\
- grun Rationnel start < tests/test_program.rat\
- java -cp $CLASSPATH MVaPAssembler out.mvap\
- java -jar $HOME/bin/MVaP.jar out.mvap.cbap
This sequence compiles, assembles, and executes a program using the compiler.