chiark / gitweb /
src/lexer-{proto,impl}.lisp: Enhance `skip-until' to match token values.
[sod] / src / lexer-impl.lisp
index 6a9b2cec0d590f7ccbc631043afc2b07b189d509..16861793b9a269cb027a2b91d9ee6aae38ee9940 100644 (file)
@@ -50,7 +50,16 @@ (defun %skip-until (scanner token-types
                    &key (keep-end (not (null (cdr token-types)))))
   "This is the implementation of the `skip-until' parser."
   (do ((consumedp nil t))
-      ((member (token-type scanner) token-types)
+      ((let ((type (token-type scanner))
+            (value (token-value scanner)))
+        (some (lambda (spec)
+                (multiple-value-bind (want-type want-value)
+                    (cond ((listp spec) (values (car spec) (cadr spec)))
+                          (t (values spec t)))
+                  (and (eq want-type type)
+                       (or (eq want-value t)
+                           (equal want-value value)))))
+              token-types))
        (unless keep-end (scanner-step scanner))
        (values nil t (or keep-end consumedp)))
     (when (scanner-at-eof-p scanner)