Skip to content

Instantly share code, notes, and snippets.

@ageldama
Created October 15, 2019 01:08
Show Gist options
  • Save ageldama/f478c2d10089c286dd6b2149836b1070 to your computer and use it in GitHub Desktop.
Save ageldama/f478c2d10089c286dd6b2149836b1070 to your computer and use it in GitHub Desktop.
(defun tokenize (s &key emit-fn)
(let ((lexer-fn (lexer s)))
(loop :with token :and val
:do (setf (values token val) (funcall lexer-fn))
:while (not (null token))
:if (null emit-fn)
:collect (cons token val)
:else
:do (funcall emit-fn token val))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment