4
I Use This!
Activity Not Available

News

Analyzed about 1 year ago. based on code collected about 1 year ago.
Posted almost 11 years ago by schneiderr
I am currently working on some pseudoMDX expression parser and I got stucked. I got reduce-reduce conflict which I don't know why occurs. Here is my simplified grammar: internal class CG : Grammar { public CG() : base(false) { ... [More] //terminals var integer = new NumberLiteral("integer", NumberOptions.IntOnly); var mdxIdentifier = new StringLiteral("mdxIdentifier"); mdxIdentifier.AddStartEnd("[", "]", StringOptions.None); //nonTerminals var expression = new NonTerminal("expression"); var numOperation = new NonTerminal("numOperation"); var numOperator = new NonTerminal("numOperator"); var expressionItem = new NonTerminal("expressionItem"); var memberFromExpression = new NonTerminal("memberFromExpression"); var memberForItemFunction = new NonTerminal("memberForItemFnc"); var member = new NonTerminal("member"); var itemFunction = new NonTerminal("itemFunction"); expression.Rule = numOperation | expressionItem | "(" + expression + ")"; numOperation.Rule = expression + numOperator + expression; numOperator.Rule = ToTerm("+") | "-" | "/" | "*"; expressionItem.Rule = memberFromExpression //| lots of other rules ; memberFromExpression.Rule = member | "{" + memberFromExpression + "}" | "(" + memberFromExpression + PreferShiftHere() + ")" //lots of other rules ; memberForItemFunction.Rule = member | "{" + memberForItemFunction + "}" //lots of other rules ; member.Rule = mdxIdentifier | itemFunction //lots of other rules ; itemFunction.Rule = memberForItemFunction + "." + "item" + "(" + integer + ")" //| memberFromExpression + "." + "item" + "(" + integer + ")" ; Root = expression; RegisterOperators(); } private void RegisterOperators() { RegisterOperators(40, "+", "-"); RegisterOperators(50, "*", "/"); } } I can't catch the point why there is conflict. Reduce-reduce conflicts on inputs: } Reduce items: membersFromExpression -> member · [EOF + - / * } )] memberForItemFunction -> member · [. }] Transitions: Well, OK they may look the same i.e. "{[Member]}", but thy both exist in different context so I don't think they are ambigious. Using Reduce hint wont help because memberForItemFunction.Rule = member + ReduceHere() | "{" + memberForItemFunction + "}" //lots of other rules ; would not parse expression like "{[Member]}" as memberFromExpression. And using Reduce hint for memberFromExpression would not parse expression "{[Member]}.item(7)" because it would not identify "{[Member]}" as memberForItemFunction. It there any way how to solve this? [Less]
Posted about 11 years ago by lalbatros
Hello, I would like to modify the expression grammar that comes with irony. I would like to specialize it for linear expressions. This means that expressions should be linear expressions with respect to the "variables". However, the expressions ... [More] do not need to be linear with respect to "parameters". The identifiers for parameters and for variables would be known at run time, when parsing. Typically, parameters would be defined by some assignment statement while variables would not appear in an assignment. Is it possible to describe this in a grammar? Thanks [Less]