● Every repro from the issue now works. Issue #19 is fixed. #24

Merged
navicore merged 1 commit from issue-19 into main 2026-06-02 18:05:31 +00:00
Owner

#19

Summary:

  • crates/patch-prolog-core/src/parser.rs: added operator_as_atom_lookahead and called it at the top of
    parse_primary. When the current token is one of the operator kinds (Plus, Minus, Star, Slash, IntDiv,
    Lt/Gt/Lte/Gte, Equals, NotEquals, TermEq/TermNeq, ArithEq/ArithNeq, Is, Mod, Rem, Not (+), Arrow (->),
    Semicolon) AND the next token is a closing context (), ], ,, |, ., EOF), the operator is consumed as an atom.
    Otherwise the parser falls through to existing behavior — preserving prefix - on numerals, prefix + for +
    Goal, and all existing infix paths.
  • 9 regression tests in tests/integration.rs covering: p(+), p(mod), [+, -, *], X = (<), X = (+), X = (-),
    infix 1 + 2 unchanged, prefix -3 unchanged, and the full =.. round-trip from the issue body.
  • Updated the two #18 tests in runner.rs — they used bar(+) as a parse-error trigger, which is now valid syntax.
    Swapped to a stray ] token, which is unambiguously still invalid.

Note: + as a prefix operator on variables/compounds (e.g. +X) is still not supported — out of scope for this
issue. Bare-atom usage of , (p(,)) also still requires quoting (p(',')), which matches SWI's behavior.

https://git.navicore.tech/navicore/patch-prolog/issues/19 Summary: - crates/patch-prolog-core/src/parser.rs: added operator_as_atom_lookahead and called it at the top of parse_primary. When the current token is one of the operator kinds (Plus, Minus, Star, Slash, IntDiv, Lt/Gt/Lte/Gte, Equals, NotEquals, TermEq/TermNeq, ArithEq/ArithNeq, Is, Mod, Rem, Not (\+), Arrow (->), Semicolon) AND the next token is a closing context (), ], ,, |, ., EOF), the operator is consumed as an atom. Otherwise the parser falls through to existing behavior — preserving prefix - on numerals, prefix \+ for \+ Goal, and all existing infix paths. - 9 regression tests in tests/integration.rs covering: p(+), p(mod), [+, -, *], X = (<), X = (\+), X = (-), infix 1 + 2 unchanged, prefix -3 unchanged, and the full =.. round-trip from the issue body. - Updated the two #18 tests in runner.rs — they used bar(+) as a parse-error trigger, which is now valid syntax. Swapped to a stray ] token, which is unambiguously still invalid. Note: + as a prefix operator on variables/compounds (e.g. +X) is still not supported — out of scope for this issue. Bare-atom usage of , (p(,)) also still requires quoting (p(',')), which matches SWI's behavior.
● Every repro from the issue now works. Issue #19 is fixed.
All checks were successful
CI - Linux / CI - Linux x86_64 (pull_request) Successful in 21s
bbf72e7161
Summary:
  - crates/patch-prolog-core/src/parser.rs: added operator_as_atom_lookahead and called it at the top of
  parse_primary. When the current token is one of the operator kinds (Plus, Minus, Star, Slash, IntDiv,
  Lt/Gt/Lte/Gte, Equals, NotEquals, TermEq/TermNeq, ArithEq/ArithNeq, Is, Mod, Rem, Not (\+), Arrow (->),
  Semicolon) AND the next token is a closing context (), ], ,, |, ., EOF), the operator is consumed as an atom.
  Otherwise the parser falls through to existing behavior — preserving prefix - on numerals, prefix \+ for \+
  Goal, and all existing infix paths.
  - 9 regression tests in tests/integration.rs covering: p(+), p(mod), [+, -, *], X = (<), X = (\+), X = (-),
  infix 1 + 2 unchanged, prefix -3 unchanged, and the full =.. round-trip from the issue body.
  - Updated the two #18 tests in runner.rs — they used bar(+) as a parse-error trigger, which is now valid syntax.
  Swapped to a stray ] token, which is unambiguously still invalid.

  Note: + as a prefix operator on variables/compounds (e.g. +X) is still not supported — out of scope for this
  issue. Bare-atom usage of , (p(,)) also still requires quoting (p(',')), which matches SWI's behavior.
navicore deleted branch issue-19 2026-06-02 18:05:31 +00:00
Sign in to join this conversation.
No description provided.