Recursive expression

Aug 20, 2014 at 10:53 AM
Edited Aug 20, 2014 at 10:55 AM

I am writing a grammar for Javascript language and I am facing with following recursive declaration problem for relationalExpression:
relationalExpression = shiftExpression
     | relationalExpression LT shiftExpression
     | relationalExpression GT shiftExpression
Seem that
relationalExpression.Rule = shiftExpression 
         | relationalExpression + LT + shiftExpression
     | relationalExpression + GT + shiftExpression
Cannot work.

Please can you help?
Thank you.
Aug 20, 2014 at 5:10 PM
What's wrong? Left recursion is OK for LALR parsers like Irony. Try it - unless you see grammar conflicts in Grammar Explorer, you're OK
Aug 21, 2014 at 12:46 PM

Thank you. Sorry I am a newbie and the above expression is correct. I had some warnings in the grammar and I supposed they came from the recursive expressions. My fault. Now I have fixed the warnings although other questions cropped up:

1) What does it mean PreferShiftHere() and why it is useful to resolve conflicts
2) How can prevent an IdentifierTerminal from including some special characters. For instance:

RegexIdentifier = identifier / but not one of the following char : ,/,\ */

Thank you again for your help.

Best regards,
Aug 24, 2014 at 6:16 PM
PreferShiftHere - it's a hint to choose SHIFT action in shift/reduce conflict. The most common known case for using - 'danglinge else' conflict, in if-then-else statements. Google/read about it, there's plenty info on the web:
and there's link there to shift-reduce conflict.
Your second question - I don't quite understand what you mean. Look at IdentifierTerminal constructor, it allows you to list explicitly what symbols are allowed (as first chars and inside chars), maybe that will help