Skip to content

Allow '=' in IRIs; keep explicit {1} cardinality (fixes red CI) - #6

Open
ericprud wants to merge 2 commits into
linkml:mainfrom
ericprud:iriref-allow-equals
Open

ericprud wants to merge 2 commits into
linkml:mainfrom
ericprud:iriref-allow-equals

Conversation

@ericprud

Copy link
Copy Markdown
Contributor

CI on main has failed since #4 (tests/test_shexc.py::TestShExCValidation::test_shex_schema). That test round-trips every shexTest schema (ShExJ → ShExC → ShExJ), and two newer shexTest schemas exposed two separate bugs.

1. = in IRIs failed to lex (1dot-baseDotSegmentsTrailing, added to shexTest 2026-08-19)

The grammar's IRIREF rule excluded =, unlike the ShEx spec, so any IRI with a query string failed:

line 3:1 token recognition error at: '<http://a.example/dir1/dir2/s/p1?q='

Fixed upstream in shexSpec/grammar#18. This PR regenerates the lexer with ANTLR 4.9.3, the version that produced the current files and the one the ~=4.9.3 runtime pin requires. With the unfixed grammar, the same command reproduces all seven committed parser files byte for byte. With the fix, only ShExDocLexer.py and ShExDocLexer.interp change, and only in the serialized ATN.

2. Explicit {1} cardinality was dropped (1card1, added to shexTest 2026-09-22)

ShExC.cardinality() emitted nothing for min=1, max=1, the same as for absent min/max, so the round-trip lost them. It now emits nothing only when both are absent, and writes {1} otherwise.

Tests

  • tests/test_iriref.py: an IRI with ?q=v&r=w parses (fails with the old lexer).
  • tests/test_cardinality.py: explicit {1} survives a round-trip, and absent cardinality stays absent (the first fails without the fix).
  • Full suite: 18 passed, 2 skipped, including all 333 shexTest schemas in test_shex_schema.

Independent of #5 (the UTF-8 decoding fix).

🤖 Generated with Claude Code

Eric Prud'hommeaux and others added 2 commits October 11, 2026 02:51
The ANTLR grammar's IRIREF excluded '=', so IRIs with query strings such
as <http://a.example/p1?q=v> failed with "token recognition error" (e.g.
shexTest's 1dot-baseDotSegmentsTrailing). Regenerated with ANTLR 4.9.3
from shexSpec/grammar#18; with the unfixed grammar the same command
reproduces the committed parser byte for byte, and only the lexer's
serialized ATN changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cardinality() treated min=1, max=1 like absent min/max and emitted
nothing, so ShExJ -> ShExC -> ShExJ dropped them (shexTest 1card1,
added 2026-09-22). Emit nothing only when both are absent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant