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,12 @@
# BACKLOG-eval
## Build backlog
- [x] D1 arithmetic — `evaluate()` correct for +/-/*//, precedence, parens, unary minus
- [x] D2 division — true division; `EvalError` on zero; not bare `ZeroDivisionError`
- [x] D3 result type — whole floats → int; non-whole → float; rule documented in evaluator.py
- [x] D4 CLI — `calc.py` at work root; stdout+exit-0 on success; stderr+exit-1 on error; no traceback
- [x] D5 tests — 24 new tests in `calc/test_evaluator.py`; 68 total pass; prior suite unaffected
## Adversary findings
_(none yet)_

View File

@ -0,0 +1,21 @@
# BACKLOG-lex
## Build backlog
- [x] Create calc/ package with __init__.py
- [x] Implement calc/lexer.py (Token, LexError, tokenize)
- [x] Implement calc/test_lexer.py covering D1-D3
- [x] Claim D1 (committed in a0745d4)
- [x] Claim D2 (committed in a0745d4)
- [x] Claim D3 (committed in a0745d4)
- [x] Claim D4 (committed in a0745d4)
- [x] Await Adversary REVIEW-lex.md PASS for all gates
## Adversary findings
### AF-1 — Missing test file (2026-06-15T00:58Z) — RESOLVED
Initially observed calc/test_lexer.py missing from Builder's untracked files.
Builder subsequently committed and pushed the file. **Status: CLOSED** (resolved in commit f67144b)
### AF-2 — Gates not yet committed to origin (2026-06-15T00:58Z) — RESOLVED
Builder pushed all gates in commit a0745d4. **Status: CLOSED**

View File

@ -0,0 +1,9 @@
# BACKLOG-parse
## Build backlog
_This section is owned by the Builder. Adversary does not edit here._
## Adversary findings
_No findings yet._

View File

@ -0,0 +1,11 @@
# DECISIONS (append-only, shared)
## D-001: Token representation
Token is a dataclass with `kind: str` and `value` (int | float | None).
NUMBER tokens carry their parsed numeric value; operator/paren tokens carry None.
EOF carries None value.
Rationale: parser phases can pattern-match on kind and directly use value without re-parsing.
## D-002: Integer vs float distinction
If a number string contains '.' it is parsed as float, otherwise int.
Edge cases: '.5' → float(0.5), '10.' → float(10.0), '42' → int(42).

View File

@ -0,0 +1,47 @@
# JOURNAL-eval — Builder
## Build log
### Approach
AST walker in `calc/evaluator.py`:
- `Num` → return `_coerce(node.value)`
- `Unary('-', ...)``_coerce(-evaluate(operand))`
- `BinOp` → evaluate both sides; for `/`, check `right == 0` before dividing; apply `_coerce` to result
`_coerce(value)`: if `isinstance(value, float) and value == int(value)``int(value)`, else pass-through.
This keeps the API return clean (no `2.0` leaking out) and is applied consistently at every node evaluation site.
### Test run (local)
```
python -m unittest -v 2>&1
...
Ran 68 tests in 0.270s
OK
```
All 68 tests pass:
- 18 lexer tests (unchanged)
- 26 parser tests (unchanged)
- 24 evaluator + CLI tests (new)
### CLI spot-check
```
python calc.py "2+3*4" → 14
python calc.py "(2+3)*4" → 20
python calc.py "7/2" → 3.5
python calc.py "4/2" → 2
python calc.py "1/0" → error: division by zero (stderr, exit 1)
python calc.py "1 +" → error: unexpected end of input (stderr, exit 1)
```
### D3 rule rationale
Python `/` always returns `float`. Applying `_coerce` at every evaluate site means:
- `4/2``2.0``int(2)` = `2`
- `7/2``3.5` (not whole → stays float)
- `2+3``5` (int arithmetic → already int, _coerce is a no-op)
This is documented in `calc/evaluator.py` module docstring.

View File

@ -0,0 +1,34 @@
# JOURNAL-lex
## Session 1
Starting implementation of calc/lexer.py per lex.md plan.
Design choices:
- Token is a dataclass with `kind: str` and `value` (str | int | float | None)
- NUMBER tokens carry numeric value (int for integers, float for floats)
- All other tokens carry None value
- LexError subclasses Exception, message includes offending char and position
## Implementation results
Ran tests:
```
$ python -m unittest -q
....................
Ran 18 tests in 0.000s
OK
```
Verification commands from plan:
```
$ python -c "from calc.lexer import tokenize; print([(t.kind,t.value) for t in tokenize('3.5*(1-2)')])"
[('NUMBER', 3.5), ('STAR', None), ('LPAREN', None), ('NUMBER', 1), ('MINUS', None), ('NUMBER', 2), ('RPAREN', None), ('EOF', None)]
$ python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
Traceback (most recent call last):
...
calc.lexer.LexError: invalid character '@' at position 2
```
All DoD items satisfied. Claiming all gates D1-D4 together.

View File

@ -0,0 +1,73 @@
# JOURNAL-parse
## 2026-06-15 — Initial implementation
### Design choices
Grammar used:
```
expr = term (('+' | '-') term)*
term = unary (('*' | '/') unary)*
unary = '-' unary | primary
primary = NUMBER | '(' expr ')'
```
This naturally encodes precedence (* and / via term, + and - via expr) and left-associativity (via the while loop that builds left-deep trees in _expr and _term). Unary minus is right-recursive via _unary → _unary, which handles chaining (--5) correctly.
### Operator representation
The Adversary's pre-claim probes in REVIEW-parse.md used symbol format ('+', '-', '*', '/') rather than token kind names ('PLUS', 'MINUS', etc.). I aligned the implementation to use symbols to match their expected cold-verification output.
### Test run output
```
$ python -m unittest -q
Ran 44 tests in 0.001s
OK
```
### D1 shape verification
```
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('1+2*3')))"
BinOp('+', Num(1), BinOp('*', Num(2), Num(3)))
```
### D2 shape verification
```
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('8-3-2')))"
BinOp('-', BinOp('-', Num(8), Num(3)), Num(2))
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('8/4/2')))"
BinOp('/', BinOp('/', Num(8), Num(4)), Num(2))
```
### D3 shape verification
```
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('(1+2)*3')))"
BinOp('*', BinOp('+', Num(1), Num(2)), Num(3))
```
### D4 shape verification
```
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('-5')))"
Unary('-', Num(5))
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('-(1+2)')))"
Unary('-', BinOp('+', Num(1), Num(2)))
$ python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('3 * -2')))"
BinOp('*', Num(3), Unary('-', Num(2)))
```
### D5 error verification
All five required error cases raise ParseError specifically:
- "1 +" → ParseError: unexpected end of input
- "(1" → ParseError: unclosed parenthesis, expected ')'
- "1 2" → ParseError: unexpected token 'NUMBER'
- ")(" → ParseError: unexpected token 'RPAREN'
- "" → ParseError: empty expression

View File

@ -0,0 +1,65 @@
# REVIEW-eval — Adversary Verdicts
Phase: eval
Plan SSOT: /home/loops/project-orchestrator/projects/agent-orchestrator-benchmark/plans/calc/eval.md
## Gates
- D1 — arithmetic: PASS @2026-06-15T01:12:53Z
- D2 — division / EvalError: PASS @2026-06-15T01:12:53Z
- D3 — result type (no trailing .0): PASS @2026-06-15T01:12:53Z
- D4 — CLI: PASS @2026-06-15T01:12:53Z
- D5 — tests green + end-to-end: PASS @2026-06-15T01:12:53Z
## Verdicts
### D1 — arithmetic: PASS @2026-06-15T01:12:53Z
Cold-verified from work-adv clone (commit after pull: 070dc92).
Evidence (all outputs match expected):
- `python calc.py "2+3*4"``14` exit 0 ✓
- `python calc.py "(2+3)*4"``20` exit 0 ✓
- `python calc.py "8-3-2"``3` exit 0 ✓
- `python calc.py "-2+5"``3` exit 0 ✓
- `python calc.py "2*-3"``-6` exit 0 ✓
- `python calc.py "--5"``5` exit 0 ✓ (double unary)
- `python calc.py "3-3"``0` exit 0 ✓
### D2 — division / EvalError: PASS @2026-06-15T01:12:53Z
Evidence:
- `python calc.py "7/2"``3.5` exit 0 ✓ (true division)
- `1/0` raises `EvalError("division by zero")`, NOT bare `ZeroDivisionError`
- `5/(3-3)` also raises `EvalError`
### D3 — result type: PASS @2026-06-15T01:12:53Z
Evidence (types confirmed via Python `isinstance` check):
- `4/2``int(2)` (not `float(2.0)`) ✓
- `7/2``float(3.5)`
- `2+3*4``int(14)`
- `0.0/1``int(0)` (whole-float coercion works for zero) ✓
- `1.5+1.5``3` exit 0 (coerces 3.0 → int) ✓
- Rule documented in evaluator.py docstring ✓
### D4 — CLI: PASS @2026-06-15T01:12:53Z
Evidence:
- `python calc.py "2+3*4"` → stdout `14`, exit 0 ✓
- `python calc.py "1 +"` → stderr error, exit 1, no "Traceback" ✓
- `python calc.py "1/0"` → stderr error, exit 1, no "Traceback" ✓
- `python calc.py` (no args) → stderr usage msg, exit 1 ✓
- Error output confirmed routed to stderr (stdout suppressed, still exits 1) ✓
### D5 — tests green + end-to-end: PASS @2026-06-15T01:12:53Z
Evidence:
- `python -m unittest -q``Ran 68 tests in ...s` / `OK`
- Breakdown: 18 lex + 26 parse + 24 eval = 68 total ✓
- Prior 44 tests (lex + parse) still pass — no regression ✓
- `python -m unittest calc.test_lexer calc.test_parser -q` → 44 tests OK ✓
## Adversary findings
None. No defects found. No VETO.

View File

@ -0,0 +1,53 @@
# REVIEW-lex — Adversary Verdicts
## Gate Verdicts (cold-verified from work-adv clone, commit a0745d4)
### lex/D1: PASS @2026-06-15T01:00Z
Cold run from work-adv clone:
- `tokenize("42")``[NUMBER(42), EOF]`, value is `int(42)`
- `tokenize("3.14")``[NUMBER(3.14), EOF]`, value is `float`
- `tokenize(".5")``[NUMBER(0.5), EOF]`, value is `float`
- `tokenize("10.")``[NUMBER(10.0), EOF]`, value is `float`
### lex/D2: PASS @2026-06-15T01:00Z
Cold run:
- `tokenize("1+2*3")``['NUMBER', 'PLUS', 'NUMBER', 'STAR', 'NUMBER', 'EOF']`
- All six operators/parens (`+`,`-`,`*`,`/`,`(`,`)`) produce correct kinds ✓
### lex/D3: PASS @2026-06-15T01:00Z
Cold run:
- `tokenize(" 12 + 3 ")``['NUMBER', 'PLUS', 'NUMBER', 'EOF']`
- `tokenize("1 @ 2")` → raises `LexError: invalid character '@' at position 2`
- Message contains offending char (`@`) and position (`2`) ✓
- Letters raise LexError ✓
### lex/D4: PASS @2026-06-15T01:00Z
```
$ python -m unittest -q
..................
Ran 18 tests in 0.000s
OK
```
18 tests, 0 failures, exit 0 ✓
Covers D1D3 including `" 12 + 3 "`, `"3.5*(1-2)"`, and `"1 @ 2"` raises LexError ✓
## Minor out-of-spec finding (does NOT affect DoD)
**Solo dot (`.`) raises `ValueError` instead of `LexError`.**
`tokenize(".")` crashes with `ValueError: could not convert string to float: '.'`
The plan specifies `.5` (dot + digit) as valid; bare `.` is undefined in the spec.
Not a DoD failure — filing as informational for future phases.
## Pre-claim probes (noted before Builder pushed)
Initially found test file missing from local untracked files; Builder then committed and pushed
the complete implementation. Both issues AF-1 and AF-2 from BACKLOG are now closed.
## Summary
All four gates D1D4 verified PASS from cold start in work-adv clone at commit a0745d4.

View File

@ -0,0 +1,73 @@
# REVIEW-parse — Adversary Verdicts
## Gate Verdicts (cold-verified from work-adv clone, commit 79016f1)
### parse/D1: PASS @2026-06-15T01:15Z
Cold run — precedence verified structurally:
- `parse(tokenize('1+2*3'))``BinOp('+', Num(1), BinOp('*', Num(2), Num(3)))` ✓ (`*` deeper than `+`)
- `parse(tokenize('2*3+1'))``BinOp('+', BinOp('*', Num(2), Num(3)), Num(1))`
- `parse(tokenize('10-4/2'))``BinOp('-', Num(10), BinOp('/', Num(4), Num(2)))`
- Extra: `1+2*3+4``BinOp('+', BinOp('+', Num(1), BinOp('*', Num(2), Num(3))), Num(4))`
### parse/D2: PASS @2026-06-15T01:15Z
Cold run — left associativity verified structurally:
- `parse(tokenize('8-3-2'))``BinOp('-', BinOp('-', Num(8), Num(3)), Num(2))` ✓ (first `-` is left child)
- `parse(tokenize('8/4/2'))``BinOp('/', BinOp('/', Num(8), Num(4)), Num(2))`
- Extra: `1+2+3``BinOp('+', BinOp('+', Num(1), Num(2)), Num(3))`
### parse/D3: PASS @2026-06-15T01:15Z
Cold run — parens override precedence:
- `parse(tokenize('(1+2)*3'))``BinOp('*', BinOp('+', Num(1), Num(2)), Num(3))` ✓ (`+` deeper than `*`)
- Extra nested: `((((1))))``Num(1)`
- Extra mixed: `2*(3+4*5)``BinOp('*', Num(2), BinOp('+', Num(3), BinOp('*', Num(4), Num(5))))`
### parse/D4: PASS @2026-06-15T01:15Z
Cold run — unary minus:
- `parse(tokenize('-5'))``Unary('-', Num(5))`
- `parse(tokenize('-(1+2)'))``Unary('-', BinOp('+', Num(1), Num(2)))`
- `parse(tokenize('3 * -2'))``BinOp('*', Num(3), Unary('-', Num(2)))`
- Extra: `--5``Unary('-', Unary('-', Num(5)))` ✓ (right-recursive unary)
- Extra: `-1+-2``BinOp('+', Unary('-', Num(1)), Unary('-', Num(2)))`
- Extra: `-3*2``BinOp('*', Unary('-', Num(3)), Num(2))` ✓ (unary higher-prec than `*`)
- Extra: `3--2``BinOp('-', Num(3), Unary('-', Num(2)))`
### parse/D5: PASS @2026-06-15T01:15Z
Cold run — all 5 plan-mandated cases raise `ParseError` (not any other exception type):
- `"1 +"``ParseError: unexpected end of input`
- `"(1"``ParseError: unclosed parenthesis, expected ')'`
- `"1 2"``ParseError: unexpected token 'NUMBER'`
- `")("``ParseError: unexpected token 'RPAREN'`
- `""``ParseError: empty expression`
Extra adversarial cases also raise `ParseError` correctly:
- `"*2"`, `"/2"`, `"()"`, `"1+"`, `"1/"` — all `ParseError`
### parse/D6: PASS @2026-06-15T01:15Z
```
$ python -m unittest -q
............................................
Ran 44 tests in 0.001s
OK
```
44 tests (18 lexer + 26 parser), 0 failures, exit 0 ✓
Tests assert structural equality using dataclass `__eq__` — not weak string comparison. Covers all D1-D5 cases including boundary and combinatorial inputs.
## Adversary Findings
No findings. Implementation is clean.
- `ParseError` is a proper subclass of `Exception` (not `SyntaxError` or other built-in) ✓
- AST nodes use operator symbols (`'+'`, `'-'`, etc.) not token kind names ✓
- Stable documented shape: `Num(value)`, `BinOp(op, left, right)`, `Unary(op, operand)`
## Summary
All six gates D1D6 verified PASS from cold start in work-adv clone at commit 79016f1.

View File

@ -0,0 +1,64 @@
# STATUS-eval — Builder
## DONE
All five eval gates D1D5 Adversary-verified PASS @2026-06-15T01:12:53Z (commit 070dc92). No findings, no VETO. This is the last phase — sequence complete.
---
## Gate: D1D5 CLAIMED (closed — all PASS)
Commit: see `git log --oneline -1` after push
### What is claimed
All five eval phase gates (D1D5):
- **D1** arithmetic — correct results for `+`, `-`, `*`, `/`, precedence, parens, unary minus
- **D2** division — true division; `EvalError` (not `ZeroDivisionError`) on divide-by-zero
- **D3** result type — whole-valued floats returned as `int`; non-whole as `float`
- **D4** CLI — `calc.py` prints result to stdout/exit-0 on success; error to stderr/exit-1 on failure; no traceback
- **D5** tests green — 68 tests pass (18 lex + 26 parse + 24 eval), 0 failures; CLI checks included
### How to verify (exact commands, run from work-adv clone root)
```bash
python -m unittest -q
```
Expected: `Ran 68 tests in ...s` / `OK` / exit 0
```bash
python calc.py "2+3*4"
```
Expected stdout: `14` / exit 0
```bash
python calc.py "(2+3)*4"
```
Expected stdout: `20` / exit 0
```bash
python calc.py "7/2"
```
Expected stdout: `3.5` / exit 0
```bash
python calc.py "4/2"
```
Expected stdout: `2` / exit 0
```bash
python calc.py "1/0"
```
Expected: error message on stderr / exit non-zero / no traceback
```bash
python calc.py "1 +"
```
Expected: error message on stderr / exit non-zero / no traceback
### Where
- `calc/evaluator.py``EvalError`, `evaluate(node) -> int | float`
- `calc/test_evaluator.py` — 24 new unittest tests covering D1D4
- `calc.py` — top-level CLI (work root)

View File

@ -0,0 +1,48 @@
# STATUS-lex
## DONE
All gates D1D4 verified PASS by Adversary at 2026-06-15T01:00Z (commit a0745d4).
## Gates
- D1 — numbers: PASS (Adversary verified)
- D2 — operators & parens: PASS (Adversary verified)
- D3 — whitespace & errors: PASS (Adversary verified)
- D4 — tests green: PASS (Adversary verified)
## Commit
SHA: f67144b
Files: calc/lexer.py, calc/test_lexer.py, calc/__init__.py
## Verification commands (re-run from a fresh clone)
```bash
# D4 — all tests pass
python -m unittest -q
# Expected: 18 tests, 0 failures, exit 0
# D2 — operator/paren sequence
python -c "from calc.lexer import tokenize; print([t.kind for t in tokenize('1+2*3')])"
# Expected: ['NUMBER', 'PLUS', 'NUMBER', 'STAR', 'NUMBER', 'EOF']
# D1 + D2 + D3 combined
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', None), ('LPAREN', None), ('NUMBER', 1), ('MINUS', None), ('NUMBER', 2), ('RPAREN', None), ('EOF', None)]
# D3 — LexError on invalid char
python -c "from calc.lexer import tokenize; tokenize('1 @ 2')"
# Expected: raises calc.lexer.LexError: invalid character '@' at position 2
```
## What is claimed (DoD items)
- **D1**: Integers and floats → NUMBER token with numeric value (int or float).
- `tokenize("42")``[NUMBER(42), EOF]` (int)
- `tokenize("3.14")``[NUMBER(3.14), EOF]` (float)
- `tokenize(".5")``[NUMBER(0.5), EOF]` (float)
- `tokenize("10.")``[NUMBER(10.0), EOF]` (float)
- **D2**: `+ - * / ( )` tokenize to `PLUS MINUS STAR SLASH LPAREN RPAREN`; `tokenize("1+2*3")``NUMBER PLUS NUMBER STAR NUMBER EOF`.
- **D3**: Spaces/tabs skipped; invalid chars raise `LexError` with offending char and position in message.
- `tokenize(" 12 + 3 ")``NUMBER PLUS NUMBER EOF`
- `tokenize("1 @ 2")` raises `LexError: invalid character '@' at position 2`
- **D4**: `python -m unittest -q` → 18 tests, 0 failures.

View File

@ -0,0 +1,113 @@
# STATUS-parse
## DONE
All gates D1D6 verified PASS by Adversary at 2026-06-15T01:15Z (commit 79016f1).
## Gates
- D1 — precedence: PASS (Adversary verified)
- D2 — left associativity: PASS (Adversary verified)
- D3 — parentheses: PASS (Adversary verified)
- D4 — unary minus: PASS (Adversary verified)
- D5 — errors: PASS (Adversary verified)
- D6 — tests green: PASS (Adversary verified)
## Commit
SHA: 88df238
Files: calc/parser.py, calc/test_parser.py
## What is claimed (DoD items)
### AST node shapes
All nodes use operator symbols (not token kind names):
- `Num(value)` — numeric literal, value is int or float
- `BinOp(op, left, right)` — binary op; op ∈ {'+', '-', '*', '/'}
- `Unary(op, operand)` — unary op; op == '-'
### D1 — precedence
`*` and `/` bind tighter than `+` and `-`.
```bash
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('1+2*3')))"
# Expected: BinOp('+', Num(1), BinOp('*', Num(2), Num(3)))
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('2*3+1')))"
# Expected: BinOp('+', BinOp('*', Num(2), Num(3)), Num(1))
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('10-4/2')))"
# Expected: BinOp('-', Num(10), BinOp('/', Num(4), Num(2)))
```
### D2 — left associativity
Same-precedence operators associate left (left child is the deeper node).
```bash
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('8-3-2')))"
# Expected: BinOp('-', BinOp('-', Num(8), Num(3)), Num(2))
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('8/4/2')))"
# Expected: BinOp('/', BinOp('/', Num(8), Num(4)), Num(2))
```
### D3 — parentheses
Parens override default precedence.
```bash
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('(1+2)*3')))"
# Expected: BinOp('*', BinOp('+', Num(1), Num(2)), Num(3))
# Note: '+' node is DEEPER (left child) of '*' — opposite of D1's case
```
### D4 — unary minus
```bash
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('-5')))"
# Expected: Unary('-', Num(5))
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('-(1+2)')))"
# Expected: Unary('-', BinOp('+', Num(1), Num(2)))
python -c "from calc.lexer import tokenize; from calc.parser import parse; print(parse(tokenize('3 * -2')))"
# Expected: BinOp('*', Num(3), Unary('-', Num(2)))
```
### D5 — errors (all must raise ParseError, not any other exception)
```bash
python -c "from calc.lexer import tokenize; from calc.parser import parse, ParseError
try: parse(tokenize('1 +'))
except ParseError: print('PASS')
except Exception as e: print('FAIL:', type(e).__name__, e)"
# Expected: PASS
python -c "from calc.lexer import tokenize; from calc.parser import parse, ParseError
try: parse(tokenize('(1'))
except ParseError: print('PASS')
except Exception as e: print('FAIL:', type(e).__name__, e)"
# Expected: PASS
python -c "from calc.lexer import tokenize; from calc.parser import parse, ParseError
try: parse(tokenize('1 2'))
except ParseError: print('PASS')
except Exception as e: print('FAIL:', type(e).__name__, e)"
# Expected: PASS
python -c "from calc.lexer import tokenize; from calc.parser import parse, ParseError
try: parse(tokenize(')('))
except ParseError: print('PASS')
except Exception as e: print('FAIL:', type(e).__name__, e)"
# Expected: PASS
python -c "from calc.lexer import tokenize; from calc.parser import parse, ParseError
try: parse(tokenize(''))
except ParseError: print('PASS')
except Exception as e: print('FAIL:', type(e).__name__, e)"
# Expected: PASS
```
### D6 — tests green
```bash
python -m unittest -q
# Expected: Ran 44 tests in ...s\n\nOK (18 lexer + 26 parser)
```