1

I have this pegjs grammar. How can I remove the left recursion from?

atom   = term
    /  "^"
    /  "_"
    /  "\\"
    /  atom "."
    /  atom "." label
    /  atom ".(" labels ")"
term = [a-zA-Z0-9]+
labels = label ("|" label)*
label  = ("+" / "-")* [A-Za-z0-9]+
Yak O'Poe
  • 760
  • 4
  • 14

1 Answers1

1

It should be something like that...

atomStatement =  atom "." /  atom "." label /  atom ".(" labels ")" / atom

atom   = term
/  "^"
/  "_"
/  "\\"

term = [a-zA-Z0-9]+
labels = label ("|" label)*
label  = ("+" / "-")* [A-Za-z0-9]+
Yak O'Poe
  • 760
  • 4
  • 14