I'm working on a parser for LiveScript language, and am having trouble with parsing both object property definition forms — key: value
and (+|-)key
— together. For example:
prop: "val"
+boolProp
-boolProp
prop2: val2
I have the key: value
form working with this:
Expression ::= TestExpression
| ParenExpression
| OpExpression
| ObjDefExpression
| PropDefExpression
| LiteralExpression
| ReferenceExpression
PropDefExpression ::= Expression COLON Expression
ObjDefExpression ::= PropDefExpression (NEWLINE PropDefExpression)*
// ... other expressions
But however I try to add ("+"|"-") IDENTIFIER
to PropDefExpression
or ObjDefExpression
, I get errors about using left recursion. What's the (right) way to do this?