Last active
March 30, 2016 14:01
-
-
Save kmizu/a7a46456dba2ffd27f8c31e613180464 to your computer and use it in GitHub Desktop.
MinXML by back reference extension
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
assert(S("<foo></foo>").drop == ParseSuccess(None, "")) | |
assert(S("<foo></bar>").drop == ParseFailure("", "bar>")) | |
assert(S("<foo><bar></bar></foo>").drop == ParseSuccess(None, "")) | |
assert(S("<foo><bar></foo></bar>").drop == ParseFailure("", "<bar></foo></bar>")) |
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
object MinXML { | |
lazy val I: P[Any] = range('a'to'z','A'to'Z', Seq('_')) ~ range('a'to'z','A'to'Z',Seq('_'),'0'to'9').* | |
lazy val S: P[Any] = "<" ~ I.evalCC {tag => | |
">" ~ S.* ~ "</" ~ tag ~ ">" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment