lua-users home
lua-l archive

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


> > 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