Skip to content

Conversation

@jjtolton
Copy link

@jjtolton jjtolton commented Oct 26, 2025

(|) 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 reject HeadTailSeparator
  • Tests: Use '|' instead of (|)
  • Add s#360 conformity test

Ref: https://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#360

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
@jjtolton jjtolton force-pushed the fix-single-bar-syntax-error branch from 178ff7e to 93261be Compare November 29, 2025 15:57
@jjtolton jjtolton changed the title Fix parser to reject (|) as syntax error per ISO spec Fix (|) parsing per ISO TC2 C2: operator-dependent validity Nov 29, 2025
@jjtolton jjtolton marked this pull request as draft November 29, 2025 17:10
… 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)
Copy link

@UWN UWN left a 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.

@jjtolton jjtolton force-pushed the fix-single-bar-syntax-error branch from 93261be to a8062de Compare November 29, 2025 17:55
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
@jjtolton jjtolton force-pushed the fix-single-bar-syntax-error branch from 590bca0 to db48e33 Compare November 29, 2025 18:22
@jjtolton jjtolton marked this pull request as ready for review November 29, 2025 18:35
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.

2 participants