[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5 Grammar update
- From: whisper@<a href="/cgi-bin/echo.cgi?oz.net">...</a>
- Date: Mon, 25 Jul 2005 18:09:39 -0700
Klaas-Jan Stol wrote:
If you want a fast Lua parser (compared to a Yacc-ish one), consider
PCCTS. It integrates the Bison/Flex syntaxing too. PCCTS can build a
parser that's comperable in performance to a hand coded top down
for sake of completeness, I just updated the Lua wiki with a link to a
Lua 5 grammar for Bison (or Yacc). I'm using this grammar in my
attempt to write a Lua compiler targeting Parrot, the new virtual
machine for Perl6. I'm pretty sure it's complete. Lua has 1 ambiguity,
as described in the reference manual, this same ambiguity is also
present in this grammar file. In this file, it is present as a
shift/reduce conflict, resolved by default by a "shift". Adding a
semicolon will result in a "reduce". (this is pretty much the same
behaviour as in original Lua, I think).
In contrast to Yacc solutions, it does require a LR parser, not an LALR
like Yacc. In LR grammars, the repetitions are on the left, not the
right, ie: expressions, expression, not expression, expressions. (Just
an abstract example because I'm too lazy to go find a real one... ;-) )
PCCTS is free and open source. Builds on standard C.
Very highly recommended!
Seattle, WA USA