Abandoned atoms work: hardly any performance benefit.
[sod] / src / lexer-impl.lisp
index 6a9b2ce..de76371 100644 (file)
                    &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)
@@ -58,7 +67,7 @@
     (scanner-step scanner)))
 
 (defun parse-error-recover (scanner parser recover
-                           &key ignore-unconsumed force-progress)
+                           &key ignore-unconsumed force-progress action)
   "This is the implementation of the `error' parser."
   (multiple-value-bind (result win consumedp) (funcall parser)
     (cond ((or win
@@ -84,6 +93,7 @@
           ;; simply to propagate the current failure back to the caller, but
           ;; we handled that case above.
           (syntax-error scanner result)
+          (when action (funcall action))
           (when (and force-progress (not consumedp)) (scanner-step scanner))
           (funcall recover)))))