jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1165266 - in /incubator/jena/Jena2/ARQ/trunk: Grammar/ src/com/hp/hpl/jena/sparql/lang/arq/
Date Mon, 05 Sep 2011 12:55:14 GMT
Author: andy
Date: Mon Sep  5 12:55:14 2011
New Revision: 1165266

URL: http://svn.apache.org/viewvc?rev=1165266&view=rev
Log: (empty)

Added:
    incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt   (with props)
    incubator/jena/Jena2/ARQ/trunk/Grammar/Q.arq
    incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj
Modified:
    incubator/jena/Jena2/ARQ/trunk/Grammar/arq.jj
    incubator/jena/Jena2/ARQ/trunk/Grammar/json.jj
    incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj
    incubator/jena/Jena2/ARQ/trunk/Grammar/sparql_11.jj
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParser.java
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParserBase.java

Added: incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt?rev=1165266&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt (added)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt Mon Sep  5 12:55:14 2011
@@ -0,0 +1,10 @@
+Problems: the lexer has moved ahread too far and so:
+
+JSON 
+{ "abc" : "def" }
+WHERE
+{
+  ?s ?p ?o 
+}
+
+attempts to parse WHERE in JSON more (it's a KeyString)

Propchange: incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/jena/Jena2/ARQ/trunk/Grammar/Q.arq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/Q.arq?rev=1165266&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/Q.arq (added)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/Q.arq Mon Sep  5 12:55:14 2011
@@ -0,0 +1,6 @@
+JSON 
+{ "abc" : "def" }
+WHERE
+{
+  ?s ?p ?o 
+}
\ No newline at end of file

Modified: incubator/jena/Jena2/ARQ/trunk/Grammar/arq.jj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/arq.jj?rev=1165266&r1=1165265&r2=1165266&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/arq.jj (original)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/arq.jj Mon Sep  5 12:55:14 2011
@@ -56,7 +56,11 @@ void QueryUnit(): { }
 void Query() : { }
 {
   Prologue()
-  ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() )
+  ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery()
+// #ifdef ARQ
+//   | JsonTemplateQuery()
+// #endif
+  )
   BindingsClause()
 }
 void UpdateUnit() : {}

