Skip to content

Instantly share code, notes, and snippets.

@qharlie
Created January 6, 2014 15:04
Show Gist options
  • Save qharlie/8284056 to your computer and use it in GitHub Desktop.
Save qharlie/8284056 to your computer and use it in GitHub Desktop.
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 relation: Parser[Any] = "[" ~ ("N-1" | "N-N" | "1-N" | "1-1") ~ "]"
}
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