lua-users home
lua-l archive

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


> I think I need a way to detect that lpeg tried to match beyond the end of
> the string. If it did (and I did not add lpeg.P(-1) at the end of the main
> rule) then I know that it failed because of too little data.
>
> The problem with most "normal" solutions is that I after a match failure the
> capture is immediately unwound and I do not know anything about it. If I add
> an alternative then it will start from the beginning and a pattern
> concatenation will never be reached when something failes before it.

Hi,
You may find codepeg useful.  I made it specifically for this kind of
application.  The codepeg parser keeps track of what tokens and rules
have been matched so that when a parsing error occurs, you can use the
stack of tokens and rules to generate good error messages:

https://github.com/weshoke/codepeg

wes