[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Translating from a VERY "loose" language
- From: Steve Heller <steveheller@...>
- Date: Mon, 11 Jun 2007 10:37:39 -0700 (PDT)
--- Timon Christl <firstname.lastname@example.org> wrote:
> On 6/11/07, Steve Heller <email@example.com>
> > I'm trying to do machine translation from an
> > "loose" language to Lua. What I mean by "loose" is
> > that this language doesn't even have run-time
> > You can compare strings and numbers and it
> > automatically.
> > I need to find all the occurrences of these type
> > mismatches so my Lua translation will work
> > Order comparisons like '<' and '>=' will throw a
> > runtime error, so I can catch them and fix the
> > However, '==' and '~=' always produce false and
> > respectively for values that don't have the same
> > so I won't know that there is a type mismatch.
> > Does anyone have any suggestions as to how to
> > these errors?
> My first idea would be to try creating a metatable
> with an entry for
> eq and attaching it to a number value. According to
> the manual all
> number values share a single common metatable. The
> same applies to
> strings. I don't know it this really works, but if
> it does it would be
> everything that is needed. Note that the manual says
> the metatable for
> non-table values can only be changed in C code.
> Hope this helps
Thanks. Sorry, I should have mentioned that I knew
about the metatable for numbers. However, I'm using
the lua.exe program to execute my lua code, not
embedding it in another C program, and I don't have
any C functions called by the Lua code. How should I
add the metatable setting code in that circumstance?