blob: f1e953d0b167e32e94c194c1c1ba3793e2531e2d [file] [log] [blame]
Sketch🕴️ad743922026-02-28 19:11:41 +04001package ast
2
3import "matheval/token"
4
5// Node is the interface all AST nodes implement.
6// The unexported marker method seals the interface — only types
7// in this package can implement it.
8type Node interface {
9 node() // sealed marker
10}
11
12// NumberLit represents a numeric literal (e.g. 3.14).
13type NumberLit struct {
14 Value float64
15}
16
17func (*NumberLit) node() {}
18
19// BinaryExpr represents a binary operation (e.g. 1 + 2).
20type BinaryExpr struct {
21 Op token.Type // Plus, Minus, Star, Slash
22 Left Node
23 Right Node
24}
25
26func (*BinaryExpr) node() {}