Created
July 25, 2016 06:45
-
-
Save anonymous/4d0c6c1d9f16b4d34307c6dccae3800a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
use Grammar::Tracer; | |
grammar ML { | |
rule TOP { <tag> } | |
token identifier { \w <[\w\d]>* } | |
token quote { <!after \\> '"' } | |
token quoted { <.quote> ~ <.quote> <.-quote>* } | |
token tag { | |
[<btag> ~ <etag($<btag><name>)> | |
<-lt>* | |
] | |
| <sctag> | |
} | |
token sctag { <.lt> \s* <name=.identifier> [\s+ [<attribute>*% \s+]]? '/' <.gt> } | |
token btag { <.lt> \s* <name=.identifier> [\s+ [<attribute>*% \s+]]? <.gt> } | |
token etag($name) { <.lt> '/' \s* $name \s* <.gt> } | |
token lt { <!after \\> '<' } | |
token gt { <!after \\> '>' } | |
token attribute { <identifier> [\s* '=' \s* <quoted>]? } | |
regex child { <-lt>* | <tag> } | |
} | |
sub MAIN(){ | |
ML.parse('<input type="hidden" name="secret"></input>').say; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment