diff options
author | Boutade <thegoofist@protonmail.com> | 2019-05-03 23:47:16 -0500 |
---|---|---|
committer | Boutade <thegoofist@protonmail.com> | 2019-05-03 23:47:16 -0500 |
commit | 730189a11ee4a1d9734cd1ef191ce0534b72049e (patch) | |
tree | 8a5a2a96d11e7b02b523e7a8cde4c4e5b0073ed2 /parzival.lisp | |
parent | 614f605513f80db554efb3c90cb6c072265bb140 (diff) |
added super-practical natural language calculator demo
Diffstat (limited to 'parzival.lisp')
-rw-r--r-- | parzival.lisp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/parzival.lisp b/parzival.lisp index 01e728a..26012d3 100644 --- a/parzival.lisp +++ b/parzival.lisp @@ -120,12 +120,20 @@ in then. If the parse fails the combinator else is run instead." parser2))))) ;; I thin i see... checkpoints to the same point are being removed when they should't be -(defun <<or (parser1 parser2 &rest parsers) +;;(defun <<or (parser1 parser2 &rest parsers) +(defun <<or (&rest parsers) "Tries each parser one after the other, rewinding the input stream after each failure, and resulting in the first successful parse." - (if parsers - (<<plus parser1 (apply #'<<or (cons parser2 parsers))) - (<<plus parser1 parser2))) + (cond ((null parsers) <fail<) + ((null (cdr parsers)) (car parsers)) + (t + (<<plus (car parsers) (apply #'<<or (cdr parsers)))))) + + + + ;; (if parsers + ;; (<<plus parser1 (apply #'<<or (cons parser2 parsers))) + ;; (<<plus parser1 parser2))) (defun <<~ (parser) |