artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
# JOURNAL-lex
|
||||
|
||||
## Implementation notes
|
||||
|
||||
Built `calc/lexer.py` with:
|
||||
- `Token` dataclass with `kind: str` and `value: Union[int, float, None]`
|
||||
- `LexError(Exception)` for invalid characters
|
||||
- `tokenize(src: str) -> list[Token]` scanning character by character
|
||||
|
||||
Number scanning handles all three forms: integer (`42`), standard float (`3.14`), leading-dot float (`.5`), and trailing-dot float (`10.`). The key invariant: when `ch` is `.` we only enter number scanning if the next char is also a digit (to avoid confusing `.` used as an operator in other contexts). Trailing dot (`10.`) is handled because after scanning digits we check if the next char is `.` and absorb it into a float.
|
||||
|
||||
14 tests written covering D1-D4 plus edge cases.
|
||||
Reference in New Issue
Block a user