Reputation: 2945
I would like to generate a Python parser for a custom language. As I am new to parsing, my only requirement so far is that the generated module shall not depend on the generator.
I learned Tatsu, as it can generate the parser as Python module. But when I review the generated module, it still begins with
from tatsu.buffering import Buffer
from tatsu.parsing import Parser
from tatsu.parsing import tatsumasu, leftrec, nomem
...
Is there a way to generate standalone (depending only on standard Python libraries) parser module using Tatsu? If not, do I have any other option?
Upvotes: 4
Views: 548
Reputation: 3994
Lark, a pure Python parsing library, can generate a small standalone parser for any LALR(1) grammar you throw at it:
The resulting parser is much smaller than Lark itself, it loads much faster because the grammar is pre-compiled, and it's just as easy to use.
Links:
Edit: I first wrote "any context-free grammar", but it is just LALR(1). Thanks Erez for the correction.
Upvotes: 1