[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [lpeg] How to implement a "fallback/onerror/panic" function in lpeg?
- From: Xavier Wang <weasley.wx@...>
- Date: Tue, 30 Aug 2011 10:29:52 +0800
In MoonScript's inspired, I'm trying to make a tiny compiler with
lpeg, but I found a problem: when the subject is incorrect, or I write
a wrong pattern, the match just return nil, not any other things, It
makes debug program very difficult, So I had to ask, has any idea to
implement a fallback function for the pattern match?
the fallback function may get some information, e.g. failure position,
expected terminal or other information, but I can't output error
message such as "test.moon: 10: `ident' expected after `,'" if I only
have failure position, How could I produce messages like this? maybe a
function mark() to mark some terminal/nonterminal to makes they can be
shown in message?