[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: loadfile and line number
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 11 Oct 2012 10:11:40 -0300
> On 11/10/2012 13:17, Luiz Henrique de Figueiredo wrote:
> >It can't, sorry. The line number is added to the error message deep down
> >in the Lua core:
> > http://www.lua.org/source/5.2/llex.c.html#lexerror
> >
> >You can extract the line number from the error message with
> > string.match(message,":(%d+):")
>
> Unfortunately, this method is not robust enough.
> If some part of the line in question matches the same pattern
> ":(%d+):", it will be captured instead.
You can provide your own name for the chunk (easier in Lua 5.2
but doable in 5.1). Just choose a name that does not contain that
pattern.
-- Roberto