Skip to content

Instantly share code, notes, and snippets.

@karthik20522
Created May 25, 2019 06:44
Show Gist options
  • Save karthik20522/ce20c37d2f19edb8de2588732684bc47 to your computer and use it in GitHub Desktop.
Save karthik20522/ce20c37d2f19edb8de2588732684bc47 to your computer and use it in GitHub Desktop.
select * from users
import scala.util.parsing.combinator._
import scala.util.parsing.combinator.syntactical._
case class Select(val fields: String*)
case class From(val table: String)
def selectAll: Parser[Select] = "select" ~ "*" ^^^ (Select("*")) //output: Select("*")
def from: Parser[From] = "from" ~> ident ^^ (From(_)) //output: From("users")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment