[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Q] simple translator from Lua to Java Script and PHP
- From: "V S P" <toreason@...>
- Date: Thu, 13 Nov 2008 02:20:47 -0500
Just wanted to report back
I ended up using metalua.
Now I have it working and I am moving on to use it my system.
Once I got to know metalua little bit, it became
'natural' at AST manipulation tasks
(and it already has a complete built in lua parser and lexer,
with error handling, so I did not even have to worry about that part).
Fabien provided a lot of help on the metalua users list.
> On Sat, 01 Nov 2008 15:40:58 +0800, "KHMan" <firstname.lastname@example.org> said:
> > V S P wrote:
> > > [snip]
> > > 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.
> > > [snip]
> > > Again, for my needs, I want to translate If/else and for loop blocks
> > > function calls) and basic < ~= == > operators within the
> > > 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
> > tbA[id4].myfunction
> > end
> > 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.
> > --
> > Cheers,
> > Kein-Hong Man (esq.)
> > Kuala Lumpur, Malaysia
> V S P
> http://www.fastmail.fm - Accessible with your email software
> or over the web
V S P
http://www.fastmail.fm - A fast, anti-spam email service.