Skip to content

Skipped possibly matching rule #422

Answered by pdubroy
mlajtos asked this question in Help
Discussion options

You must be logged in to vote

At position 0, it tries to match ExpressionBinaryExpressionExpression. This is left recursive, so the inner Expression fails. But, since BinaryExpression only has one alternative, that means that it also fails.

What you probably want to do is to eliminate the alternation in the body of Expression, and instead create a precedence between the different types of expression. This ensures that the left recursive application of BinaryExpression eventually succeeds. For example, here is a snippet from a Smalltalk grammar that I wrote a while back:

    Expression =
      | variable assign Expression  -- assignment
      | KeywordExpression

    KeywordExpression =
      | KeywordExpression …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mlajtos
Comment options

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