How to display errors when parsing with metasexp?
I'm parsing with common lisp library meta-sexp.
When I call a rule like this (entity? (create-parser-context str)), I'm not getting any error if the str开发者_如何学运维 is invalid. How to get the errors displayed?
A non-match is not an error unless a rule (entity?
) or the code calling it programs a non-match as failure.
See the readme. There is an example rule integer-debug?
, in the center of the document, that uses a callback to report the character and position of input that failed to parse an integer.
Since rules return NIL on no-parse, to signal a fatal error: (or (entity? (create-parser-context input)) (error "Input is bad!))
could be used to bail out with an error message from an irrecoverable input error.
精彩评论