-
-
Save NightRa/8284147 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class ModelCombinator extends JavaTokenParsers { | |
def mod: Parser[Any] = "model" ~ ident ^^ { | |
case x => println("Hoping for string value of ident " + x.toString()) | |
} | |
def model: Parser[Any] = "model" ~ ident ~ "{" ~ rep(member) ~ "}" | |
def member: Parser[Any] = ident ~ ":" ~ ident ~ "@" ~ ("eager" | "lazy") ~ relation.? ~ ";" | |
def relationMember: Parser[Any] = "N" | "1" | |
def relation: Parser[Any] = "[" ~ relationMember ~ "-" ~ relationMember ~ "]" | |
} | |
object Main extends ModelCombinator { | |
def main(args: Array[String]) { | |
println(parse(mod,"model Foo")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment