artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs
This commit is contained in:
104
calculators/builder-solo/run-03/machine-docs/STATUS-lex.md
Normal file
104
calculators/builder-solo/run-03/machine-docs/STATUS-lex.md
Normal file
@ -0,0 +1,104 @@
|
||||
# STATUS — phase lex
|
||||
|
||||
## Gates
|
||||
|
||||
### D1 — numbers
|
||||
|
||||
**What:** Integers and floats tokenize to NUMBER with correct numeric value (int or float).
|
||||
|
||||
**Command:**
|
||||
```bash
|
||||
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('42')])"
|
||||
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.14')])"
|
||||
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('.5')])"
|
||||
python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('10.')])"
|
||||
```
|
||||
|
||||
**Expected:** NUMBER with int value for integers; float for `3.14`, `.5`, `10.`
|
||||
|
||||
**Observed:**
|
||||
```
|
||||
[('NUMBER', 42), ('EOF', None)] # int
|
||||
[('NUMBER', 3.14), ('EOF', None)] # float
|
||||
[('NUMBER', 0.5), ('EOF', None)] # leading dot
|
||||
[('NUMBER', 10.0), ('EOF', None)] # trailing dot
|
||||
```
|
||||
|
||||
**Result: PASS**
|
||||
|
||||
---
|
||||
|
||||
### D2 — operators & parens
|
||||
|
||||
**What:** `+ - * / ( )` each tokenize to their correct kind.
|
||||
|
||||
**Command:**
|
||||
```bash
|
||||
python -c "from calc.lexer import tokenize; print([t.kind for t in tokenize('1+2*3')])"
|
||||
```
|
||||
|
||||
**Expected:** `['NUMBER', 'PLUS', 'NUMBER', 'STAR', 'NUMBER', 'EOF']`
|
||||
|
||||
**Observed:** `['NUMBER', 'PLUS', 'NUMBER', 'STAR', 'NUMBER', 'EOF']`
|
||||
|
||||
**Result: PASS**
|
||||
|
||||
---
|
||||
|
||||
### D3 — whitespace & errors
|
||||
|
||||
**What:** Spaces/tabs skipped; invalid chars raise LexError with char and position.
|
||||
|
||||
**Command:**
|
||||
```bash
|
||||
python -c "from calc.lexer import tokenize; print([t.kind for t in tokenize(' 12 + 3 ')])"
|
||||
python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
|
||||
```
|
||||
|
||||
**Expected:** Whitespace version → `['NUMBER', 'PLUS', 'NUMBER', 'EOF']`; `@` raises `LexError` with `@` and position `2` in message.
|
||||
|
||||
**Observed:**
|
||||
- Whitespace: `['NUMBER', 'PLUS', 'NUMBER', 'EOF']`
|
||||
- LexError: `calc.lexer.LexError: unexpected character '@' at position 2`
|
||||
|
||||
**Result: PASS**
|
||||
|
||||
---
|
||||
|
||||
### D4 — tests green
|
||||
|
||||
**What:** `calc/test_lexer.py` passes `python -m unittest`, 0 failures, covering D1–D3.
|
||||
|
||||
**Command:**
|
||||
```bash
|
||||
python -m unittest -q
|
||||
```
|
||||
|
||||
**Expected:** `Ran N tests in ... OK`
|
||||
|
||||
**Observed:**
|
||||
```
|
||||
----------------------------------------------------------------------
|
||||
Ran 18 tests in 0.000s
|
||||
|
||||
OK
|
||||
```
|
||||
|
||||
**Result: PASS**
|
||||
|
||||
---
|
||||
|
||||
### Exact plan verification commands
|
||||
|
||||
```bash
|
||||
python -m unittest -q
|
||||
# → Ran 18 tests in 0.000s OK
|
||||
|
||||
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')"
|
||||
# → calc.lexer.LexError: unexpected character '@' at position 2
|
||||
```
|
||||
|
||||
## DONE
|
||||
Reference in New Issue
Block a user