A tree-walk interpreter for Miniscript supporting:
- Data Types:
- Numbers: Standard Math, Mod, Power, Logical Operators, Comparison
- String: Concatenation, Subtraction, Replication, Division
- Bool
- Null
- Control Flow:
- If: else if, else and nested
- While: with break and continue
- Function: recursion and mutual recursion
- We support to main mode of execution: REPL or Miniscript
.ms
file. We will outputexecution.log
detailing or interpreting steps with any errors flagged andresult.log
for the final execution result.
- Our interpreter follows a simple FSM consisting of:
Init
: intialize value and contextLexing
: tokenisationParsing
: syntax analysis to abstract syntax tree (AST)Executing
: execute Miniscript code based on ASTLexing Error
: handle Tokenisation ErrorParsing Error
: handle Syntax ErrorExecuting Error
: handle Runtime ErrorCleaning
: free memory used
- Build the interpreter
cd src
make clean && make
- Run REPL:
./miniscript
- Run file:
./miniscript path/to/your/file.ms
- You can find our Miniscript test files in the test folders.