Files
rexlang/examples/calc/ast.dino
T
Your NameandClaude Sonnet 5.5 eaf9567a36 Dino compiler: language, formatter, language server, docs, editor support
Compiler in Rust (lexer, parser, checker, C codegen), maps, chars,
dino fmt, dino lsp (diagnostics, formatting, outline, definition,
hover, completion, signature help), docs, examples, VS Code/Vim files.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 23:46:12 +01:00

16 lines
527 B
Plaintext

// The shape of a parsed calculation.
pub enum Node {
Num(value: float)
Var(name: string)
Neg(inner: []Node)
Bin(op: string, sides: []Node)
Call(name: string, args: []Node)
Assign(name: string, value: []Node)
}
// Enums can't hold themselves directly, so children live in a list of one or two.
pub func neg(n: Node): Node { return Node.Neg([n]) }
pub func bin(op: string, l, r: Node): Node { return Node.Bin(op, [l, r]) }
pub func assign(name: string, v: Node): Node { return Node.Assign(name, [v]) }