summaryrefslogtreecommitdiff
path: root/parzival.lisp
diff options
context:
space:
mode:
authorBoutade <thegoofist@protonmail.com>2019-04-27 08:12:29 -0500
committerBoutade <thegoofist@protonmail.com>2019-04-27 08:12:29 -0500
commit1bed2e23644ca4514a2dfbca521f5841fa3507b2 (patch)
tree2aec93fee7ed8c454637a30fab02d9ac8a59b3cc /parzival.lisp
parent4db2291159831a93a35af68e8e176f4b51e220d5 (diff)
removed <~item<, changed semantics of <item<, added <peek<
Diffstat (limited to 'parzival.lisp')
-rw-r--r--parzival.lisp18
1 files changed, 9 insertions, 9 deletions
diff --git a/parzival.lisp b/parzival.lisp
index d17be0e..9dd9630 100644
--- a/parzival.lisp
+++ b/parzival.lisp
@@ -34,18 +34,18 @@
(lambda (stream) (values nil nil stream))
"Consumes nothing from input and fails the parse.")
-
-(<<def <item<
- (lambda (stream) (values (read-char stream) t stream))
- "Consumes exactly one item from input and results in that item.")
+(<<def <peek<
+ (lambda (stream) (values (peek-char nil stream nil nil) t stream))
+ "A pseudo-parser that peeks at the next item without consuming it. Useful
+ for building efficient look-ahead of one item.")
-(<<def <~item<
+(<<def <item<
(lambda (stream)
(if (peek-char nil stream nil nil)
- (funcall <item< stream)
+ (funcall (<<result (read-char stream)) stream)
(funcall <fail< stream)))
- "Results in next item from the input without consuming it.")
+ "Results in next item from the input stream, or fails.")
(<<def <eof<
@@ -171,9 +171,9 @@ is the result of PN."
(defun <<~sat (pred)
"(<<~SAT PRED) is like (<<SAT PRED) but doesn't consume the item if (FUNCALL PRED ITEM) is false."
- (<<bind <~item<
+ (<<bind <peek<
(lambda (c) (if (funcall pred c)
- (<<result c)
+ <item<
<fail<))))