[Dev-luatex] Assignments in Lua

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Fri May 23 13:35:29 CEST 2008


> extending the syntax is not a priority; in principle one can write 
> another input language, map the parsed result onto primitives or lua 
> functions etc etc

That's what I'm doing right now: I have extended the use of "#" inside
the macro body by transforming the macro body to Lua code using lpeg,
compiling this Lua code into a function and calling the function using
a glue macro. Example:

	#{for i = 1, tonumber(p1) do}%
		#(i): #2%

This repeats #2 #1 times and prefixes it with the iteration's number.
It is transformed to (more or less) the following Lua function:

function repeat(p1, p2)
	for i = 1, tonumber(p1) do
		tex.sprint(tostring(i), tostring(p2))

The macro \repeat then is:


Of course, this is slower than a traditional TeX macro.

> Hans


More information about the dev-luatex mailing list