lua-users home
lua-l archive

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



Yes, thanks for asking.

It is not really a patch, but a set of "token filters" to be used with LHF's earlier patch.

Tokens are the first level parsed version of your Lua code; between source code and Lua bytecode. They are normally only handled internally, but token filter patch allows one to insert his/her custom rules, to change the way Lua syntax is.

The elegancy lies in being able to adapt the language, without changing the C code a bit. Therefore, this allows extensions/mods to be used by anyone, anywhere, on any system. This is all background, presentation of what "token filtering" itself is.

Usage:
	lua -lfilter yourcode.lua

Loading filter.lua prepares Lua to load the real code, using the better/worse/different syntax.

Now, to my packet:

ftools.lua
	- higher level interface for making token filters
- ability to have multiple filters, loaded from separate files (maybe multiple authors)

ftricond.lua
? cond { true_choice, false_choice } The ternary operator, as in C/Perl

fselect.lua
#... -> select('#',...) Shorthand and more readable to managing multiple
     ...[n]      -> (select(n,...))	parameter lists (...)

finc.lua
     exp +=  -> exp = exp +		C-style += operations:   myvar += 1
     exp -=  -> exp = exp -
     exp *=  -> exp = exp *
     exp /=  -> exp = exp /
     exp ..=  -> exp = exp ..

fdotuntil.lua
     tbl.until etc.			Normally, Lua does not allow "until", "function",
					"repeat", "true", "false", "nil" as table indices.

There's no harm in using these mods, any valid Lua code will run with the filters applied as well. The purpose of token filtering, by lhf was to give a testing ground for custom syntax changes, some of which might make it to future Lua proper. Based on my experiences, token filtering is Simply Great for this, and will reduce the need for special this-and-that patches by a magnitude.

-asko



therandthem kirjoitti 7.11.2006 kello 1.09:

I'm new to Lua and do not totally understand the basic
syntax, let alone this patch you describe.  Could you
provide a simpler overview of what you are describing
here?

Thanks,

McKinley

--- askok@dnainternet.net wrote:


Attached is a set of token tuning tools, and some
tune-ups, to give your Lua a flashy, almost
syntax-over-sugary look.
I don't promise furry backseats, no built-in XBox
360, but
almost. :)

Requirements:
      Lua 5.1 with token filter patch applied (not
included)

Ignition:
      make LUA=path-to-your-modded/lua

Tested on:
      OS X 10.4 (but there's nothing system
specific)

Gains:
     ? cond { true_choice, false_choice }   -->
 _G['?'](cond){ true_choice, false_choice }
     #...        -> select('#',...)
     ...[n]      -> (select(n,...))
     exp +=  -> exp = exp +
     exp -=  -> exp = exp -
     exp *=  -> exp = exp *
     exp /=  -> exp = exp /
     exp ..=  -> exp = exp ..
     tbl.until          (and other reserved words:
function, repeat, nil, false, true)
     {|, until=
     obj:until
     =|,|(|{ do  -> =|,|(|{ function()

The important part really is the ftools.lua, which
allows
multiple filters to co-operate, without need to know
of
each other. As to my knowledge, this hasn't been
possible
earlier.

-asko






______________________________________________________________________ ______________
Sponsored Link

$200,000 mortgage for $660/mo - 30/15 yr fixed, reduce debt, home equity -
Click now for info http://yahoo.ratemarketplace.com