lua-users home
lua-l archive

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


thank you,
downloading LuaSrcDiet

In the mean time, using luaanalyze example
I got an AST using Metalua's parser/lexer the one
that's part of the luaanalyze (it seems as though
Metalua's lua parser/lexer can be used outside
of metalua itself -- and that's how luaanalyze is working,
so it eliminates any dependency on C compilation, platform /etc,
but yet gives me an already working Lua parser/lexer with line numbering

So I am going through that now ...  I can see
all the operators, and I think, I can even the function call
(tag== 'call' ) !

I will try to walk that tree using recursive calls just
like luaanalyze find_vars and build
'translation' blocks', then for each block type I will do the
translation code ... Will see how this will work out

... just downloaded....

It looks like your LuaSrcDiet already did the organization into
 blocks, but used a different parser/lexer to get there...
may be it will be simpler for me than building them myself from
the AST tree metalua's parser/lexer....

I will have to figure this out...

thanks again,

On Sat, 01 Nov 2008 15:40:58 +0800, "KHMan" <> 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
> > 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
>     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

-- - Accessible with your email software
                          or over the web