lua-users home
lua-l archive

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


>  Wed, 31 Jul 2002 23:00:11 -0300
>  Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
>
>  >Unfortunately not at the moment.  The parser relies on the fact that
>  >the GC will not be invoked during compilation.
>  
>  The user function that is called by lua_load has this signature:
>  
>  	typedef const char * (*lua_Chunkreader) (void *ud, size_t *size);
>  
>  Note that it does *not* get a lua_State. But GC is not the only problem.
>  The real problem is that Lua code cannot be run during parsing; several
>  data structures are in a unfinished state.

Does lua_load call this once ?  Or is there a loop like that:

char *chunk;
size_t size;
while((chunk=read_chunk(ud,*size))!=NULL)
{
 
 compile_chunk_to_bytecode(...)
}
run_bytecode(...)


If it  is the  loop, it  would be simple  to write  a line  based data
format where just by a charcter in the first column.

Also, xml parsers tend to spit out their chunks in undefined portions,
so  compile_chunk_to_bytecode(...)  should   be  able  to  handle  the
situation where chunks come like this:

  "for i=1,g" , "etn(table) d" , "o print(i,v", ") end"

I dived  into the  code of Lua  4, and  I believe that  it is  not too
complicated to get this to work by modifying lzio.

If there would be no loop,  the user basically would be forced to read
in the whole file  first, and we would need to keep  date once more in
memory.

Juergen