Download this file
| 1 | package calc |
| 2 | |
| 3 | // Node is any expression node. |
| 4 | type Node interface{ node() } |
| 5 | |
| 6 | type Num struct{ V float64 } |
| 7 | type Str struct{ V string } |
| 8 | type Bool struct{ V bool } |
| 9 | |
| 10 | // Ref is a single-cell reference as written. Positions are what the source |
| 11 | // says; binding to stable ids happens in the reference pass, because |
| 12 | // relative references are positional offsets and must stay that way until |
| 13 | // a paste anchor is known. |
| 14 | type Ref struct { |
| 15 | ColPos, RowPos int |
| 16 | AbsCol, AbsRow bool |
| 17 | } |
| 18 | |
| 19 | type Range struct{ From, To *Ref } |
| 20 | |
| 21 | type Binary struct { |
| 22 | Op string |
| 23 | Left, Right Node |
| 24 | } |
| 25 | |
| 26 | type Unary struct { |
| 27 | Op string |
| 28 | X Node |
| 29 | } |
| 30 | |
| 31 | type Call struct { |
| 32 | Name string |
| 33 | Args []Node |
| 34 | } |
| 35 | |
| 36 | func (*Num) node() {} |
| 37 | func (*Str) node() {} |
| 38 | func (*Bool) node() {} |
| 39 | func (*Ref) node() {} |
| 40 | func (*Range) node() {} |
| 41 | func (*Binary) node() {} |
| 42 | func (*Unary) node() {} |
| 43 | func (*Call) node() {} |
| 44 | |