lua-users home
lua-l archive

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

V S P wrote:
I installed the [luaanalyze-20080925b.tar.gz]
got it to run on the example file -- no problems.
However, there is no documentations/samples on how to use this
(since this is workin in progress).  And I am having difficulties
figuring out out the
basic APIs to walk through the AST, and assign actions (if I need
any for translation).

Many of the things listed in the LuaGrammar page are likely to be experimental stuff. As such, if you prefer an actively supported project and something that looks like a complete piece of software, then Fabien's metalua is definitely a good choice.

c) Still having difficulties to get metalua to run on windows
(but the metalua's gg/mlp works in the luaanalyse above -- so I am
thinking when Fabian has time for getting the whole metalua support
for windows/vs 2005/lua 5.1.4 -- I will at least get some knowledge
of dealing with AST using luaanlyze)

If this is a stand-alone project, why not get MinGW up and running, since metalua has the correct Makefiles and config for that.

d) the other projects listed there were not actively worked on
(or may be I missed some)

This is a rather small niche area, so you're not likely to see very active development. For example, I fiddle with Yueliang when I feel like it, or when prompted by the requirements of other projects like LuaSrcDiet. It's up to you to decide what type of tool you want to apply to the problem.

Again, for my needs, I want to translate If/else  and for loop blocks
of lua code to javascript (very constrained lua code with 3 or 4 function calls) and basic < ~= == > operators within the 'if elseif else' expressions. Javascript is already typeless
so I am not worrying about 'internal' type of variables, table elements
or any duck-typing issues.

From your OP:

if tbA[id4]<tbB[id87]  then

If your snippets are very predictable, you just need to fiddle with token patterns, which would be pretty simple to do, but not very flexible. But if there are future needs, then parsing may be better.

If you want to do quick-and-dirty parsing, and isn't leery about not going with orthodox methods like AST, then grab LuaSrcDiet. I have done a parser skeleton there and you get all tokens in a nice table, even all the non-tokens. Find the appropriate parts of the grammar (stat, expr_stat, if_stat, cond, block, expr, subexpr, primaryexp, prefixexp, field, yindex, ...) then add code to translate certain constructs, replacing the original tokens. Write out the modified token stream and voila! you're all done.

Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia