lua-users home
lua-l archive

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


> 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]?

-- Roberto