Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/felipenugo/cantor-interpreter/llms.txt

Use this file to discover all available pages before exploring further.

Setting up Cantor Interpreter involves three things: cloning the repository, installing the Python packages that provide the ANTLR4 runtime, and running make to generate the parser files from the grammar. The steps below walk through each one.

Requirements

RequirementMinimum versionPurpose
Python3.12Running the interpreter
Java11 or newerRunning the ANTLR4 tool during code generation
antlr4-python3-runtime4.13.1ANTLR4 runtime used at parse time
antlr4-toolslatestProvides the antlr4 CLI that generates parser source files
Java is only required during the make step that generates the parser files. Once cantorLexer.py, cantorParser.py, and cantorVisitor.py have been created, you do not need Java to run Cantor programs.

Installation steps

1

Clone the repository

git clone https://github.com/felipenugo/cantor-interpreter.git
cd cantor-interpreter
2

Install Python dependencies

Install the two required packages — the ANTLR4 Python runtime and the ANTLR4 tools — using either of the following commands:
pip install -r requirements.txt
Or, using the provided Makefile target:
make deps
Both commands install exactly the packages listed in requirements.txt:
antlr4-python3-runtime==4.13.1
antlr4-tools
3

Generate the ANTLR4 parser

Run make (with no arguments) to invoke ANTLR4 on the grammar file and generate the Python source files:
make
The Makefile runs ANTLR4 inside the src/ directory so that all generated files are placed there:
cd src && antlr4 -Dlanguage=Python3 -visitor -no-listener cantor.g4
After this step, the following files appear in src/:
Generated fileDescription
cantorLexer.pyTokenises .cantor source files
cantorParser.pyBuilds the parse tree from the token stream
cantorVisitor.pyBase visitor class used by CantorInterpreter
cantor.interp, cantor.tokens, cantorLexer.interp, cantorLexer.tokensANTLR4 metadata files (not used directly)
The generated files are produced entirely from src/cantor.g4. Do not edit them by hand — any changes will be overwritten the next time you run make.

Utility Makefile targets

Beyond the default build, the Makefile provides several helpful targets.

make clean

Removes all ANTLR4-generated Python source files, metadata files, and Python cache directories (__pycache__, .ruff_cache, .antlr):
make clean

make re

Equivalent to make clean && make — rebuilds everything from scratch. Use this if you modify the grammar file src/cantor.g4 and need a guaranteed clean rebuild:
make re

make deps

Installs Python dependencies via pip. Useful as a quick shorthand instead of typing the full pip install command:
make deps

Verifying the installation

Once make completes, confirm the generated files exist:
ls src/cantorLexer.py src/cantorParser.py src/cantorVisitor.py
Then run a quick smoke test by piping two numbers into the built-in addition example:
echo "3 2" | python3 cantor.py tests/programs/phase1-core/suma.cantor
Expected output:
5
If you see 5, the interpreter is correctly installed and the parser was generated successfully.

Build docs developers (and LLMs) love