lua-users home
lua-l archive

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

Lua's grammar is pretty simple -- at least if you ignore the cases where
line breaks matter. For a demonstration project, I would probably just start
by writing a parser (possibly in Lua) or use one of the existing ones and
add onto it. I probably wouldn't start with the parser that is built into
Lua because that one is presumably optimized for space and code generation


on 11/1/04 10:08 AM, Asger Ottar Alstrup at wrote:

> Roberto Ierusalimschy wrote:
>>> Basically, my reasoning is that the simple type check solution would
>>> cover 90% of the demands at a very low cost. In other words, the
>>> gain/cost ratio is excellent for the simple type checker.
>> The best way to support that claim is with a working prototype. Why
>> don't you try to implement your idea?
> That is true, and a fair request to back up my claims. If I can find the
> time, my plan would be this:
> 1) Extend the parser to support type annotations a few places in the
> grammar: In particular, variable and function declarations.
> 2) Add a simple typing pass when the syntax tree is built, which has two
> phased:
>  a) Bubble types up from leaves in the syntax tree in a post-order
> depth first traversal - i.e. type deduction.
>  b) A second traversal, which checks that the deduced types matches
> any declared types.
> Can you give me a few pointers to where to start? I have never looked at
> the source code for the compiler. Where can I extend the parser, where
> can I extend the syntax tree with a type field, and where can I hook up
> such a new typing pass? Is there an example of a tree traversal somewhere?
> Thanks,
> Asger Ottar Alstrup