Extracted the data-half of Pratt-style precedence parsing: the operator table format and lookup. The climbing loop stays per-language because the two canaries use opposite conventions (lua: higher prec = tighter; prolog: lower prec = tighter, with xfx/xfy/yfx assoc tags) — forcing one shared loop adds callback indirection that obscures more than it shares. The brief's literal ask is "Grammar is a dict, not hardcoded cond" and that's what gets shared. Entry shape: (NAME PREC ASSOC). Three accessors: pratt-op-name / pratt-op-prec / pratt-op-assoc. One traversal: pratt-op-lookup. Ported lua/parser.sx — replaced 18-clause cond and the lua-binop-right? hardcoded `or` with a 15-entry lua-op-table, now queried via pratt-op-lookup. Ported prolog/parser.sx — pl-op-find (linear walk reimpl) deleted; pl-op-lookup wraps pratt-op-lookup; pl-token-op simplified to return the entry directly. Verification: - lua/test.sh: 185/185 = baseline. - prolog/conformance.sh: 590/590 = baseline (timestamp-only diff). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.1 KiB
1.1 KiB
Prolog scoreboard
590 / 590 passing (0 failure(s)). Generated 2026-05-07T17:07:57+00:00.
| Suite | Passed | Total | Status |
|---|---|---|---|
| parse | 25 | 25 | ok |
| unify | 47 | 47 | ok |
| clausedb | 14 | 14 | ok |
| solve | 62 | 62 | ok |
| operators | 19 | 19 | ok |
| dynamic | 11 | 11 | ok |
| findall | 11 | 11 | ok |
| term_inspect | 14 | 14 | ok |
| append | 6 | 6 | ok |
| reverse | 6 | 6 | ok |
| member | 7 | 7 | ok |
| nqueens | 6 | 6 | ok |
| family | 10 | 10 | ok |
| atoms | 34 | 34 | ok |
| query_api | 16 | 16 | ok |
| iso_predicates | 29 | 29 | ok |
| meta_predicates | 25 | 25 | ok |
| list_predicates | 33 | 33 | ok |
| meta_call | 15 | 15 | ok |
| set_predicates | 15 | 15 | ok |
| char_predicates | 27 | 27 | ok |
| io_predicates | 24 | 24 | ok |
| assert_rules | 15 | 15 | ok |
| string_agg | 25 | 25 | ok |
| advanced | 21 | 21 | ok |
| compiler | 17 | 17 | ok |
| cross_validate | 17 | 17 | ok |
| integration | 20 | 20 | ok |
| hs_bridge | 19 | 19 | ok |
Run bash lib/prolog/conformance.sh to refresh. Override the binary
with SX_SERVER=path/to/sx_server.exe bash ….