[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lexer and syntax highlighter powered by LPeg
- From: "Andy Stark" <AStark@...>
- Date: Tue, 10 Apr 2007 21:43:19 +0100
Lua list <lua@bazar2.conectiva.com.br> writes:
>> It's been commonplace for compilers to be self-hosting for some time
>>(BCPL was the first, I think). The Java compiler is written in Java, C#
written
>> in C# and Perl 6 (if it ever materialises) is designed the same way.
>>The bootstrapping problem must be surmountable somehow.
>Sure, as long as you're willing/able to write the first implementation
>in some other language, or find some way to build up to it from
>simpler implementations.
It would probably be possible to write the Lua 6 (?) parser in Lua 5 and
then modify it to take advantage of Lua 6 features once it's fully
self-hosting. Although self-hosting compilers are not unusual, I suspect
it hasn't been done with a non-JIT interpreter before, except perhaps as a
research project. Lua is fast, but perhaps not fast enough to make this
truly practical.
(Incidentally, BCPL wasn't the first self-hosting language: a dialect of
Algol 58 called NELIAC was first, and PL/1 actually appeared a few years
before BCPL.)
I was thinking that maybe a packrat parser need not memoise every single
state previously encountered but just use a limited size cache of states.
That way, there would be a certain probability of an expensive backtrack
when a rule fails but this probability would reduce if a larger cache was
available. On desktop machines, you might get near linear time compilation
but on Lego Mindstorms (where the source text is presumably short) you
would get much worse performance. This would seem to make Lua more
"scalable" across a wide variety of target machines. I haven't found any
research into this subject, though, which isn't a good sign.
And that is the most important point - PEG technology is interesting but
Lua is surely too valuable to use a parser implementation that isn't
thoroughly proven.
I hope it was at least worth discussing, though!
&.
#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared
by MailMarshal.
The Blackpool Sixth Form College.
#####################################################################################