Added: incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj?rev=1165266&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj (added)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj Mon Sep  5 12:55:14 2011
@@ -0,0 +1,196 @@
+/* Grammar extract - JSON tokens, parser state <JSON> */
+
+// Do \ u inside JavaCC??
+
+
+TOKEN [IGNORE_CASE] : { <JSON: "json" > }
+
+void JsonTemplateQuery() : {}
+{
+    <JSON>
+    { token_source.SwitchTo(JSONX) ; } 
+    json()
+    { token_source.SwitchTo(DEFAULT) ; } 
+}
+
+<JSONX> SKIP : { " " | "\t" | "\n" | "\r" | "\f" }
+
+<JSONX> TOKEN :
+{
+  < J_ECHAR: "\\" ( "t"|"b"|"n"|"r"|"f"|"\\"|"\""|"'") >
+
+| < J_STRING:
+    // Double quoted string
+      "\"" ( (~["\"","\\","\n","\r"]) | <J_ECHAR> )* "\"" >
+| < #J_AZ: ( ["A"-"Z"] | ["a"-"z"] ) >
+
+|  <J_TRUE: "true">
+|  <J_FALSE: "false">
+|  <J_NULL: "null">
+
+
+// WARNING : This accepts all keywords.
+| < J_KEY_STRING:  (<J_AZ> | "_") ( <J_AZ> | "_" | <J_DIGITS> )* >
+
+| < #J_DIGITS: (["0"-"9"])+>
+| < J_INTEGER: <J_DIGITS> >
+| < J_DECIMAL: ( <J_DIGITS> "." (<J_DIGITS>)* | "." <J_DIGITS> ) >
+| < J_DOUBLE:   // Required exponent.
+      (
+        (["0"-"9"])+ "." (["0"-"9"])* <J_EXPONENT>
+        | "." (["0"-"9"])+ (<J_EXPONENT>)
+        | (["0"-"9"])+ <J_EXPONENT>
+      )
+      >
+
+| < J_VAR: "?" <J_KEY_STRING> >
+
+| < J_POSITIVE_INTEGER: <J_PLUS> <J_INTEGER> >
+| < J_POSITIVE_DECIMAL: <J_PLUS> <J_DECIMAL> >
+| < J_POSITIVE_DOUBLE:  <J_PLUS> <J_DOUBLE> >
+
+| < J_NEGATIVE_INTEGER: <J_MINUS> <J_INTEGER> >
+| < J_NEGATIVE_DECIMAL: <J_MINUS> <J_DECIMAL> >
+| < J_NEGATIVE_DOUBLE:  <J_MINUS> <J_DOUBLE> >
+
+| < #J_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+
+| < J_LBRACE:    "{" >
+| < J_RBRACE:    "}" >
+
+| < J_LBRACKET:  "[" >
+| < J_RBRACKET:  "]" >
+
+| < J_LPAREN:    "(" >
+| < J_RPAREN:    ")" >
+
+| < J_COMMA: 	"," >
+| < J_COLON: 	":" >
+
+| < J_PLUS:	"+" >
+| < J_MINUS:	"-" >
+}
+
+void json() : {}
+{
+    { jsonStartParse() ; }
+    JObject()
+    { jsonFinishParse() ; }
+}
+ 
+
+void json_any() : {}
+{
+    { jsonStartParse() ; }
+    (JValue())?
+    { jsonFinishParse() ; }
+}
+
+
+// ---- Structures
+
+void JValue() : {}
+{
+ JSimpleValue()
+| JObject()
+| JArray()
+}
+
+void JObject() : { }
+{
+  <J_LBRACE> 
+  { jsonStartObject() ; }
+  (JMembers())?
+  { jsonFinishObject(); }
+  <J_RBRACE>
+}
+
+void JMembers() : {}
+{
+  JPair() 
+  (<J_COMMA> JPair())* 
+}
+
+void JPair() : {}
+{
+  { jsonStartPair() ; }
+  ( JString() | JKeyString() )
+  { jsonKeyPair() ; }
+  <J_COLON>
+  JValue()
+  { jsonFinishPair() ; }
+}
+
+void JArray() : {}
+{
+   <J_LBRACKET> 
+    { jsonStartArray() ; }
+	(JElements())?
+    { jsonFinishArray() ; }
+   <J_RBRACKET>
+}
+
+void JElements() : { }
+{
+    JArrayValue()
+    (<J_COMMA> JArrayValue())*
+}
+
+void JArrayValue() : { }
+{
+    JValue() { jsonElement() ; }
+}
+
+// ---- 
+
+void JSimpleValue() : {}
+{
+  JString()
+| JNumber()
+| JTrue()
+| JFalse()
+| JNull()
+}
+
+void JNumber() : { Token t ; }
+{
+  t = <J_INTEGER> 		{ jsonValueInteger(t.image) ; }
+| t = <J_DECIMAL>		{ jsonValueDecimal(t.image) ; }
+| t = <J_DOUBLE>		{ jsonValueDouble(t.image) ; }
+| t = <J_POSITIVE_INTEGER>	{ jsonValueInteger(t.image) ; }
+| t = <J_POSITIVE_DECIMAL>	{ jsonValueDecimal(t.image) ; }
+| t = <J_POSITIVE_DOUBLE>	{ jsonValueDouble(t.image) ; }
+| t = <J_NEGATIVE_INTEGER>	{ jsonValueInteger(t.image) ; }
+| t = <J_NEGATIVE_DECIMAL>	{ jsonValueDecimal(t.image) ; }
+| t = <J_NEGATIVE_DOUBLE>	{ jsonValueDouble(t.image) ; }
+}
+
+void JString() : { Token t ; }
+{
+  t = <J_STRING> { jsonValueString(t.image); } 
+}
+
+void JKeyString() : { Token t ; }
+{
+  t = <J_KEY_STRING> { jsonValueKeyString(t.image); } 
+}
+
+void JVar() : { Token t ; }
+{
+   t = <J_VAR> { jsonValueVar(t.image) ; }
+}
+
+void JTrue() : { Token t ; }
+{
+  <J_TRUE> { jsonValueBoolean(true) ; }
+}
+
+void JFalse() : { Token t ; }
+{
+  <J_FALSE> { jsonValueBoolean(false) ; }
+}
+
+void JNull() : { Token t ; }
+{
+  <J_NULL> { jsonValueNull() ; }
+}

