LiveScript object definition parsing without recursion?

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, this is a valid LiveScript object definition:
prop: "val"
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?

Full code is on github:
1 comment
Comment actions Permalink

To answer my own question, the problem was with using too generic "Expression". Once I reworked it to use more limited and specific expressions, the problem went away.


Please sign in to leave a comment.