| Sketch🕴️ | ad74392 | 2026-02-28 19:11:41 +0400 | [diff] [blame] | 1 | package ast |
| 2 | |
| 3 | import "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. |
| 8 | type Node interface { |
| 9 | node() // sealed marker |
| 10 | } |
| 11 | |
| 12 | // NumberLit represents a numeric literal (e.g. 3.14). |
| 13 | type NumberLit struct { |
| 14 | Value float64 |
| 15 | } |
| 16 | |
| 17 | func (*NumberLit) node() {} |
| 18 | |
| 19 | // BinaryExpr represents a binary operation (e.g. 1 + 2). |
| 20 | type BinaryExpr struct { |
| 21 | Op token.Type // Plus, Minus, Star, Slash |
| 22 | Left Node |
| 23 | Right Node |
| 24 | } |
| 25 | |
| 26 | func (*BinaryExpr) node() {} |