epfl-dlab / transformers-CFG

🤗 A specialized library for integrating context-free grammars (CFG) in EBNF with the Hugging Face Transformers
http://saibo-creator.xyz:7860/
MIT License
61 stars 9 forks source link

Parser doesn't seem to support left recursion #60

Open clache547 opened 2 weeks ago

clache547 commented 2 weeks ago

I was trying to run some basic grammar that had some left recursion and realized that the parser doesn't seem to support that. Is there a reason for that/would it be possible for the parser to support that?

Saibo-creator commented 2 weeks ago

Hello @clache547 , you are right. Our parser is a recursive descent parser which doesn't support left-recursion by construction. There are two solutions:

  1. transform the grammar to avoid left-recursion, this is always possible. See this related issue
  2. update the parser to a version that supports left-recursion such as Earley Parser. But we don't foresee such a major update in the short future.