lua-users home
lua-l archive

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


> Please correct me if I am wrong, but my inspection of lpeg.c
> (the documentation is not very specific) persuades me that if
> pattern:match(text) fails then it returns nil.

Right.


> Would it not be more useful if an error object could be returned
> as well?  In writing a grammar one wants to be able to create
> context-bearing error messages sometimes:
>
> grammar = lpeg.P { ...
>   [NonTerminal] = Pattern_if_OK + Fail(grammar.name,Name[NonTerminal]);
>   .... }

Do you think we need explicit support for this? Can't the application do
it by itself? For instance, in your example, "Fail" could build a
pattern that always matches and captures an error object.

-- Roberto