Modified: incubator/jena/Jena2/ARQ/trunk/Grammar/json.jj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/json.jj?rev=1165266&r1=1165265&r2=1165266&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/json.jj (original)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/json.jj Mon Sep  5 12:55:14 2011
@@ -1,272 +1,272 @@
-#if 0
-// (Run through cpp -P -C first)
-#endif
-
-#define PACKAGE     org.openjena.atlas.json.io.parserjavacc.javacc
-#define CLASS       JSON_Parser
-#define PARSERBASE  JSON_ParserBase
-
-options
-{
-   JAVA_UNICODE_ESCAPE   = true ;
-   UNICODE_INPUT         = false ;
-
-  STATIC                = false ;
-//  DEBUG_PARSER          = true ;
-//  DEBUG_TOKEN_MANAGER   = true ;
-}
-
-
-PARSER_BEGIN(CLASS)
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package PACKAGE ;
-
-public class CLASS extends PARSERBASE
-{
-}
-PARSER_END(CLASS)
-
-
-SKIP : { <" " | "\t" | "\n" | "\r" | "\f"> }
-TOKEN: { <WS: " " | "\t" | "\n" | "\r" | "\f"> }
-
-// Do \ u inside JavaCC??
-
-//TOKEN [IGNORE_CASE] :
-TOKEN :
-{
-  <ECHAR: "\\" ( "t"|"b"|"n"|"r"|"f"|"\\"|"\""|"'") >
-| < #QUOTE_3D: "\"\"\"">
-| < #QUOTE_3S: "'''">
-| < STRING_LITERAL1: 
-      // Single quoted string
-      "'" ( (~["'","\\","\n","\r"]) | <ECHAR> )* "'" > 
-| < STRING_LITERAL2:
-    // Double quoted string
-      "\"" ( (~["\"","\\","\n","\r"]) | <ECHAR> )* "\"" >
-| < STRING_LITERAL_LONG1:
-     <QUOTE_3S> 
-      ( ("'" | "''")? (~["'","\\"] | <ECHAR> ))*
-     <QUOTE_3S> >
-
-| < STRING_LITERAL_LONG2: 
-     <QUOTE_3D> 
-      ( ("\"" | "\"\"")? (~["\"","\\"] | <ECHAR> ))*
-     <QUOTE_3D> >
-
-
-
-
-| < #DIGITS: (["0"-"9"])+>
-| < INTEGER: <DIGITS> >
-| < DECIMAL: ( <DIGITS> "." (<DIGITS>)* | "." <DIGITS> ) >
-| < DOUBLE:   // Required exponent.
-      (
-        (["0"-"9"])+ "." (["0"-"9"])* <EXPONENT>
-        | "." (["0"-"9"])+ (<EXPONENT>)
-        | (["0"-"9"])+ <EXPONENT>
-      )
-      >
-
-| < POSITIVE_INTEGER: <PLUS> <INTEGER> >
-| < POSITIVE_DECIMAL: <PLUS> <DECIMAL> >
-| < POSITIVE_DOUBLE:  <PLUS> <DOUBLE> >
-
-| < NEGATIVE_INTEGER: <MINUS> <INTEGER> >
-| < NEGATIVE_DECIMAL: <MINUS> <DECIMAL> >
-| < NEGATIVE_DOUBLE:  <MINUS> <DOUBLE> >
-
-| < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
-
-
-|  <TRUE: "true">
-|  <FALSE: "false">
-|  <NULL: "null">
-
-| < LBRACE:    "{" >
-| < RBRACE:    "}" >
-
-| < LBRACKET:  "[" >
-| < RBRACKET:  "]" >
-
-| < LPAREN:    "(" >
-| < RPAREN:    ")" >
-
-| <COMMA: 	"," >
-| <COLON: 	":" >
-
-| <PLUS:	"+" >
-| <MINUS:	"-" >
-}
-
-// ---- Parser entry points
-
-void unit() : {}
-{
-    { startParse() ; }
-    object()
-    { finishParse() ; }
-    <EOF>
-}
- 
-
-void any() : {}
-{
-    { startParse() ; }
-    (Value())?
-    { finishParse() ; }
-    <EOF>
-}
-
-
-// ---- Structures
-
-void Value() : {}
-{
- SimpleValue()
-| object()
-| Array()
-}
-
-void object() : { }
-{
-  <LBRACE> 
-  { startObject() ; }
-  (Members())?
-  { finishObject(); }
-  <RBRACE>
-}
-
-void Members() : {}
-{
-  Pair() 
-  (<COMMA> Pair())* 
-}
-
-void Pair() : {}
-{
-  { startPair() ; }
-  String()
-  { keyPair() ; }
-  <COLON>
-  Value()
-  { finishPair() ; }
-}
-
-void Array() : {}
-{
-   <LBRACKET> 
-    { startArray() ; }
-	(Elements())?
-    { finishArray() ; }
-   <RBRACKET>
-}
-
-void Elements() : { }
-{
-    ArrayValue()
-    (<COMMA> ArrayValue())*
-}
-
-void ArrayValue() : { }
-{
-    Value() { element() ; }
-}
-
-// ---- 
-
-void SimpleValue() : {}
-{
-  String()
-| Number()
-| True()
-| False()
-| Null()
-}
-
-void Number() : { Token t ; }
-{
-  t = <INTEGER> 		    { valueInteger(t.image) ; }
-| t = <DECIMAL>			    { valueDecimal(t.image) ; }
-| t = <DOUBLE>			    { valueDouble(t.image) ; }
-| t = <POSITIVE_INTEGER>	{ valueInteger(t.image) ; }
-| t = <POSITIVE_DECIMAL>	{ valueDecimal(t.image) ; }
-| t = <POSITIVE_DOUBLE>		{ valueDouble(t.image) ; }
-| t = <NEGATIVE_INTEGER>	{ valueInteger(t.image) ; }
-| t = <NEGATIVE_DECIMAL>	{ valueDecimal(t.image) ; }
-| t = <NEGATIVE_DOUBLE>		{ valueDouble(t.image) ; }
-}
-
-// Token to Java Object : These  rules exist to inject the 
-// necessary Java objects and code for the tokens.
-void String() : { Token t ; }
-{
-  t = <STRING_LITERAL2> { valueString(t.image); } 
-	//  <STRING>
-}
-
-void True() : { Token t ; }
-{
-  <TRUE> { valueBoolean(true) ; }
-}
-
-void False() : { Token t ; }
-{
-  <FALSE> { valueBoolean(false) ; }
-}
-
-void Null() : { Token t ; }
-{
-  <NULL> { valueNull() ; }
-}
-
-
-/*
- * (c) Copyright 2008 Hewlett-Packard Development Company, LP
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
-# Local Variables:
-# tab-width: 4
-# indent-tabs-mode: nil
-# comment-default-style: "//"
-# End:
-*/
+#if 0
+// (Run through cpp -P -C first)
+#endif
+
+#define PACKAGE     org.openjena.atlas.json.io.parserjavacc.javacc
+#define CLASS       JSON_Parser
+#define PARSERBASE  JSON_ParserBase
+
+options
+{
+   JAVA_UNICODE_ESCAPE   = true ;
+   UNICODE_INPUT         = false ;
+
+  STATIC                = false ;
+//  DEBUG_PARSER          = true ;
+//  DEBUG_TOKEN_MANAGER   = true ;
+}
+
+
+PARSER_BEGIN(CLASS)
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package PACKAGE ;
+
+public class CLASS extends PARSERBASE
+{
+}
+PARSER_END(CLASS)
+
+
+SKIP : { <" " | "\t" | "\n" | "\r" | "\f"> }
+TOKEN: { <WS: " " | "\t" | "\n" | "\r" | "\f"> }
+
+// Do \ u inside JavaCC??
+
+//TOKEN [IGNORE_CASE] :
+TOKEN :
+{
+  <ECHAR: "\\" ( "t"|"b"|"n"|"r"|"f"|"\\"|"\""|"'") >
+| < #QUOTE_3D: "\"\"\"">
+| < #QUOTE_3S: "'''">
+| < STRING_LITERAL1: 
+      // Single quoted string
+      "'" ( (~["'","\\","\n","\r"]) | <ECHAR> )* "'" > 
+| < STRING_LITERAL2:
+    // Double quoted string
+      "\"" ( (~["\"","\\","\n","\r"]) | <ECHAR> )* "\"" >
+| < STRING_LITERAL_LONG1:
+     <QUOTE_3S> 
+      ( ("'" | "''")? (~["'","\\"] | <ECHAR> ))*
+     <QUOTE_3S> >
+
+| < STRING_LITERAL_LONG2: 
+     <QUOTE_3D> 
+      ( ("\"" | "\"\"")? (~["\"","\\"] | <ECHAR> ))*
+     <QUOTE_3D> >
+
+
+
+
+| < #DIGITS: (["0"-"9"])+>
+| < INTEGER: <DIGITS> >
+| < DECIMAL: ( <DIGITS> "." (<DIGITS>)* | "." <DIGITS> ) >
+| < DOUBLE:   // Required exponent.
+      (
+        (["0"-"9"])+ "." (["0"-"9"])* <EXPONENT>
+        | "." (["0"-"9"])+ (<EXPONENT>)
+        | (["0"-"9"])+ <EXPONENT>
+      )
+      >
+
+| < POSITIVE_INTEGER: <PLUS> <INTEGER> >
+| < POSITIVE_DECIMAL: <PLUS> <DECIMAL> >
+| < POSITIVE_DOUBLE:  <PLUS> <DOUBLE> >
+
+| < NEGATIVE_INTEGER: <MINUS> <INTEGER> >
+| < NEGATIVE_DECIMAL: <MINUS> <DECIMAL> >
+| < NEGATIVE_DOUBLE:  <MINUS> <DOUBLE> >
+
+| < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+
+
+|  <TRUE: "true">
+|  <FALSE: "false">
+|  <NULL: "null">
+
+| < LBRACE:    "{" >
+| < RBRACE:    "}" >
+
+| < LBRACKET:  "[" >
+| < RBRACKET:  "]" >
+
+| < LPAREN:    "(" >
+| < RPAREN:    ")" >
+
+| <COMMA: 	"," >
+| <COLON: 	":" >
+
+| <PLUS:	"+" >
+| <MINUS:	"-" >
+}
+
+// ---- Parser entry points
+
+void unit() : {}
+{
+    { startParse() ; }
+    object()
+    { finishParse() ; }
+    <EOF>
+}
+ 
+
+void any() : {}
+{
+    { startParse() ; }
+    (Value())?
+    { finishParse() ; }
+    <EOF>
+}
+
+
+// ---- Structures
+
+void Value() : {}
+{
+ SimpleValue()
+| object()
+| Array()
+}
+
+void object() : { }
+{
+  <LBRACE> 
+  { startObject() ; }
+  (Members())?
+  { finishObject(); }
+  <RBRACE>
+}
+
+void Members() : {}
+{
+  Pair() 
+  (<COMMA> Pair())* 
+}
+
+void Pair() : {}
+{
+  { startPair() ; }
+  String()
+  { keyPair() ; }
+  <COLON>
+  Value()
+  { finishPair() ; }
+}
+
+void Array() : {}
+{
+   <LBRACKET> 
+    { startArray() ; }
+	(Elements())?
+    { finishArray() ; }
+   <RBRACKET>
+}
+
+void Elements() : { }
+{
+    ArrayValue()
+    (<COMMA> ArrayValue())*
+}
+
+void ArrayValue() : { }
+{
+    Value() { element() ; }
+}
+
+// ---- 
+
+void SimpleValue() : {}
+{
+  String()
+| Number()
+| True()
+| False()
+| Null()
+}
+
+void Number() : { Token t ; }
+{
+  t = <INTEGER> 		    { valueInteger(t.image) ; }
+| t = <DECIMAL>			    { valueDecimal(t.image) ; }
+| t = <DOUBLE>			    { valueDouble(t.image) ; }
+| t = <POSITIVE_INTEGER>	{ valueInteger(t.image) ; }
+| t = <POSITIVE_DECIMAL>	{ valueDecimal(t.image) ; }
+| t = <POSITIVE_DOUBLE>		{ valueDouble(t.image) ; }
+| t = <NEGATIVE_INTEGER>	{ valueInteger(t.image) ; }
+| t = <NEGATIVE_DECIMAL>	{ valueDecimal(t.image) ; }
+| t = <NEGATIVE_DOUBLE>		{ valueDouble(t.image) ; }
+}
+
+// Token to Java Object : These  rules exist to inject the 
+// necessary Java objects and code for the tokens.
+void String() : { Token t ; }
+{
+  t = <STRING_LITERAL2> { valueString(t.image); } 
+	//  <STRING>
+}
+
+void True() : { Token t ; }
+{
+  <TRUE> { valueBoolean(true) ; }
+}
+
+void False() : { Token t ; }
+{
+  <FALSE> { valueBoolean(false) ; }
+}
+
+void Null() : { Token t ; }
+{
+  <NULL> { valueNull() ; }
+}
+
+
+/*
+ * (c) Copyright 2008 Hewlett-Packard Development Company, LP
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+# Local Variables:
+# tab-width: 4
+# indent-tabs-mode: nil
+# comment-default-style: "//"
+# End:
+*/

