| commit | b05c53fb01342873787b545359f443b5dbf2be7f | [log] [tgz] |
|---|---|---|
| author | Sketch🕴️ <skallywag@sketch.dev> | Sat Feb 28 19:13:36 2026 +0400 |
| committer | Sketch🕴️ <skallywag@sketch.dev> | Sat Feb 28 19:13:36 2026 +0400 |
| tree | fb628f9aa5e539abc5bd2e64240bb0211707be0b | |
| parent | ad74392541b9a72b521e56673cfdd013532fbd4a [diff] |
parser: implement recursive-descent parser with tests
- Parse([]token.Token) (ast.Node, error) converts tokens to AST
- Grammar: expr → term ((+|-) term)*, term → factor ((*|/) factor)*, factor → NUMBER | '(' expr ')'
- Correct operator precedence (* / before + -)
- Left-associative operators
- Error handling: empty input, missing/unexpected parens, trailing tokens, consecutive operators
- 19 unit tests covering success and error cases