You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/09/05 22:33:21 UTC
svn commit: r1165411 - in /incubator/jena/Jena2/ARQ/trunk/Grammar:
AFS_json_notes.txt json-extra-bak.jj json-extra.jj master.jj
Author: andy
Date: Mon Sep 5 20:33:21 2011
New Revision: 1165411
URL: http://svn.apache.org/viewvc?rev=1165411&view=rev
Log: (empty)
Added:
incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra-bak.jj
Modified:
incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt
incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj
incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj
Modified: 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=1165411&r1=1165410&r2=1165411&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt (original)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/AFS_json_notes.txt Mon Sep 5 20:33:21 2011
@@ -8,3 +8,13 @@ WHERE
}
attempts to parse WHERE in JSON more (it's a KeyString)
+==>
+
+Use SPAQL tokens
+
+with a special test for ":" which is a PNAME_NS
+
+JKeyString:
+
+PNAME_NS or special token
+<PNAME_JSON: (<PN_PREFIX>)? (" ")+ ":" >
\ No newline at end of file
Added: incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra-bak.jj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra-bak.jj?rev=1165411&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra-bak.jj (added)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra-bak.jj Mon Sep 5 20:33:21 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-extra.jj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj?rev=1165411&r1=1165410&r2=1165411&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj (original)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/json-extra.jj Mon Sep 5 20:33:21 2011
@@ -3,72 +3,16 @@
// Do \ u inside JavaCC??
-TOKEN [IGNORE_CASE] : { <JSON: "json" > }
+TOKEN [IGNORE_CASE] :
+{
+ <JSON: "json" >
+| <NULL: "null">
+}
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() : {}
@@ -98,42 +42,43 @@ void JValue() : {}
void JObject() : { }
{
- <J_LBRACE>
+ <LBRACE>
{ jsonStartObject() ; }
(JMembers())?
{ jsonFinishObject(); }
- <J_RBRACE>
+ <RBRACE>
}
void JMembers() : {}
{
JPair()
- (<J_COMMA> JPair())*
+ (<COMMA> JPair())*
}
void JPair() : {}
{
{ jsonStartPair() ; }
- ( JString() | JKeyString() )
+ //( JString() | JKeyString() )
+ JString()
{ jsonKeyPair() ; }
- <J_COLON>
+ <COLON>
JValue()
{ jsonFinishPair() ; }
}
void JArray() : {}
{
- <J_LBRACKET>
+ <LBRACKET>
{ jsonStartArray() ; }
(JElements())?
{ jsonFinishArray() ; }
- <J_RBRACKET>
+ <RBRACKET>
}
void JElements() : { }
{
JArrayValue()
- (<J_COMMA> JArrayValue())*
+ (<COMMA> JArrayValue())*
}
void JArrayValue() : { }
@@ -154,43 +99,43 @@ void JSimpleValue() : {}
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) ; }
+ t = <INTEGER> { jsonValueInteger(t.image) ; }
+| t = <DECIMAL> { jsonValueDecimal(t.image) ; }
+| t = <DOUBLE> { jsonValueDouble(t.image) ; }
+| t = <INTEGER_POSITIVE> { jsonValueInteger(t.image) ; }
+| t = <DECIMAL_POSITIVE> { jsonValueDecimal(t.image) ; }
+| t = <DOUBLE_POSITIVE> { jsonValueDouble(t.image) ; }
+| t = <INTEGER_NEGATIVE> { jsonValueInteger(t.image) ; }
+| t = <DECIMAL_NEGATIVE> { jsonValueDecimal(t.image) ; }
+| t = <DOUBLE_NEGATIVE> { jsonValueDouble(t.image) ; }
}
void JString() : { Token t ; }
{
- t = <J_STRING> { jsonValueString(t.image); }
+ t = <STRING_LITERAL2> { jsonValueString(t.image); }
}
void JKeyString() : { Token t ; }
{
- t = <J_KEY_STRING> { jsonValueKeyString(t.image); }
+ t = <PNAME_NS> { jsonValueKeyString(t.image); }
}
void JVar() : { Token t ; }
{
- t = <J_VAR> { jsonValueVar(t.image) ; }
+ (t = <VAR1> | t = <VAR2> ) { jsonValueVar(t.image) ; }
}
void JTrue() : { Token t ; }
{
- <J_TRUE> { jsonValueBoolean(true) ; }
+ <TRUE> { jsonValueBoolean(true) ; }
}
void JFalse() : { Token t ; }
{
- <J_FALSE> { jsonValueBoolean(false) ; }
+ <FALSE> { jsonValueBoolean(false) ; }
}
void JNull() : { Token t ; }
{
- <J_NULL> { jsonValueNull() ; }
+ <NULL> { jsonValueNull() ; }
}
Modified: incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj?rev=1165411&r1=1165410&r2=1165411&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj (original)
+++ incubator/jena/Jena2/ARQ/trunk/Grammar/master.jj Mon Sep 5 20:33:21 2011
@@ -201,7 +201,7 @@ void SelectClause() : { Var v ; Expr ex
{ allowAggregatesInExpressions = false ; }
}
-#ifdef 0
+#if 0
#include "json-extra.jj"
#endif