datalog: parser accepts negative integer literals (248/248)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s

Bug: `n(-1).` failed to parse — the tokenizer produced op `-`
followed by number `1`, and dl-pp-parse-arg expected a term after
seeing `-` as an op (and a `(` for a compound) but found a bare
number. Users had to write `(- 0 1)` or compute via `is`.

Fix: dl-pp-parse-arg detects op `-` directly followed by a number
token (no intervening `(`) and consumes both as a single negative
number literal. Subtraction (`is(Y, -(X, 2))`) and compound
arithmetic via the operator form are unaffected — they use the
`-(` lookahead path.

2 new parser tests: negative integer literal and subtraction
compound preserved.
This commit is contained in:
2026-05-10 20:55:42 +00:00
parent 2c8c1f75b3
commit 2a1d8eeab2
4 changed files with 31 additions and 6 deletions

View File

@@ -1,11 +1,11 @@
{
"lang": "datalog",
"total_passed": 246,
"total_passed": 248,
"total_failed": 0,
"total": 246,
"total": 248,
"suites": [
{"name":"tokenize","passed":26,"failed":0,"total":26},
{"name":"parse","passed":20,"failed":0,"total":20},
{"name":"parse","passed":22,"failed":0,"total":22},
{"name":"unify","passed":28,"failed":0,"total":28},
{"name":"eval","passed":36,"failed":0,"total":36},
{"name":"builtins","passed":23,"failed":0,"total":23},
@@ -16,5 +16,5 @@
{"name":"magic","passed":34,"failed":0,"total":34},
{"name":"demo","passed":21,"failed":0,"total":21}
],
"generated": "2026-05-10T20:51:33+00:00"
"generated": "2026-05-10T20:55:23+00:00"
}