Skip to content

Conversation

@fabiomadge
Copy link
Collaborator

@fabiomadge fabiomadge commented Jun 29, 2025

Summary

This PR removes two misplaced LL(1) resolvers that were flagged by Coco/R as unnecessary and fixes the resulting field location parsing issue.

Problem

Coco/R was generating warnings for two misplaced resolvers:

-- line 3767 col 8 : warning : Misplaced resolver: no LL(1) conflict.
-- line 4512 col 8 : warning : Misplaced resolver: no LL(1) conflict.

These resolvers don't actually resolve any parsing conflicts and add unnecessary complexity.

Solution

Removed Misplaced Resolvers:

  • IF(AcceptReferrersAndBacktick()) in ConstAtomExpression (line 3767)
  • IF(IsIdentifier(la.kind)) in FieldLocationSuffix (line 4512)

Fixed Field Location Parsing:

Removing the resolvers required restructuring field location parsing to handle backtick consumption correctly:

  • Replace resolver with direct backtick matching
  • Create FieldLocationBody production to separate backtick consumption logic
  • Ensure field location expressions (```x, obj`field`) work correctly

Impact

  • Eliminates build warnings: 2 Coco/R warnings
  • Cleaner grammar: Removes unnecessary complexity
  • Identical functionality: All existing behavior preserved
  • Field locations work: --referrers flag functionality maintained

Testing

  • Grammar compiles with fewer warnings
  • All referrers tests pass (field location expressions work correctly)
  • No functional changes to parsing behavior
  • Build succeeds cleanly

Type of Change

  • Chore/maintenance (grammar cleanup, no functional changes)

This is a pure maintenance change that improves code quality and eliminates some build warnings.

Remove two misplaced LL(1) resolvers that were flagged by Coco/R as unnecessary:
- Remove IF(AcceptReferrersAndBacktick()) resolver in ConstAtomExpression
- Remove IF(IsIdentifier(la.kind)) resolver in FieldLocationSuffix

The resolvers don't actually resolve any parsing conflicts and can be safely removed.
However, removing them requires restructuring field location parsing to handle
backtick consumption correctly.

Changes:
- Replace IF(AcceptReferrersAndBacktick()) with direct backtick matching
- Create FieldLocationBody production to handle backtick consumption properly
- Ensure field location expressions work correctly with --referrers flag

Impact:
- Eliminates 2 'Misplaced resolver: no LL(1) conflict' warnings
- Cleaner grammar with no unnecessary complexity
- Identical parsing behavior (all tests pass)
- Reduces build warnings from 2 to 0
"(" NameSegment<out e> ")" (. e = new UnaryOpExpr(x, UnaryOpExpr.Opcode.Assigned, e); .)
| IF(AcceptReferrersAndBacktick()) (. e = new ImplicitThisExpr(la); .)
FieldLocationSuffix<ref e>
| "`" (. if (!AcceptReferrers()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat. I would not have guess that this would work since "backtick name" is always a valid frame expression.
But it works great !

Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a super nice fix thanks a lot !

@keyboardDrummer keyboardDrummer merged commit 84e6ba4 into master Jul 2, 2025
22 checks passed
@keyboardDrummer keyboardDrummer deleted the chore/remove-misplaced-ll1-resolvers branch July 2, 2025 10:15
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.

3 participants