extend sparql grammar
authorAlexandre Bertails <bertails@w3.org>
Thu, 10 Dec 2009 17:23:37 -0500
changeset 11 eba6b088b20d
parent 10 98ab8070d7e7
child 12 eace1151058d
extend sparql grammar
src/main/scala/SPARQL.scala
--- a/src/main/scala/SPARQL.scala	Thu Dec 10 14:37:35 2009 -0500
+++ b/src/main/scala/SPARQL.scala	Thu Dec 10 17:23:37 2009 -0500
@@ -5,11 +5,8 @@
 
 import MyParsers._
 
-// object SparqlTypeAliases {
-//   type TriplePatterns = List[TriplePattern]
-// }
-
-// import SpqrqlTypeAliases._
+case class SparqlSelect(attrs:SparqlAttributeList, triples:TriplePatterns)
+case class SparqlAttributeList(attributelist:List[Var])
 
 case class TriplePatterns(triplepatterns:List[TriplePattern])
 case class TriplePattern(s:S, p:P, o:O)
@@ -37,6 +34,12 @@
 
 case class Sparql() extends JavaTokenParsers {
 
+  def select:Parser[SparqlSelect] =
+    "SELECT" ~ attributelist ~ "{" ~ triplepatterns ~ "}" ^^ { case "SELECT"~a~"{"~t~"}" => SparqlSelect(a, t) }
+
+  def attributelist:Parser[SparqlAttributeList] =
+    rep(varr) ^^ { SparqlAttributeList(_) }
+
   def triplepatterns:Parser[TriplePatterns] =
     repsep(triplepattern, ".") ^^ { TriplePatterns(_) }