962 B
962 B
JOURNAL-lex
2026-06-15
Build
Created calc/__init__.py (empty package marker) and calc/lexer.py implementing:
Tokendataclass withkind(str) andvalue(int | float | None)LexError(Exception)raised on invalid characters with offending char and positiontokenize(src: str) -> list[Token]covering numbers (int/float, leading/trailing dot), operators, parens, whitespace skipping, and error raisingEOFsingleton token appended at end of every token list
Created calc/test_lexer.py with 18 unittest cases covering D1–D3 including the three mandatory inputs.
Verification
All four DoD gates observed passing:
- D1: integers, floats (3.14, .5, 10.) tokenize correctly with right Python type
- D2: all six operator/paren kinds correct;
1+2*3yields expected sequence - D3: whitespace skipped;
@raises LexError with position 2 in message - D4: 18 tests, 0 failures
Commit: 70b71caacd1f7334e387ff15b007573201b524b6