X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/d0be8052ee97b6d685ca9b73a4ccfa22ed04ccf5..6afec9101d5ea87e3df4bda2239ffd05f8154fa6:/src/lexer-impl.lisp diff --git a/src/lexer-impl.lisp b/src/lexer-impl.lisp index 6a9b2ce..ccaca5c 100644 --- a/src/lexer-impl.lisp +++ b/src/lexer-impl.lisp @@ -50,7 +50,16 @@ &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))))) @@ -178,6 +188,14 @@ ;; Some special punctuation sequences are single tokens. ("..." (values :ellipsis nil)) + ("==" (values :eq)) + ("!=" (values :ne)) + ("<=" (values :le)) + (">=" (values :ge)) + ("&&" (values :and)) + ("||" (values :or)) + ("<<" (values :shl)) + (">>" (values :shr)) ;; Any other character is punctuation. (:any (values it nil))