[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Luma errors
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 11 Apr 2011 18:19:40 -0300
> As I said, the syntax for definitions and non-terminals was the same
> prior to LPEG 0.8. I understand why the %name syntax was introduced
> for definitions, but did you make <name> (and, with 0.10, name) be
> just for non-terminals to avoid having a definition shadow a
> production?
A common mistake when writing LPeg patterns is to forget to add quotes
around literals, mostly because other pattern-matching libraries do
not require or even accept quotes. Earlier versions of LPeg had a weird
error message for these errors, see example:
> return re.match('x', '"x"')
2
> return re.match('x', 'x')
./re.lua:83: reference to unknown rule #1
So, IIRC I added both <name> and %name to avoid lonely names in grammars
and those weird error messages.
Later versions got better error messages:
> return re.match('x', 'x')
./re.lua:211: reference to rule 'x' outside a grammar
And, so, the <> became superfluous. So, maybe the % is superfluous too.
(But maybe I do not recall correctly...)
-- Roberto