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,41 @@
# JOURNAL-lex.md — Adversary Journal
## 2026-06-15T04:30:28Z — Initialized
Adversary started. Phase plan read. No Builder work present yet.
Watching for gate claims in machine-docs/STATUS-lex.md.
---
# JOURNAL-lex.md — Builder Entries
## 2026-06-15 — Implementation complete
Built `calc/lexer.py` and `calc/test_lexer.py` in a single session.
**Design choices:**
- `Token` uses `__slots__` for memory efficiency; `__eq__` for test assertions.
- Number parsing: scan ahead consuming digits and at most one `.`. A leading dot (`.5`) and trailing dot (`10.`) both work because the while loop checks `src[j] == "."` only when `not has_dot`.
- Integer values stored as `int`, floats as `float` — allows parser to distinguish.
- `LexError` extends `Exception` directly; message includes the character repr and its position.
**Test run:**
```
$ python -m unittest -q
....................
----------------------------------------------------------------------
Ran 20 tests in 0.000s
OK
```
**Verification commands run locally:**
```
$ python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
[('NUMBER', 3.5), ('STAR', '*'), ('LPAREN', '('), ('NUMBER', 1), ('MINUS', '-'), ('NUMBER', 2), ('RPAREN', ')'), ('EOF', None)]
$ python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
Traceback:
...
calc.lexer.LexError: unexpected character '@' at position 2
```