lua-users home
lua-l archive

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


On 12/02/2014 22:42, Duncan Cross wrote:
Looks like a typo here...? "linenum" is just thrown away, when it
looks like it should probably be the second parameter of Cg().

Good catch - but even with:

local incrementline = Cg( (Cb("linenum") / function ( a ) print("NL"); return a + 1 end), "linenum")

The function still doesn't fire:

> texlike:match("foo \n bar")
New
{
  line = 1,
  text = [[foo
 bar]],
}

Here's an even more reduced case:

local newline = P"\r"^-1 * "\n" / function (a) print("newline"); end
local incrementline = Cg ( Cb"linenum" / function ( a ) print("incrementline"); return a + 1 end , "linenum" )
local setup = Cg ( Cc ( 1) , "linenum" )
local test = (setup * newline * incrementline):match("\n")
test:match("\n")

Produces:

newline

Why doesn't incrementline do anything when it matches? (Incidentally, I've just tried the example where I got this pattern from and it doesn't work. :( )