[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: help to (slightly) modify Lua interpreter
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 5 Nov 2009 14:16:59 -0200
> I'm coming again with the same help request, I would like to use
> expressions where userdata are indexed with more comma-separated
> values. For example, if you want to index a matrix it would be natural
> to write something like:
> m[i, j]
> I'm quite determined to change Lua to obtain this syntax extension and
> I would appreciate a lot any suggestions about where to look in the
> source code to understand how it works for the part I'm interested on
> and make the modification right. I already have a good knowledge of
> the paser but I think that I would need to make non-trivial changes in
> the AST and in the way the AST is interpreted.
Lua does not build an AST; it generates code on the fly. For the syntax
part, you have to look at lparser.c, function 'primaryexp', case '['.
But of course you must know what code you want to generate for that
syntax. Do you plan to make m[i, j] the same as m[i][j]?