X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/blobdiff_plain/97d10f8b1f631cd32ea5ac9118b253cb4142d391..ae7a3c8fb42e457933efbbb9127d5a745096825a:/src/lexer-proto.lisp diff --git a/src/lexer-proto.lisp b/src/lexer-proto.lisp index 122da75..b045be7 100644 --- a/src/lexer-proto.lisp +++ b/src/lexer-proto.lisp @@ -141,6 +141,14 @@ (defparse error (:context (context token-scanner-context) :ignore-unconsumed ,ignore-unconsumed :force-progress ,force-progress)) +(export 'must) +(defparse must (:context (context token-scanner-context) + sub &optional default) + "Try to parse SUB; if it fails, report an error, and return DEFAULT. + + This parser can't actually fail." + `(parse (error () ,sub (t ,default)))) + ;;;-------------------------------------------------------------------------- ;;; Lexical analysis utilities.