You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to parse this simple string: "test internal procedure" using the grammar below.
I get an error saying parser is expecting "var". It doesn't make any sense because this string perfectly fits the MethodDeclaration rule. If I uncomment the below MemberAttribute.Q(), which is placed inside GlobalVarSection rule, it all works. But it's an empty rule, it shouldn't change anything, but it does. Looks like when rules start the same way, Irony does not fall back to check the alternative path.
`
using Irony.Parsing;
using System;
using System.Collections.Generic;
using System.Text;
namespace Parser
{
[Language("AL")]
class ALGrammarTest : Grammar
{
public ALGrammarTest()
{
var Member = new NonTerminal("Member");
var GlobalVarSection = new NonTerminal("GlobalVarSection");
var MethodDeclaration = new NonTerminal("MethodDeclaration");
var MemberAttribute = new NonTerminal("MemberAttribute");
var AccessModifier = ToTerm("internal");
var VarKeyword = ToTerm("var");
var ProcedureKeyword = ToTerm("procedure");
Member.Rule =
GlobalVarSection
| MethodDeclaration;
GlobalVarSection.Rule =
/*MemberAttribute.Q()
+ */
"test"
+ AccessModifier.Q()
+ VarKeyword;
MethodDeclaration.Rule =
MemberAttribute.Q()
+ "test"
+ AccessModifier.Q()
+ ProcedureKeyword;
MemberAttribute.Rule = Empty;
// Root
this.Root = Member;
}
}
`
The text was updated successfully, but these errors were encountered:
As far as I could guess, you are trying to parse before validating the grammar. Did you try loading it in Grammar Explorer? Load it there and see if there are any conflicts
I am trying to parse this simple string: "test internal procedure" using the grammar below.
I get an error saying parser is expecting "var". It doesn't make any sense because this string perfectly fits the MethodDeclaration rule. If I uncomment the below MemberAttribute.Q(), which is placed inside GlobalVarSection rule, it all works. But it's an empty rule, it shouldn't change anything, but it does. Looks like when rules start the same way, Irony does not fall back to check the alternative path.
`
using Irony.Parsing;
using System;
using System.Collections.Generic;
using System.Text;
namespace Parser
{
`
The text was updated successfully, but these errors were encountered: