[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: make lpeg.P(table) recursive?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 8 Apr 2011 11:29:00 -0300
> > The problem is that this conflicts with the rule for the initial symbol.
> > Currently, P[1] = "S" means that "S" is the initial symbol. With this
> > change, it would mean that "S" is the initial pattern (that is, the
> > grammar would recognize the string "S" only).
> >
>
> How come this is working then?
>
> pat = P{
> "e";
> e = "r" + V"t",
> t = {
> "y",
> y = "y"
> }
> }
I do not know. You changed the code, did you not? (But I assume that it
is treating the inicial rule [index 1] differently.)
> We could apply lpeg.P to all entries but the key 1, but that does not
> > sound good.
> >
>
> Is there a known, useful purpose for non-string keys? If not, keys
> could be restricted to strings, leaving P[1] as a convention for the
> initial rule...
Rule 1 is often used for simple-recursive rules. (See the "Balanced
parentheses" example in the documentation.)
-- Roberto