Skip to content

Instantly share code, notes, and snippets.

@pgoodman
Created January 1, 2009 18:04
Show Gist options
  • Save pgoodman/42317 to your computer and use it in GitHub Desktop.
Save pgoodman/42317 to your computer and use it in GitHub Desktop.
(defun-parser :html-attr
(no-capture (repeat 0 nil " "))
(and (concat (repeat 0 nil (range #\a #\z))
(and ":" (repeat 0 nil (concat (range #\a #\z)))))
(no-capture #\= #\")
(find-next #\")
(no-capture #\")))
(defun-parser :html-attrs
(repeat 0 nil :html-attr))
(defun-parser :html-tag-name
(concat (maybe "!")
(repeat 0 nil (range #\a #\z))
(and ":" (repeat 0 nil (range #\a #\z))))) ; this is like a conditional
(defun-parser :html-tag
(and (no-capture "<")
(maybe "/")
:html-tag-name
:html-attrs
(no-capture (repeat 0 nil " "))
(maybe "/")
(no-capture ">")))
(defun-parser :html
(repeat 0 nil (and (find-next "<")
:html-tag))
(concat (repeat 0 nil (any-char))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment