Codebase Structure
Last updated
Was this helpful?
Last updated
Was this helpful?
Here is a timeline of events that happen when a user invokes the Varphi Interpreter (vpi
) on a Varphi file:
The Varphi Interpreter executable, through , parses the arguments supplied to the executable. It extract's the user's Varphi source code file path, and determines what the compilation target will be (either a command-line program, command-line program with debugging, or debug adapter).
The user's Varphi source code file is opened for reading, and it's contents are passed through a lexer. The lexer tokenizes the code and catches specific syntax errors at this stage (specifically, a syntax error is thrown by the lexer only if a line element does not fit the criteria to be a state name, tally, blank, or head direction).
The Varphi codebase consists of two parts:
The Varphi-to-Python Compiler
The Varphi Interpreter
The Varphi-to-Python Compiler is a (non-published) Python package and is located under the varphi
directory in the source code directory.
The three components of the Varphi-to-Python Compiler are:
The lexer and parser
The translators (Compilers)
The Varphi Runtime Library
The lexer and parser are generated from a grammar file (Varphi.g4
) and are not included in the source code. When Varphi is built, they are located under varphi/parsing/VarphiLexer.py
and varphi/parsing/VarphiParser.py
, respectively.
Varphi includes a translator, or compiler, for every possible target (command-line program, debug adapter, etc.). These are located under varphi/compilation/varphi_translator.py
.
The Varphi Runtime Library is a set of utilities used by the Python code which Varphi programs are compiled to. This library is located under varphi/runtime
.