Prabu
Prabu

Reputation: 2298

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?

Upvotes: 0

Views: 81

Answers (1)

frayser
frayser

Reputation: 1782

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.

Upvotes: 1

Related Questions