Skip to content

Disambiguation Strategy ? #2041

Answered by msujew
khkiley asked this question in Q&A
Aug 28, 2024 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Hey @khkiley,

the grammar isn't ambiguous due to the Identifier, but rather due to the StringExpression -> StringExpression and NumericExpression -> NumericExpression parts. It's not even really ambiguous: Instead this issue is called direct left recursion. It's one of the main limitations of LL parsers.

There are quite a few resources that show how to solve this. See here. It generally boils down to rewriting the grammar rules to eliminate the left recursive subrule call.

Regarding the Identifier issue: Most people don't actually write their grammar split by string or numeric expressions. They just have operation expression (i.e. with 2 or more operators), unary expressions and then prim…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@khkiley
Comment options

@khkiley
Comment options

@msujew
Comment options

msujew Aug 28, 2024
Collaborator

Answer selected by khkiley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants