Tree-walk interpreter in TypeScript for a pipe-oriented functional language.
After modifying or adding functionality, always update:
- Tests — Unit tests in
__tests__/, integration tests intests/ - Examples — Files in
examples/ - Syntax highlighting — VSCode extension in
vscode-lea/ - Documentation — Relevant files in
docs/
docs/SYNTAX.md— Full syntax referencedocs/BUILTINS.md— All built-in functionsdocs/PIPELINES.md— First-class pipelinesdocs/CHEATSHEET.md— Quick reference
Source → Lexer → Tokens → Parser → AST → Interpreter → Result
src/lexer.ts— Tokenization (TokenType enum, KEYWORDS map)src/parser.ts— Recursive descent parsersrc/ast.ts— AST node types (Expr, Stmt, Program)src/interpreter.ts— Tree-walk interpreter, Environment classsrc/lsp/— Language Server Protocol implementation
NUMBER, STRING, TEMPLATE_STRING, IDENTIFIER
LET, AND, MAYBE, TRUE, FALSE, AWAIT, CONTEXT, PROVIDE, DECORATOR, MATCH, IF, THEN, ELSE, RETURN, INPUT, USE
PIPE (/>), SPREAD_PIPE (/>>>), PARALLEL_PIPE (\>), ARROW (->), REVERSE_ARROW (<-)
REVERSE_PIPE (</), BIDIRECTIONAL_PIPE (</>), REACTIVE_PIPE (@>), PIPE_CHAR (|)
PLUS, MINUS, STAR, SLASH, PERCENT, CONCAT (++)
EQ, EQEQ, NEQ, LT, GT, LTE, GTE, DOUBLE_COLON (::), COLON_GT (:>)
LPAREN, RPAREN, LBRACKET, RBRACKET, LBRACE, RBRACE
COMMA, COLON, DOT, SPREAD (...), UNDERSCORE, HASH, AT, QUESTION
CODEBLOCK_OPEN ({-- --}), CODEBLOCK_CLOSE ({/--})
NEWLINE, EOF
Expressions: NumberLiteral, StringLiteral, TemplateStringExpr, BooleanLiteral, Identifier, BinaryExpr, UnaryExpr, PipeExpr, SpreadPipeExpr, ParallelPipeExpr, CallExpr, FunctionExpr, ListExpr, IndexExpr, PlaceholderExpr, TupleExpr, RecordExpr, MemberExpr, TernaryExpr, AwaitExpr, BlockBody, ReturnExpr, PipelineLiteral, ReversePipeExpr, UseExpr, BidirectionalPipelineLiteral, MatchExpr, ReactivePipeExpr
Statements: LetStmt, AndStmt, AssignStmt, ExprStmt, ContextDefStmt, ProvideStmt, DecoratorDefStmt, CodeblockStmt
- Ternary (
? :) - Equality (
==,!=) - Comparison (
<,>,<=,>=) - Term (
+,-,++) - Factor (
*,/,%) - Pipe (
/>,/>>>,\>,</) - Unary (
-) - Call
- Primary
npm run lea file.lea # Run file
npm run repl # Interactive REPL
npm test # Unit tests
npm run test:integration # Integration tests
npm run visualize -- file.lea # Output Mermaid markdown
npm run visualize -- file.lea --html # Output HTML with diagram