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,29 @@
# JOURNAL — lex phase (Builder)
## Session 1
### Implementation
Built `calc/lexer.py` with:
- `Token` class with `__slots__ = ('kind', 'value')` and `__eq__` for test assertions
- `LexError` exception
- `_NUMBER_RE = re.compile(r'\d+\.?\d*|\.\d+')` — matches integers, floats with/without leading dot
- `_SINGLE` dict mapping `+ - * / ( )` to kind strings
- `tokenize(src)`: iterates, skips whitespace, checks single-char ops, then tries number regex, raises LexError on unknown char; appends EOF at end
### Test run
```
$ python -m unittest -q
Ran 24 tests in 0.000s
OK
```
### Verification commands
```
$ 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 (most recent call last):
...
calc.lexer.LexError: unexpected character '@' at position 2
```