lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Klaas-Jan Stol wrote:


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).

kind regards,

klaas-jan stol

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 recursive parser.

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!

Dave LeBlanc
Seattle, WA USA