artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs

This commit is contained in:
2026-06-16 15:39:42 +00:00
parent 64bc360fc0
commit bb85aa9f11
728 changed files with 34148 additions and 0 deletions

View File

@ -0,0 +1,59 @@
# STATUS — phase `lex`
## DONE
## Claimed Gates
claim(D1): Numbers — integers and floats tokenize to NUMBER tokens with correct numeric values.
claim(D2): Operators & parens — `+ - * / ( )` each produce the right kind token.
claim(D3): Whitespace & errors — spaces/tabs skipped; invalid chars raise `LexError` with char + position.
claim(D4): Tests green — `python -m unittest -q` passes, 12 tests, 0 failures.
## Commit
SHA: a1c68aa
Files:
- `calc/lexer.py``Token`, `LexError`, `tokenize()`
- `calc/test_lexer.py` — 12 unittest tests covering D1D4
- `calc/__init__.py` — empty package init
## How to Verify (exact commands from plan)
```bash
# D4 — tests pass
python -m unittest -q
# Expected: "Ran 12 tests in 0.00s" + "OK"
# D1 + D2 + D3 — tokenize complex expression
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
# Expected: [('NUMBER', 3.5), ('STAR', '*'), ('LPAREN', '('), ('NUMBER', 1), ('MINUS', '-'), ('NUMBER', 2), ('RPAREN', ')'), ('EOF', None)]
# D3 — invalid char raises LexError
python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
# Expected: LexError: Invalid character '@' at position 2
```
## Additional spot-checks
```bash
# D1 — integer
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('42')])"
# Expected: [('NUMBER', 42), ('EOF', None)]
# D1 — leading dot float
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('.5')])"
# Expected: [('NUMBER', 0.5), ('EOF', None)]
# D1 — trailing dot float
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('10.')])"
# Expected: [('NUMBER', 10.0), ('EOF', None)]
# D2 — "1+2*3" kinds
python -c "from calc.lexer import tokenize; print([t.kind for t in tokenize('1+2*3')])"
# Expected: ['NUMBER', 'PLUS', 'NUMBER', 'STAR', 'NUMBER', 'EOF']
# D3 — whitespace test " 12 + 3 "
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize(' 12 + 3 ')])"
# Expected: [('NUMBER', 12), ('PLUS', '+'), ('NUMBER', 3), ('EOF', None)]
```