|
Mike Pall wrote:
I also have a site about this, but it's kinda ... ugly :-). I'm not really into websites (and designing them), but I try to give some info about my work.Hi, 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).Oh, nice! But you forgot the URL: http://lua-users.org/wiki/LuaGrammar
it's at http://members.home.nl/joeijoei/parrot.
I 'm not sure if it's that easy to put this in... but I can surely try. I think the modulo operator is easy, and I suspect the "..." will be no problem either, but I have my doubts about the *x syntax, because * is also used for multiplication. I expect a number of conflicts in the grammar... Anyway, bit by bit I'm implementing things, so it's not going very fast.I'm using this grammar in my attempt to write a Lua compiler targeting Parrot, the new virtual machine for Perl6.Since you are restarting the Lua/Parrot project at this time, maybe it would be a good idea to use the Lua 5.1 grammar? It's not that different from Lua 5.0. We gained two new operators ('*x' to get the object size and 'x%y' for modulo) and the ellipsis token ('...') is now a valid multi-result expression representing the variable arguments inside a varargs function.
function calls are not properly implemented currently, because the function calling stuff in Parrot is not quite finished (it's being reworked on now). Also, I think the closure/coroutine stuff isn't quite finished as well, there are still some design decisions about this that have to be made. I'm sure it can be done eventually. Current version of Parrot is 0.2.1 (or 0.2.2? anyway, very low, it will take another year at least or so before it will be near 1.0).BTW: Here are some semantic challenges for your compiler: local x,y,z = 1,... f(1,...) f(1,g()) f{1,...} f{1,g()} local x,y,z = 1,(...) f(1,(...)) f(1,(g())) f{1,(...)} f{1,(g())} local x,y,z = 1,...,3 f(1,...,3) f(1,g(),3) f{1,...,3} f{1,g(),3} local x,y,z = 1,2,3,... local x,y,z = 1,2,3,g() local x,y,z = 1,f(2,{3,...},g({4,h()},...))And here's a tough one to check that you got the semantics for lexical scoping, closures and coroutines right (same in 5.0/5.1): local function f(x) return coroutine.wrap(function(n) repeat x=x+n; n=coroutine.yield(x) until false end), coroutine.wrap(function(n) repeat x=x*n; n=coroutine.yield(x) until false end) end local a,b=f(3) local c,d=f(5) assert(d(b(c(a(d(b(c(a(1)))))))) == 168428160)
But these are good test cases, thanks.
Bye, Mike
kjs