1.1 KiB
DECISIONS (append-only, settled design decisions)
lex phase
D-LEX-1: Token uses @dataclass for equality and repr, making test assertions clean.
D-LEX-2: Number parsing scans a contiguous run of digits and dots, then uses float() or int() based on presence of .. Edge cases .5 and 10. handled correctly by Python's built-in conversion.
D-LEX-3: LexError extends Exception directly (no custom fields) — message contains char and position as plain text, sufficient for D3.
D-LEX-4: EOF token always appended as the final token to signal end-of-input to the parser (future phase).
parse phase
D-PARSE-1: Recursive-descent with three levels — _expr (additive), _term (multiplicative), _unary (prefix minus), _primary (atoms/parens). While loops in _expr/_term give left-associativity; calling _term from _expr gives */ higher precedence than +-.
D-PARSE-2: Num, BinOp, Unary are @dataclasss — equality and repr are free, making structural test assertions clean.
D-PARSE-3: ParseError extends Exception directly. Message contains the unexpected token kind/value, sufficient for D5.