-
Notifications
You must be signed in to change notification settings - Fork 157
Fix (|) parsing per ISO TC2 C2: operator-dependent validity #3141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jjtolton
wants to merge
4
commits into
mthom:master
Choose a base branch
from
jjtolton:fix-single-bar-syntax-error
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+215
−4
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes mthom#3140 The parser was incorrectly accepting (|) and converting it to the atom '|', when it should produce a syntax_error according to ISO/IEC 13211-1 Technical Corrigendum 2, Section C2. Changes: - Modified reduce_brackets() in parser.rs to reject HeadTailSeparator inside parentheses, treating (|) as incomplete/forbidden syntax - Updated builtins.pl to use quoted atom '|' instead of (|) in error term - Added comprehensive tests in src/tests/iso_syntax_errors.pl covering: * (|) syntax error * ISO operator creation restrictions for {} and '|' * Valid operator declarations with proper priorities
178ff7e to
93261be
Compare
… artifacts Two fixes: 1. ISO TC2 C2 compliance for (|): - (|) now only valid when | IS an operator - When | is not an operator, (|) produces syntax_error - Pass op_dir to reduce_brackets() to check operator status 2. Issue mthom#3170 - LR artifacts fix: - reduce_curly() now rejects unreduced operators - Added is_op!(td.spec) check to prevent garbage output - {!*!(|)/} now correctly errors instead of producing {/} Tests: 20 new tests in lr_artifacts_3170.pl covering both fixes Refs: - mthom#3170 - https://www.complang.tuwien.ac.at/ulrich/iso-prolog/dtc2#C2
- Fix catch/3 patterns: use (Goal, false) to properly detect when Goal succeeds instead of throwing expected error - Add .stdout files for snapshot testing (expect "All tests passed") - Add lr_artifacts_3170.toml for CLI test integration - Remove op_create_bar_in_list test: list syntax bypasses op validation (separate bug, out of scope for this PR)
UWN
suggested changes
Nov 29, 2025
UWN
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- (|) when | IS an operator → valid, parses as atom '|'
It remains invalid.
93261be to
a8062de
Compare
Per clarification on Issue #4 and conformity test s#360: - (|) must be a syntax error regardless of operator status - Even with op(1105,xfy,'|'), writeq((|)) must error - The only valid way to write bar as atom is '|' (quoted) Changes: - Simplify reduce_brackets() to always reject HeadTailSeparator - Remove op_dir parameter (no longer needed) - Update lr_artifacts_3170 tests to use '|' instead of (|) - Add conformity test s#360: (|) errors even with op defined - Add test verifying '|' (quoted) is valid
590bca0 to
db48e33
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(|)is NEVER valid syntax (conformity test s#360)Even with
op(1105,xfy,'|'),(|)must error. Use'|'(quoted) for the atom.Per ISO 6.4.2:
|is not a name token (unlike!and;), so cannot be parenthesized.Changes
reduce_brackets(): Always rejectHeadTailSeparator'|'instead of(|)Ref: https://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#360