lua-users home
lua-l archive

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


KHMan wrote:
Veli-Pekka Tätilä wrote:
> Most of the Lua parsers I've found Leg, luaparse and yueliang are either
> not well documented, go way over my head or are overkill in features for
> this purpose. The self-containedness requirement is mostly due to me
> simply wishing to put the parser and a screen reader script of mine in
> an app specific folder, and being able to use the code straight away in
> the screen reader for my text editor. <more snippage>
Being the guilty party for Yueliang, here is some info. Yueliang
0.3.0 has a working native Lua 5.0.3 parser skeleton based on
Lua's C parser, and it's about 600 lines sans comments.
Sounds good so far. In fact this is one of the modules I looked into and the one that seemed the most promissing. The trouble I had with it was, as far as I could tell, no clear documentation of how to get started, i.e. which file to import and what the public interface is, as well as what kind of structures it generates as output. There were plenty of files, maybe I didn't just look in the right one. Seems to me the individual files are well documented, however. With this in mind are there any other projects using your parser, so one could see how it is used in practice?

So, plus the lexer, a callback parser for Lua should be feasible
at about 1000 lines sans comments.
Ah the length won't be a problem as such.

> [snip]
> There might be yet another way to go about this, too. If there's a Lua
> disassembler, one could actually have a read out of what Lua sees during
> it parsing the code on the fly. rather than reading the actual code.
> However, this would get rid of all comments and I'm not sure, since I am
> not familiar with any internals, how CLEARLY the byte code corresponds
> to the statements in the source file i.e. is it easy to understand and
> how much things get optimized. <snip>
luac already provides a basic disassembly listing.
ChunkSpy on LuaForge provides disassembly in a little bit more detail.
Ah, I'll take a look just in case. Though at this point the parsing route seems more sensible to me.

I have written a document discussing Lua
bytecodes at:
http://luaforge.net/docman/view.php/83/98/ANoFrillsIntroToLua51VMInstructions.pdf
http://luaforge.net/docman/view.php/83/99/ANoFrillsIntroToLua51VMInstructions.odt
Please let me know if you require the above in other formats.
Though far from a favorite format as far as accessibility goes, I think the PDf should do fine after a plain text dump doable with XPDF. Thanks for all these resources and a quick reply, too.

--
With kind regards Veli-Pekka Tätilä