IronyProject / Irony

Irony — .NET Language Implementation Kit
https://www.nuget.org/packages/Irony
MIT License
510 stars 97 forks source link

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

Open Cheongroach opened 9 months ago

Cheongroach commented 9 months ago

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 commented 9 months ago

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