chiark / gitweb /
src/utilities.lisp: Add new anaphoric `aand'.
[sod] / src / parser / parser-proto.lisp
index 189e503fb40fee0a6d6e726f8d4f9573c31fd30c..7aafe45ef3e2dd26aad24224055b7057abbcfe4c 100644 (file)
@@ -87,6 +87,21 @@ (defun combine-parser-failures (failures)
          failures
          :initial-value nil))
 
+(export 'parse-empty)
+(defun parse-empty (&optional value)
+  "Return a parser which parses nothing, successfully.
+
+   The parser returns VALUE and consumes nothing."
+  (lambda () (values value t nil)))
+
+(export 'parse-fail)
+(defun parse-fail (indicator &optional consumedp)
+  "Return a parser which fails.
+
+   The parser reports the INDICATOR and (falsely) claims to have consumed
+   input if CONSUMEDP is true."
+  (lambda () (values indicator nil consumedp)))
+
 ;;;--------------------------------------------------------------------------
 ;;; Basic protocol.