lua-users home
lua-l archive

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

That seems like a solution. The problem is I need to be able to modify
the tree dynamically as the user modifies the source code. If I worked
at the bytecode level, I would have to recompile the script each time
user types new character which would be very very slow. Also
at the time when the code is corrupted (because user is just typing
e.g. new line of code), it wouldn't compile at all. That is why I need
to get the output already from the parser - at least to be able to
ignore lines of code which are corrupted.


> There is a way to use the Lua parser. I don't know what you are 
> trying to do, what information you want, but if you are talking
> about a tree of functions and variables definitions and usage, 
> you can let the Lua parser compile the Lua code and then undump the
> compiled code using "luac -u". You will need to parse the luac 
> output (which is much more easier to do) and, as far as I've seen,
> this solves the tree problem.
> You may want to give a look at the undump to see how it can make 
> your life easier. But you will need to simulate a Lua virtual
> machine to find out who is who (for example, when you reach a 
> CALL instruction, who is the called value - the function -, who are
> the parameters and who receives the returned values).
> We are doing exactly that around here (Fabrica Digital)
> []'s
> Luiz