lua-users home
lua-l archive

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


Sure,
here it is (there are two files and a test file)

http://pastebin.com/f6dbea82b

----  lua file like this

if arr1.field1<arr2.field1  or arr1.field2>arr2[33][15] then
  call_func2("xyz")
elseif a<b then
  call_func3("abc")
  call_func4("abc")
else
  call_func5(123)
end


-----------



will get translated into 
-------------

if( js_iop_or( js_iop_lt( arr1['field1'], arr2['field1'])
, js_iop_lt( arr2[33][15], arr1['field2'])
)
)
{
 call_func2('xyz') ;
}
else if
( js_iop_lt(a,b)
)
{
 call_func3('abc') ; call_func4('abc') ;
}
else

{
 call_func5(123) ;
}/*end of if*/

-------------

I also have many call backs
context sensitive callbacks and 'output language builder' callbacks
(to translate to other languages if I need to)

I just have it serving my needs because it does not do
even assignment operations (because I use function calls for assignments
and does not support parenthesis, of course nothing like function
declarations either....


I can add some things easily , but others are obviously way beyound
my skills.

Also, I have been programming Lua just for two months, so my code
may be 'cheesy' to many hardcore people

Well -- done with disclaimers :-)


Vlad


On Thu, 13 Nov 2008 09:10:32 -0200, "Jo&#227;o Felipe Santos"
<joao.eel@gmail.com> said:
> On Thu, Nov 13, 2008 at 5:20 AM, V S P <toreason@fastmail.fm> wrote:
> > Just wanted to report back
> > that for my simple lua to javascript translator
> > 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.
> >
> > thanks,
> > Vlad
> >
> 
> Great news! Any chance that we'll see the code published soon? I'm
> very interested!
> 
> Best regards
> -- Jo&#227;o
-- 
  V S P
  toreason@fastmail.fm

-- 
http://www.fastmail.fm - Email service worth paying for. Try it for free