Modified: incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj?rev=1165266&r1=1165265&r2=1165266&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj (original)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj Mon Sep  5 12:55:14 2011
@@ -96,7 +96,11 @@ void QueryUnit(): { }
 void Query() : { }
 {    
   Prologue()
-  ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() )
+  ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() 
+// #ifdef ARQ
+//   | JsonTemplateQuery()
+// #endif
+  )
   BindingsClause()
 }
 
@@ -197,6 +201,10 @@ void SelectClause() : {  Var v ; Expr ex
   { allowAggregatesInExpressions = false ; }
 }
 
+#ifdef 0
+#include  "json-extra.jj"
+#endif
+
 void ConstructQuery() : { Template t ; 
                           TripleCollectorBGP acc = new TripleCollectorBGP() ; }
 {

Modified: incubator/jena/Jena2/ARQ/trunk/Grammar/sparql_11.jj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/sparql_11.jj?rev=1165266&r1=1165265&r2=1165266&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/sparql_11.jj (original)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/sparql_11.jj Mon Sep  5 12:55:14 2011
@@ -56,7 +56,11 @@ void QueryUnit(): { }
 void Query() : { }
 {
   Prologue()
-  ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery() )
+  ( SelectQuery() | ConstructQuery() | DescribeQuery() | AskQuery()
+// #ifdef ARQ
+//   | JsonTemplateQuery()
+// #endif
+  )
   BindingsClause()
 }
 void UpdateUnit() : {}

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParser.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParser.java?rev=1165266&r1=1165265&r2=1165266&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParser.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParser.java Mon
Sep  5 12:55:14 2011
@@ -5132,26 +5132,6 @@ public class ARQParser extends ARQParser
     finally { jj_save(3, xla); }
   }
 
