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"
+boolProp
-boolProp2
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: https://github.com/modo-lv/LiveScriptBrains/blob/0363ea144aecffa75d1da3747bbcb2dd06dfeb40/src/com/simpleplugin/LiveScript.bnf
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.

0

Please sign in to leave a comment.