From: Philipp Kempgen Date: 2010-08-20T04:56:57+09:00 Subject: Re: Parsing, BNF, TreeTop, GhostWheel, ... Clifford Heath wrote: > Yes. PEG parsers are greedy (iterate as far as possible and never > backtrack on that), and also take the first alternative that succeeds, > without trying subsequent alternatives. It's actually quite useful > and natural, once you get the hang of it. > > Pure PEGs have no lookahead, as Treetop does. It's often necessary > though, in the light of the above. What I wanted to do is to construct/generate a parser from a bunch of (A)BNF rules (dozends) from an RFC so backtracking is a requirement while lookahead is not. The grammar specification for the parser (/ parser generator) does not need to be exactly like BNF but should not require me to think about where lookahead is needed as this manual conversion can be error-prone. That seems to rule out PEG parsers. Clifford Heath wrote: > Christian Surlykke wrote: >> You may want to look at: http://kanocc.rubyforge.org/ > > Actually, I think Citrus does a better job than Treetop (of which I'm primary maintainer and a serious user). It provides a BNF built on ruby functions and operators, and also a Treetop/PEG-like parser for grammar files as an alternative. A brief look at Kanocc indicates Citrus may be preferable over it also. > > Citrus doesn't memoize by default however, you have to enable that. It also doesn't have support for semantic predicates, an important feature (for me) which I added to Treetop. > Thanks a lot for the pointers Clifford and Christian! Will have a look as soon as time permits. Philipp