● Every error message now shows the surface lexeme — mod, ], ., ) — instead of Mod, RBracket, Dot, RParen. #25

Merged
navicore merged 1 commit from issue-20 into main 2026-06-02 18:09:57 +00:00
Owner

#20

Issue #20 is fixed.

Summary:

  • crates/patch-prolog-core/src/tokenizer.rs: added a Display impl on TokenKind that yields the surface lexeme.
    Symbolic operators and punctuation are backticked (+, mod, ]); atoms/variables/numbers are described as
    atom \foo, variable X, etc.; Eof reads as "end of input".
  • crates/patch-prolog-core/src/parser.rs: changed the three {:?} formats in error messages to {} (using the new
    Display impl). Also lowercased "Expected" → "expected", "Unexpected" → "unexpected" for sentence-style
    consistency, and quoted the literal tokens in parse_clause (. or :-).
  • 5 regression tests in tests/integration.rs (test_parse_err_*) covering: punctuation lexeme, word-operator
    lexeme, atom lexeme, EOF phrasing, and the expected … path showing the surface form.

The binary now reports e.g. Parse error in foo.pl: unexpected ] at line 2 col 11 — actionable for beginners,
no internal variant names leaked. Pairs cleanly with the #18 line-number fix already shipped.

https://git.navicore.tech/navicore/patch-prolog/issues/20 Issue #20 is fixed. Summary: - crates/patch-prolog-core/src/tokenizer.rs: added a Display impl on TokenKind that yields the surface lexeme. Symbolic operators and punctuation are backticked (`+`, `mod`, `]`); atoms/variables/numbers are described as atom \foo`, variable `X`, etc.; Eof` reads as "end of input". - crates/patch-prolog-core/src/parser.rs: changed the three {:?} formats in error messages to {} (using the new Display impl). Also lowercased "Expected" → "expected", "Unexpected" → "unexpected" for sentence-style consistency, and quoted the literal tokens in parse_clause (`.` or `:-`). - 5 regression tests in tests/integration.rs (test_parse_err_*) covering: punctuation lexeme, word-operator lexeme, atom lexeme, EOF phrasing, and the expected … path showing the surface form. The binary now reports e.g. Parse error in foo.pl: unexpected \]` at line 2 col 11` — actionable for beginners, no internal variant names leaked. Pairs cleanly with the #18 line-number fix already shipped.
● Every error message now shows the surface lexeme — mod, ], ., ) — instead of Mod, RBracket, Dot, RParen.
All checks were successful
CI - Linux / CI - Linux x86_64 (pull_request) Successful in 20s
79c931349c
Issue #20 is fixed.

  Summary:
  - crates/patch-prolog-core/src/tokenizer.rs: added a Display impl on TokenKind that yields the surface lexeme.
  Symbolic operators and punctuation are backticked (`+`, `mod`, `]`); atoms/variables/numbers are described as
  atom \foo`, variable `X`, etc.; Eof` reads as "end of input".
  - crates/patch-prolog-core/src/parser.rs: changed the three {:?} formats in error messages to {} (using the new
  Display impl). Also lowercased "Expected" → "expected", "Unexpected" → "unexpected" for sentence-style
  consistency, and quoted the literal tokens in parse_clause (`.` or `:-`).
  - 5 regression tests in tests/integration.rs (test_parse_err_*) covering: punctuation lexeme, word-operator
  lexeme, atom lexeme, EOF phrasing, and the expected … path showing the surface form.

  The binary now reports e.g. Parse error in foo.pl: unexpected \]` at line 2 col 11` — actionable for beginners,
  no internal variant names leaked. Pairs cleanly with the #18 line-number fix already shipped.
navicore deleted branch issue-20 2026-06-02 18:09:57 +00:00
Sign in to join this conversation.
No description provided.