Skip to content
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

Wrong BNF in add-expression of Samples.MyCGrammar #63

Open
Cheongroach opened this issue Feb 1, 2024 · 1 comment
Open

Wrong BNF in add-expression of Samples.MyCGrammar #63

Cheongroach opened this issue Feb 1, 2024 · 1 comment

Comments

@Cheongroach
Copy link

Here is a BNF defination in MyCGrammar at current version.

       // ...
      addExpression.Rule
          = multiplyExpression + addOperator + addExpression
          | prefixExpression;  // BAD here

      addOperator.Rule
          = ToTerm("+") | "-";

      multiplyExpression.Rule
          = prefixExpression + multiplyOperator + multiplyExpression
          | prefixExpression;

      multiplyOperator.Rule
          = ToTerm("*")
          | "/";

      prefixExpression.Rule
          = prefixOperator + factor
          | factor;
       // ...

The prefixExpression in line 5 for addExpression must not stand here, it should be a multiplyExpression. Otherwise a multiply expression cannot be solved correctly.

(I turn grammar root to expression to show the problem:)

image

@rivantsov
Copy link
Contributor

thanks for pointing it out, but remember - these are just sample grammars, not thouroughly tested

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

No branches or pull requests

2 participants