[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPeg - new version
- From: Dave Dodge <dododge@...>
- Date: Fri, 23 Mar 2007 16:18:27 -0500
On Fri, Mar 23, 2007 at 01:20:43PM +0100, Mike Pall wrote:
> Philippe Lhoste wrote:
> > So I went ahead and created my own opcodes, reusing most of Roberto's
> > ideas and creating new codes to make some common expressions optimal.
>
> Since a PEG implementation leads naturally to a bytecode
> interpreter,
Aside: if you're willing to accept some limitations it's of course not
necessary. I too recently implemented a PEG library (in plain C,
unrelated to Lua), but I took the easier road of direct recursive
evaluation.
Granted, this means I have to keep evaluation depth in mind when
creating the expressions, but the nice thing was that it let me get
something usable in a day or two. That way I could start working
sooner on some other things I needed, such as a yacc-style parser
generator (that reads a textual description of a grammar and emits
compilable C code to implement that grammar using the PEG library).
If at some point I decide that recursive evaluation is not sufficient
for the project, my PEG API should allow me to transparently replace
the evaluator with an iterative/bytecode design.
-Dave Dodge