801 B
801 B
JOURNAL-lex
2026-06-15
Build
- Created
calc/__init__.py(empty package marker) - Created
calc/lexer.py:Token(NamedTuple withkindandvalue),LexError,tokenize(src)- Handles integers (int), floats (float, including
.5and10.edge cases) - Single-char operators:
+ - * / ( ) - Whitespace (space, tab) skipped
- Invalid chars raise
LexErrorwith char repr and position - Appends
EOFtoken at end
- Handles integers (int), floats (float, including
- Created
calc/test_lexer.py: 14 unittest cases covering D1–D3
Verification
python -m unittest -q→ 14 tests, 0 failures — PASStokenize('3.5*(1-2)')→ correct 8-token sequence — PASStokenize('1 @ 2')→ raisesLexError: unexpected character '@' at position 2— PASS
Commit
7ac5cdaded6af3b635d6d638f9c20082b5648393