interpreter
A custom language with a TypeScript lexer, parser and AST interpreter. The source pipeline lives in src/index.ts.
Components
Section titled “Components”| Class | Input | Result |
|---|---|---|
| Lexer | Source string | Token array |
| Parser | Token array in constructor | ProgramNode from parse() |
| Interpreter | ASTNode passed to interpret() | Value of the last processed node |
The lexer recognizes XML-like delimiters, ::, $, numbers and identifiers. Parser routes XMLTag to class/function declarations, PHPVariable to assignments and Identifier to module imports. Node types are declared in src/types.d.ts.
AST execution
Section titled “AST execution”Program processes body sequentially. VariableAssignment updates the variable map; Identifier reads it and throws for unknown names; Literal returns value. Class/function declarations and imports are stored as nodes: interpretClassDeclaration and interpretFunctionDeclaration do not execute their bodies. Unknown node types produce Unknown node type.
src/index.ts accepts exactly one file path, reads UTF-8 source, builds tokens/AST and prints the interpretation result. test.zorin illustrates syntax but the Parser defines actual parsing. TypeScript/ts-node dependencies are declared in package.json.
Source · AGPL-3.0