Skip to content

Instantly share code, notes, and snippets.

Created July 24, 2016 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c4a468029e0a137fbe53c08ee0a9b6b5 to your computer and use it in GitHub Desktop.
Save anonymous/c4a468029e0a137fbe53c08ee0a9b6b5 to your computer and use it in GitHub Desktop.
grammar ML {
rule TOP { <tag> }
token identifier { \w <[\w\d]>* }
token quote { <!after \\> '"' }
token quoted { <.quote>} ~ <.quote> .* }
token tag {
<btag>
~
<etag($<btag><name>)>
$<children> = [[<!after '<'> .*] | <tag>]*
}
token la { <!after '\'> '<' }
token ra { <!after '\'> '>' }
token btag { [<.la> \s* <name=.identifier> \s* [<attribute>*% \s] <.ra>] }
token etag($name) { <.la> '/' \s* $name \s* <.ra> }
token attribute { <identifier> [\s* '=' \s* <quoted>]? }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment