lua-users home
lua-l archive

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


I am in need to translate valid simple chunks of Lua
code 
mostly if statements and for-loops

into valid PHP and Javascript code snippets

for example 

lua:
if tbA[id4]<tbB[id87]  then 
   tbA[id4].myfunction
end

then java script would be (just pseudocode)

javascript:
if (getDom("tbA.id4").getValue()<getDom("tbB.id87").getValue())
{
    myfunction_js("tbA.id4");
}

I understand that the most straighforward approach
(but not necessarely the simplest and easy to implement)
is to write my own parser (i am using Lpeg for my other things)

However, I would like to know if there is a way for me to
use Lua's load string,
then get access to byte-compiled code  and then translate the
bytecompile
code into whatever I need

Wouldn't this be simpler for me to do (as then Lua takes care of lexing,
parsing, etc)

Are there any examples of this (or even the first approach)?
May be there are other suggestions?


thank you in advance









-- 
  V S P
  toreason@fastmail.fm

-- 
http://www.fastmail.fm - A no graphics, no pop-ups email service