-  private boolean jj_3R_68() {
-    if (jj_3R_78()) return true;
-    return false;
-  }
-
-  private boolean jj_3R_67() {
-    if (jj_3R_77()) return true;
-    return false;
-  }
-
-  private boolean jj_3R_62() {
-    Token xsp;
-    xsp = jj_scanpos;
-    if (jj_3R_67()) {
-    jj_scanpos = xsp;
-    if (jj_3R_68()) return true;
-    }
-    return false;
-  }
-
   private boolean jj_3_4() {
     if (jj_scan_token(SEMICOLON)) return true;
     if (jj_scan_token(SEPARATOR)) return true;
@@ -5592,6 +5572,26 @@ public class ARQParser extends ARQParser
     return false;
   }
 
+  private boolean jj_3R_68() {
+    if (jj_3R_78()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_67() {
+    if (jj_3R_77()) return true;
+    return false;
+  }
+
+  private boolean jj_3R_62() {
+    Token xsp;
+    xsp = jj_scanpos;
+    if (jj_3R_67()) {
+    jj_scanpos = xsp;
+    if (jj_3R_68()) return true;
+    }
+    return false;
+  }
+
   /** Generated Token Manager. */
   public ARQParserTokenManager token_source;
   JavaCharStream jj_input_stream;

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParserBase.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParserBase.java?rev=1165266&r1=1165265&r2=1165266&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParserBase.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/lang/arq/ARQParserBase.java
Mon Sep  5 12:55:14 2011
@@ -5,12 +5,57 @@
  */
 
 package com.hp.hpl.jena.sparql.lang.arq;
+import org.openjena.atlas.json.io.JSONHandler ;
+import org.openjena.atlas.json.io.JSONHandlerBase ;
+import org.openjena.atlas.lib.NotImplemented ;
+
 import com.hp.hpl.jena.sparql.lang.ParserQueryBase ;
 
 class ARQParserBase
     extends ParserQueryBase
     implements ARQParserConstants
 {
+    // JSON
+    JSONHandler handler = new JSONHandlerBase() ;
+    
+    public void setHandler(JSONHandler handler)
+    { 
+        if ( handler == null )
+            this.handler = new JSONHandlerBase() ;
+        else
+            this.handler = handler ;
+    }
+    
+    // All the signals from the parsing process.
+    protected void jsonStartParse()                 { handler.startParse() ; }
+    protected void jsonFinishParse()                { handler.finishParse() ; }
+    
+    protected void jsonStartObject()                { handler.startObject() ; }
+    protected void jsonFinishObject()               { handler.finishObject() ; }
+
+    protected void jsonStartPair()                  { handler.startPair() ; }
+    protected void jsonKeyPair()                    { handler.keyPair() ; }
+    protected void jsonFinishPair()                 { handler.finishPair() ; }
+    
+    protected void jsonStartArray()                 { handler.startArray() ; }
+    protected void jsonElement()                    { handler.element() ; }
+    protected void jsonFinishArray()                { handler.finishArray() ; }
+
+    protected void jsonValueString(String image)
+    {
+        // Strip quotes
+        image = image.substring(1,image.length()-1) ;
+        handler.valueString(image) ;
+    }
+        
+    protected void jsonValueKeyString(String image) { handler.valueString(image) ; }
+    protected void jsonValueInteger(String image)   { handler.valueInteger(image) ; }
+    protected void jsonValueDecimal(String image)   { handler.valueDecimal(image) ; }
+    protected void jsonValueDouble(String image)    { handler.valueDouble(image) ; }
+    protected void jsonValueBoolean(boolean b)      { handler.valueBoolean(b) ; }
+    protected void jsonValueNull()                  { handler.valueNull() ; }
+    
+    protected void jsonValueVar(String image)       { throw new NotImplemented("yet") ; }
 }
 
 /*



Mime
View raw message