lua-users home
lua-l archive

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


I define a function to be used with LPEG that simply returns the first
character. It _cannot_ match the empty string:

function fct(str)
  if #str==0 then return false
  else return 2,str:sub(1,1)
  end
end

I turn it into an LPEG pattern:

lpeg.version() --> 1.0.0
patt=lpeg.P(fct)

"patt" is supposed to do exactly the same as lepg.C(1). It works OK on its own:
  patt:match""  --> nil
  patt:match"abc" --> a

But I can't make it match twice:
  (patt*patt):match"abc" --> a a [expected: a b]

This seems to contradict the manual's statement that: "If the call
returns a number, the match succeeds and the returned number becomes
the new current position."