lua-users home
lua-l archive

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


Lua list <lua@bazar2.conectiva.com.br> writes:

>Same reaction as Peter, what for? The current lexer will be probably 
>always faster than an LPeg implementation (as it is hand-written), and 
>is able to handle subtle corner cases of syntax...

Well, I'm not an expert on PEGs (in fact I don't think very many people
are) but I understand they can always be implemented as a packrat parser.
This type of parser works by memoising intermediate parsing states and
consequently always runs in linear time with respect to the source text.
So perhaps it could be quite fast after all. I don't know if LPEG uses, or
can ever be made to use a packrat parsing system but it seems to me that
it might at least be a possibility. In any case, basing the parser on a
single, straightforward formalism has got to be beneficial, hasn't it? I
mean, assuming the performance isn't spectacularly worse. And it's better
still if the compiler can be written in Lua.

Also, we might not need the pattern matching facilities of the string
library if LPEG was available, so the parser and string library might be
able to share some code.

>On the other hand, I suppose it would delight people wanting to 
>customize Lua syntax... :-)

Remember that some people do this for legitimate research purposes ;-)

Also, people don't just customise the syntax of Lua, they may also want to
change the backend to target other virtual machines. This would surely be
easier if the compiler was written in Lua and it would help broaden Lua's
adoption if it were available for more VMs than other languages. And then
there are code analysing tools, etc...

>One can rewrite at least luac this way (direct bytecode generation).

The Lua interpreter wouldn't need an onboard compiler. It would just load
luac (which is a Lua module now, right?) and use it to compile bytecode
which it would then run as usual.

&.




#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal.
The Blackpool Sixth Form College.
#####################################################################################