diff options
Diffstat (limited to 'parzival.lisp')
-rw-r--r-- | parzival.lisp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/parzival.lisp b/parzival.lisp index cc88725..71bb6c0 100644 --- a/parzival.lisp +++ b/parzival.lisp @@ -54,7 +54,7 @@ and the thrid value is the stream stream. The stream will be left in whatever state it was in when the parse stopped, either successfully or not." `(progn - (defvar ,name ',name) + (defparameter ,name ',name) (defun ,name (stream) ,docstring (funcall ,parser stream)))) @@ -116,6 +116,15 @@ in then. If the parse fails the combinator else is run instead." `(<<if (,var ,parser ,stream) ,form <fail<)) +(defmacro <<conditionally (condition then else) + "Returns a parser that is sensative to the current state. If +CONDITION is true, then the THEN parser is run, otherwise the ELSE parser is run." + `(lambda (stream) + (if ,condition + (funcall ,then stream) + (funcall ,else stream)))) + + ;;; The <<PLUS COMBINATOR is vital, and gives us amazing powers to choose our ;;; own future! This section defines <<plus and uses it to define some nice utilities. |