Removed JavaCC parser definition and its generated classes.
This commit is contained in:
parent
abe244c099
commit
43f2a0012b
26
gson/pom.xml
26
gson/pom.xml
@ -134,32 +134,6 @@
|
||||
</workspaceCodeStylesURL>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>javacc-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javacc</id>
|
||||
<goals>
|
||||
<goal>javacc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>src/main/javacc</sourceDirectory>
|
||||
<outputDirectory>src/main/java</outputDirectory>
|
||||
<timestampDirectory>target/generated-src/javacc-timestamp</timestampDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.javacc</groupId>
|
||||
<artifactId>javacc</artifactId>
|
||||
<version>4.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
|
@ -1,751 +0,0 @@
|
||||
/* Generated By:JavaCC: Do not edit this line. JsonParserJavacc.java */
|
||||
package com.google.gson;
|
||||
import java.io.EOFException;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
final class JsonParserJavacc implements JsonParserJavaccConstants {
|
||||
|
||||
final public JsonElement parse() throws ParseException {
|
||||
JsonElement json = null;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 0:
|
||||
jj_consume_token(0);
|
||||
{if (true) throw new JsonParseException(new EOFException());}
|
||||
break;
|
||||
case DIGITS:
|
||||
case NULL:
|
||||
case NAN:
|
||||
case INFINITY:
|
||||
case BOOLEAN:
|
||||
case SINGLE_QUOTE_LITERAL:
|
||||
case DOUBLE_QUOTE_LITERAL:
|
||||
case 26:
|
||||
case 27:
|
||||
case 31:
|
||||
case 33:
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 26:
|
||||
jj_consume_token(26);
|
||||
break;
|
||||
default:
|
||||
jj_la1[0] = jj_gen;
|
||||
;
|
||||
}
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 27:
|
||||
json = JsonObject();
|
||||
break;
|
||||
case 31:
|
||||
json = JsonArray();
|
||||
break;
|
||||
case DIGITS:
|
||||
case NAN:
|
||||
case INFINITY:
|
||||
case BOOLEAN:
|
||||
case SINGLE_QUOTE_LITERAL:
|
||||
case DOUBLE_QUOTE_LITERAL:
|
||||
case 33:
|
||||
json = JsonPrimitive();
|
||||
break;
|
||||
case NULL:
|
||||
json = JsonNull();
|
||||
break;
|
||||
default:
|
||||
jj_la1[1] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
{if (true) return json;}
|
||||
break;
|
||||
default:
|
||||
jj_la1[2] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonObject JsonObject() throws ParseException {
|
||||
JsonObject o = new JsonObject();
|
||||
jj_consume_token(27);
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case IDENTIFIER_SANS_EXPONENT:
|
||||
case IDENTIFIER_STARTS_WITH_EXPONENT:
|
||||
case SINGLE_QUOTE_LITERAL:
|
||||
case DOUBLE_QUOTE_LITERAL:
|
||||
Pair(o);
|
||||
label_1:
|
||||
while (true) {
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 28:
|
||||
;
|
||||
break;
|
||||
default:
|
||||
jj_la1[3] = jj_gen;
|
||||
break label_1;
|
||||
}
|
||||
jj_consume_token(28);
|
||||
Pair(o);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
jj_la1[4] = jj_gen;
|
||||
;
|
||||
}
|
||||
jj_consume_token(29);
|
||||
{if (true) return o;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonNull JsonNull() throws ParseException {
|
||||
Token t;
|
||||
t = jj_consume_token(NULL);
|
||||
{if (true) return JsonNull.createJsonNull();}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private void Pair(JsonObject o) throws ParseException {
|
||||
JsonPrimitive property;
|
||||
JsonElement value;
|
||||
property = JsonMemberName();
|
||||
jj_consume_token(30);
|
||||
value = JsonValue();
|
||||
o.add(property.getAsString(), value);
|
||||
}
|
||||
|
||||
final private JsonPrimitive JsonMemberName() throws ParseException {
|
||||
Token t; JsonPrimitive value;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case IDENTIFIER_SANS_EXPONENT:
|
||||
case IDENTIFIER_STARTS_WITH_EXPONENT:
|
||||
t = Identifier();
|
||||
{if (true) return new JsonPrimitive(t.image);}
|
||||
break;
|
||||
case SINGLE_QUOTE_LITERAL:
|
||||
case DOUBLE_QUOTE_LITERAL:
|
||||
value = JsonString();
|
||||
{if (true) return value;}
|
||||
break;
|
||||
default:
|
||||
jj_la1[5] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonArray JsonArray() throws ParseException {
|
||||
JsonArray array = new JsonArray();
|
||||
jj_consume_token(31);
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 32:
|
||||
array = JsonArrayEmpty(array);
|
||||
{if (true) return array;}
|
||||
break;
|
||||
case DIGITS:
|
||||
case NULL:
|
||||
case NAN:
|
||||
case INFINITY:
|
||||
case BOOLEAN:
|
||||
case SINGLE_QUOTE_LITERAL:
|
||||
case DOUBLE_QUOTE_LITERAL:
|
||||
case 27:
|
||||
case 31:
|
||||
case 33:
|
||||
JsonArrayElement(array);
|
||||
label_2:
|
||||
while (true) {
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 28:
|
||||
;
|
||||
break;
|
||||
default:
|
||||
jj_la1[6] = jj_gen;
|
||||
break label_2;
|
||||
}
|
||||
JsonArrayNextElement(array);
|
||||
}
|
||||
jj_consume_token(32);
|
||||
{if (true) return array;}
|
||||
break;
|
||||
default:
|
||||
jj_la1[7] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonArray JsonArrayEmpty(JsonArray array) throws ParseException {
|
||||
jj_consume_token(32);
|
||||
{if (true) return array;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonArray JsonArrayElement(JsonArray array) throws ParseException {
|
||||
JsonElement element = null;
|
||||
element = JsonValue();
|
||||
array.add(element);
|
||||
{if (true) return array;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonArray JsonArrayNextElement(JsonArray array) throws ParseException {
|
||||
JsonElement element = null;
|
||||
jj_consume_token(28);
|
||||
element = JsonValue();
|
||||
array.add(element);
|
||||
{if (true) return array;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonElement JsonValue() throws ParseException {
|
||||
JsonElement o = null;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case SINGLE_QUOTE_LITERAL:
|
||||
case DOUBLE_QUOTE_LITERAL:
|
||||
o = JsonString();
|
||||
break;
|
||||
case DIGITS:
|
||||
case NAN:
|
||||
case INFINITY:
|
||||
case 33:
|
||||
o = JsonNumber();
|
||||
break;
|
||||
case 27:
|
||||
o = JsonObject();
|
||||
break;
|
||||
case 31:
|
||||
o = JsonArray();
|
||||
break;
|
||||
case BOOLEAN:
|
||||
o = JsonBoolean();
|
||||
break;
|
||||
case NULL:
|
||||
o = JsonNull();
|
||||
break;
|
||||
default:
|
||||
jj_la1[8] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
{if (true) return o;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonPrimitive JsonBoolean() throws ParseException {
|
||||
Token t;
|
||||
t = jj_consume_token(BOOLEAN);
|
||||
boolean value = Boolean.valueOf(t.image);
|
||||
{if (true) return new JsonPrimitive(value);}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonPrimitive JsonPrimitive() throws ParseException {
|
||||
JsonPrimitive value;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case SINGLE_QUOTE_LITERAL:
|
||||
case DOUBLE_QUOTE_LITERAL:
|
||||
value = JsonString();
|
||||
{if (true) return value;}
|
||||
break;
|
||||
case DIGITS:
|
||||
case NAN:
|
||||
case INFINITY:
|
||||
case 33:
|
||||
value = JsonNumber();
|
||||
{if (true) return value;}
|
||||
break;
|
||||
case BOOLEAN:
|
||||
value = JsonBoolean();
|
||||
{if (true) return value;}
|
||||
break;
|
||||
default:
|
||||
jj_la1[9] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonPrimitive JsonNumber() throws ParseException {
|
||||
String intpart = null,
|
||||
fracpart = null,
|
||||
exppart = null;
|
||||
JsonPrimitive value;
|
||||
if (jj_2_1(2)) {
|
||||
value = JsonSpecialNumbers();
|
||||
{if (true) return value;}
|
||||
} else {
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case DIGITS:
|
||||
case 33:
|
||||
intpart = JsonInt();
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 34:
|
||||
fracpart = JsonFrac();
|
||||
break;
|
||||
default:
|
||||
jj_la1[10] = jj_gen;
|
||||
;
|
||||
}
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case EXPONENT:
|
||||
exppart = JsonExp();
|
||||
break;
|
||||
default:
|
||||
jj_la1[11] = jj_gen;
|
||||
;
|
||||
}
|
||||
Number n;
|
||||
if (exppart != null || fracpart != null) {
|
||||
fracpart = (fracpart == null) ? "" : fracpart;
|
||||
exppart = (exppart == null) ? "" : exppart;
|
||||
n = new java.math.BigDecimal(intpart + fracpart + exppart);
|
||||
} else {
|
||||
n = new java.math.BigInteger(intpart);
|
||||
}
|
||||
{if (true) return new JsonPrimitive(n);}
|
||||
break;
|
||||
default:
|
||||
jj_la1[12] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonPrimitive JsonSpecialNumbers() throws ParseException {
|
||||
boolean negative = false;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case NAN:
|
||||
jj_consume_token(NAN);
|
||||
{if (true) return new JsonPrimitive(Double.NaN);}
|
||||
break;
|
||||
case INFINITY:
|
||||
case 33:
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 33:
|
||||
jj_consume_token(33);
|
||||
negative = true;
|
||||
break;
|
||||
default:
|
||||
jj_la1[13] = jj_gen;
|
||||
;
|
||||
}
|
||||
jj_consume_token(INFINITY);
|
||||
{if (true) return new JsonPrimitive(negative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY);}
|
||||
break;
|
||||
default:
|
||||
jj_la1[14] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private String JsonInt() throws ParseException {
|
||||
String digits;
|
||||
boolean negative = false;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case 33:
|
||||
jj_consume_token(33);
|
||||
negative = true;
|
||||
break;
|
||||
default:
|
||||
jj_la1[15] = jj_gen;
|
||||
;
|
||||
}
|
||||
digits = Digits();
|
||||
if(negative)
|
||||
{if (true) return "-" + digits;}
|
||||
{if (true) return digits;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private String JsonFrac() throws ParseException {
|
||||
String digits;
|
||||
jj_consume_token(34);
|
||||
digits = Digits();
|
||||
{if (true) return "." + digits;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private String JsonExp() throws ParseException {
|
||||
Token t;
|
||||
t = jj_consume_token(EXPONENT);
|
||||
{if (true) return t.image;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private Token Identifier() throws ParseException {
|
||||
Token t;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case IDENTIFIER_STARTS_WITH_EXPONENT:
|
||||
t = jj_consume_token(IDENTIFIER_STARTS_WITH_EXPONENT);
|
||||
break;
|
||||
case IDENTIFIER_SANS_EXPONENT:
|
||||
t = jj_consume_token(IDENTIFIER_SANS_EXPONENT);
|
||||
break;
|
||||
default:
|
||||
jj_la1[16] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
{if (true) return t;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private String Digits() throws ParseException {
|
||||
Token t;
|
||||
t = jj_consume_token(DIGITS);
|
||||
{if (true) return t.image;}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
final private JsonPrimitive JsonString() throws ParseException {
|
||||
Token t;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case SINGLE_QUOTE_LITERAL:
|
||||
t = jj_consume_token(SINGLE_QUOTE_LITERAL);
|
||||
break;
|
||||
case DOUBLE_QUOTE_LITERAL:
|
||||
t = jj_consume_token(DOUBLE_QUOTE_LITERAL);
|
||||
break;
|
||||
default:
|
||||
jj_la1[17] = jj_gen;
|
||||
jj_consume_token(-1);
|
||||
throw new ParseException();
|
||||
}
|
||||
String value = StringUnmarshaller.unmarshall(t.image);
|
||||
{if (true) return new JsonPrimitive(value);}
|
||||
throw new Error("Missing return statement in function");
|
||||
}
|
||||
|
||||
private boolean jj_2_1(int xla) {
|
||||
jj_la = xla; jj_lastpos = jj_scanpos = token;
|
||||
try { return !jj_3_1(); }
|
||||
catch(LookaheadSuccess ls) { return true; }
|
||||
finally { jj_save(0, xla); }
|
||||
}
|
||||
|
||||
private boolean jj_3R_6() {
|
||||
if (jj_scan_token(33)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean jj_3R_5() {
|
||||
Token xsp;
|
||||
xsp = jj_scanpos;
|
||||
if (jj_3R_6()) jj_scanpos = xsp;
|
||||
if (jj_scan_token(INFINITY)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean jj_3_1() {
|
||||
if (jj_3R_3()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean jj_3R_4() {
|
||||
if (jj_scan_token(NAN)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean jj_3R_3() {
|
||||
Token xsp;
|
||||
xsp = jj_scanpos;
|
||||
if (jj_3R_4()) {
|
||||
jj_scanpos = xsp;
|
||||
if (jj_3R_5()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Generated Token Manager. */
|
||||
public JsonParserJavaccTokenManager token_source;
|
||||
SimpleCharStream jj_input_stream;
|
||||
/** Current token. */
|
||||
public Token token;
|
||||
/** Next token. */
|
||||
public Token jj_nt;
|
||||
private int jj_ntk;
|
||||
private Token jj_scanpos, jj_lastpos;
|
||||
private int jj_la;
|
||||
private int jj_gen;
|
||||
final private int[] jj_la1 = new int[18];
|
||||
static private int[] jj_la1_0;
|
||||
static private int[] jj_la1_1;
|
||||
static {
|
||||
jj_la1_init_0();
|
||||
jj_la1_init_1();
|
||||
}
|
||||
private static void jj_la1_init_0() {
|
||||
jj_la1_0 = new int[] {0x4000000,0x880307c0,0x8c0307c1,0x10000000,0x31800,0x31800,0x10000000,0x880307c0,0x880307c0,0x30740,0x0,0x20,0x40,0x0,0x300,0x0,0x1800,0x30000,};
|
||||
}
|
||||
private static void jj_la1_init_1() {
|
||||
jj_la1_1 = new int[] {0x0,0x2,0x2,0x0,0x0,0x0,0x0,0x3,0x2,0x2,0x4,0x0,0x2,0x2,0x2,0x2,0x0,0x0,};
|
||||
}
|
||||
final private JJCalls[] jj_2_rtns = new JJCalls[1];
|
||||
private boolean jj_rescan = false;
|
||||
private int jj_gc = 0;
|
||||
|
||||
/** Constructor with InputStream. */
|
||||
public JsonParserJavacc(java.io.InputStream stream) {
|
||||
this(stream, null);
|
||||
}
|
||||
/** Constructor with InputStream and supplied encoding */
|
||||
public JsonParserJavacc(java.io.InputStream stream, String encoding) {
|
||||
try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
|
||||
token_source = new JsonParserJavaccTokenManager(jj_input_stream);
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
jj_gen = 0;
|
||||
for (int i = 0; i < 18; i++) jj_la1[i] = -1;
|
||||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream stream) {
|
||||
ReInit(stream, null);
|
||||
}
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream stream, String encoding) {
|
||||
try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
|
||||
token_source.ReInit(jj_input_stream);
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
jj_gen = 0;
|
||||
for (int i = 0; i < 18; i++) jj_la1[i] = -1;
|
||||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public JsonParserJavacc(java.io.Reader stream) {
|
||||
jj_input_stream = new SimpleCharStream(stream, 1, 1);
|
||||
token_source = new JsonParserJavaccTokenManager(jj_input_stream);
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
jj_gen = 0;
|
||||
for (int i = 0; i < 18; i++) jj_la1[i] = -1;
|
||||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.Reader stream) {
|
||||
jj_input_stream.ReInit(stream, 1, 1);
|
||||
token_source.ReInit(jj_input_stream);
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
jj_gen = 0;
|
||||
for (int i = 0; i < 18; i++) jj_la1[i] = -1;
|
||||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
/** Constructor with generated Token Manager. */
|
||||
public JsonParserJavacc(JsonParserJavaccTokenManager tm) {
|
||||
token_source = tm;
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
jj_gen = 0;
|
||||
for (int i = 0; i < 18; i++) jj_la1[i] = -1;
|
||||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(JsonParserJavaccTokenManager tm) {
|
||||
token_source = tm;
|
||||
token = new Token();
|
||||
jj_ntk = -1;
|
||||
jj_gen = 0;
|
||||
for (int i = 0; i < 18; i++) jj_la1[i] = -1;
|
||||
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
|
||||
}
|
||||
|
||||
private Token jj_consume_token(int kind) throws ParseException {
|
||||
Token oldToken;
|
||||
if ((oldToken = token).next != null) token = token.next;
|
||||
else token = token.next = token_source.getNextToken();
|
||||
jj_ntk = -1;
|
||||
if (token.kind == kind) {
|
||||
jj_gen++;
|
||||
if (++jj_gc > 100) {
|
||||
jj_gc = 0;
|
||||
for (int i = 0; i < jj_2_rtns.length; i++) {
|
||||
JJCalls c = jj_2_rtns[i];
|
||||
while (c != null) {
|
||||
if (c.gen < jj_gen) c.first = null;
|
||||
c = c.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
return token;
|
||||
}
|
||||
token = oldToken;
|
||||
jj_kind = kind;
|
||||
throw generateParseException();
|
||||
}
|
||||
|
||||
static private final class LookaheadSuccess extends java.lang.Error { }
|
||||
final private LookaheadSuccess jj_ls = new LookaheadSuccess();
|
||||
private boolean jj_scan_token(int kind) {
|
||||
if (jj_scanpos == jj_lastpos) {
|
||||
jj_la--;
|
||||
if (jj_scanpos.next == null) {
|
||||
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
|
||||
} else {
|
||||
jj_lastpos = jj_scanpos = jj_scanpos.next;
|
||||
}
|
||||
} else {
|
||||
jj_scanpos = jj_scanpos.next;
|
||||
}
|
||||
if (jj_rescan) {
|
||||
int i = 0; Token tok = token;
|
||||
while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
|
||||
if (tok != null) jj_add_error_token(kind, i);
|
||||
}
|
||||
if (jj_scanpos.kind != kind) return true;
|
||||
if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** Get the next Token. */
|
||||
final public Token getNextToken() {
|
||||
if (token.next != null) token = token.next;
|
||||
else token = token.next = token_source.getNextToken();
|
||||
jj_ntk = -1;
|
||||
jj_gen++;
|
||||
return token;
|
||||
}
|
||||
|
||||
/** Get the specific Token. */
|
||||
final public Token getToken(int index) {
|
||||
Token t = token;
|
||||
for (int i = 0; i < index; i++) {
|
||||
if (t.next != null) t = t.next;
|
||||
else t = t.next = token_source.getNextToken();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
private int jj_ntk() {
|
||||
if ((jj_nt=token.next) == null)
|
||||
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
|
||||
else
|
||||
return (jj_ntk = jj_nt.kind);
|
||||
}
|
||||
|
||||
private java.util.List jj_expentries = new java.util.ArrayList();
|
||||
private int[] jj_expentry;
|
||||
private int jj_kind = -1;
|
||||
private int[] jj_lasttokens = new int[100];
|
||||
private int jj_endpos;
|
||||
|
||||
private void jj_add_error_token(int kind, int pos) {
|
||||
if (pos >= 100) return;
|
||||
if (pos == jj_endpos + 1) {
|
||||
jj_lasttokens[jj_endpos++] = kind;
|
||||
} else if (jj_endpos != 0) {
|
||||
jj_expentry = new int[jj_endpos];
|
||||
for (int i = 0; i < jj_endpos; i++) {
|
||||
jj_expentry[i] = jj_lasttokens[i];
|
||||
}
|
||||
jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
|
||||
int[] oldentry = (int[])(it.next());
|
||||
if (oldentry.length == jj_expentry.length) {
|
||||
for (int i = 0; i < jj_expentry.length; i++) {
|
||||
if (oldentry[i] != jj_expentry[i]) {
|
||||
continue jj_entries_loop;
|
||||
}
|
||||
}
|
||||
jj_expentries.add(jj_expentry);
|
||||
break jj_entries_loop;
|
||||
}
|
||||
}
|
||||
if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
|
||||
}
|
||||
}
|
||||
|
||||
/** Generate ParseException. */
|
||||
public ParseException generateParseException() {
|
||||
jj_expentries.clear();
|
||||
boolean[] la1tokens = new boolean[35];
|
||||
if (jj_kind >= 0) {
|
||||
la1tokens[jj_kind] = true;
|
||||
jj_kind = -1;
|
||||
}
|
||||
for (int i = 0; i < 18; i++) {
|
||||
if (jj_la1[i] == jj_gen) {
|
||||
for (int j = 0; j < 32; j++) {
|
||||
if ((jj_la1_0[i] & (1<<j)) != 0) {
|
||||
la1tokens[j] = true;
|
||||
}
|
||||
if ((jj_la1_1[i] & (1<<j)) != 0) {
|
||||
la1tokens[32+j] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 35; i++) {
|
||||
if (la1tokens[i]) {
|
||||
jj_expentry = new int[1];
|
||||
jj_expentry[0] = i;
|
||||
jj_expentries.add(jj_expentry);
|
||||
}
|
||||
}
|
||||
jj_endpos = 0;
|
||||
jj_rescan_token();
|
||||
jj_add_error_token(0, 0);
|
||||
int[][] exptokseq = new int[jj_expentries.size()][];
|
||||
for (int i = 0; i < jj_expentries.size(); i++) {
|
||||
exptokseq[i] = (int[])jj_expentries.get(i);
|
||||
}
|
||||
return new ParseException(token, exptokseq, tokenImage);
|
||||
}
|
||||
|
||||
/** Enable tracing. */
|
||||
final public void enable_tracing() {
|
||||
}
|
||||
|
||||
/** Disable tracing. */
|
||||
final public void disable_tracing() {
|
||||
}
|
||||
|
||||
private void jj_rescan_token() {
|
||||
jj_rescan = true;
|
||||
for (int i = 0; i < 1; i++) {
|
||||
try {
|
||||
JJCalls p = jj_2_rtns[i];
|
||||
do {
|
||||
if (p.gen > jj_gen) {
|
||||
jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
|
||||
switch (i) {
|
||||
case 0: jj_3_1(); break;
|
||||
}
|
||||
}
|
||||
p = p.next;
|
||||
} while (p != null);
|
||||
} catch(LookaheadSuccess ls) { }
|
||||
}
|
||||
jj_rescan = false;
|
||||
}
|
||||
|
||||
private void jj_save(int index, int xla) {
|
||||
JJCalls p = jj_2_rtns[index];
|
||||
while (p.gen > jj_gen) {
|
||||
if (p.next == null) { p = p.next = new JJCalls(); break; }
|
||||
p = p.next;
|
||||
}
|
||||
p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
|
||||
}
|
||||
|
||||
static final class JJCalls {
|
||||
int gen;
|
||||
Token first;
|
||||
int arg;
|
||||
JJCalls next;
|
||||
}
|
||||
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
/* Generated By:JavaCC: Do not edit this line. JsonParserJavaccConstants.java */
|
||||
package com.google.gson;
|
||||
|
||||
|
||||
/**
|
||||
* Token literal values and constants.
|
||||
* Generated by org.javacc.parser.OtherFilesGen#start()
|
||||
*/
|
||||
interface JsonParserJavaccConstants {
|
||||
|
||||
/** End of File. */
|
||||
int EOF = 0;
|
||||
/** RegularExpression Id. */
|
||||
int EXPONENT = 5;
|
||||
/** RegularExpression Id. */
|
||||
int DIGITS = 6;
|
||||
/** RegularExpression Id. */
|
||||
int NULL = 7;
|
||||
/** RegularExpression Id. */
|
||||
int NAN = 8;
|
||||
/** RegularExpression Id. */
|
||||
int INFINITY = 9;
|
||||
/** RegularExpression Id. */
|
||||
int BOOLEAN = 10;
|
||||
/** RegularExpression Id. */
|
||||
int IDENTIFIER_SANS_EXPONENT = 11;
|
||||
/** RegularExpression Id. */
|
||||
int IDENTIFIER_STARTS_WITH_EXPONENT = 12;
|
||||
/** RegularExpression Id. */
|
||||
int HEX_CHAR = 13;
|
||||
/** RegularExpression Id. */
|
||||
int UNICODE_CHAR = 14;
|
||||
/** RegularExpression Id. */
|
||||
int ESCAPE_CHAR = 15;
|
||||
/** RegularExpression Id. */
|
||||
int SINGLE_QUOTE_LITERAL = 16;
|
||||
/** RegularExpression Id. */
|
||||
int DOUBLE_QUOTE_LITERAL = 17;
|
||||
/** RegularExpression Id. */
|
||||
int QUOTE = 18;
|
||||
/** RegularExpression Id. */
|
||||
int ENDQUOTE = 20;
|
||||
/** RegularExpression Id. */
|
||||
int CHAR = 21;
|
||||
/** RegularExpression Id. */
|
||||
int CNTRL_ESC = 22;
|
||||
/** RegularExpression Id. */
|
||||
int HEX = 24;
|
||||
/** RegularExpression Id. */
|
||||
int HEX_ESC = 25;
|
||||
|
||||
/** Lexical state. */
|
||||
int DEFAULT = 0;
|
||||
/** Lexical state. */
|
||||
int STRING_STATE = 1;
|
||||
/** Lexical state. */
|
||||
int ESC_STATE = 2;
|
||||
/** Lexical state. */
|
||||
int HEX_STATE = 3;
|
||||
|
||||
/** Literal token values. */
|
||||
String[] tokenImage = {
|
||||
"<EOF>",
|
||||
"\" \"",
|
||||
"\"\\t\"",
|
||||
"\"\\n\"",
|
||||
"\"\\r\"",
|
||||
"<EXPONENT>",
|
||||
"<DIGITS>",
|
||||
"\"null\"",
|
||||
"\"NaN\"",
|
||||
"\"Infinity\"",
|
||||
"<BOOLEAN>",
|
||||
"<IDENTIFIER_SANS_EXPONENT>",
|
||||
"<IDENTIFIER_STARTS_WITH_EXPONENT>",
|
||||
"<HEX_CHAR>",
|
||||
"<UNICODE_CHAR>",
|
||||
"<ESCAPE_CHAR>",
|
||||
"<SINGLE_QUOTE_LITERAL>",
|
||||
"<DOUBLE_QUOTE_LITERAL>",
|
||||
"\"\\\"\"",
|
||||
"\"\\\\\"",
|
||||
"<ENDQUOTE>",
|
||||
"<CHAR>",
|
||||
"<CNTRL_ESC>",
|
||||
"\"u\"",
|
||||
"<HEX>",
|
||||
"<HEX_ESC>",
|
||||
"\")]}\\\'\\n\"",
|
||||
"\"{\"",
|
||||
"\",\"",
|
||||
"\"}\"",
|
||||
"\":\"",
|
||||
"\"[\"",
|
||||
"\"]\"",
|
||||
"\"-\"",
|
||||
"\".\"",
|
||||
};
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,188 +0,0 @@
|
||||
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 4.1 */
|
||||
/* JavaCCOptions:KEEP_LINE_COL=null */
|
||||
package com.google.gson;
|
||||
|
||||
/**
|
||||
* This exception is thrown when parse errors are encountered.
|
||||
* You can explicitly create objects of this exception type by
|
||||
* calling the method generateParseException in the generated
|
||||
* parser.
|
||||
*
|
||||
* You can modify this class to customize your error reporting
|
||||
* mechanisms so long as you retain the public fields.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
final class ParseException extends Exception {
|
||||
|
||||
/**
|
||||
* The version identifier for this Serializable class.
|
||||
* Increment only if the <i>serialized</i> form of the
|
||||
* class changes.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* This constructor is used by the method "generateParseException"
|
||||
* in the generated parser. Calling this constructor generates
|
||||
* a new object of this type with the fields "currentToken",
|
||||
* "expectedTokenSequences", and "tokenImage" set.
|
||||
*/
|
||||
public ParseException(Token currentTokenVal,
|
||||
int[][] expectedTokenSequencesVal,
|
||||
String[] tokenImageVal
|
||||
)
|
||||
{
|
||||
super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
|
||||
currentToken = currentTokenVal;
|
||||
expectedTokenSequences = expectedTokenSequencesVal;
|
||||
tokenImage = tokenImageVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* The following constructors are for use by you for whatever
|
||||
* purpose you can think of. Constructing the exception in this
|
||||
* manner makes the exception behave in the normal way - i.e., as
|
||||
* documented in the class "Throwable". The fields "errorToken",
|
||||
* "expectedTokenSequences", and "tokenImage" do not contain
|
||||
* relevant information. The JavaCC generated code does not use
|
||||
* these constructors.
|
||||
*/
|
||||
|
||||
public ParseException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/** Constructor with message. */
|
||||
public ParseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the last token that has been consumed successfully. If
|
||||
* this object has been created due to a parse error, the token
|
||||
* followng this token will (therefore) be the first error token.
|
||||
*/
|
||||
public Token currentToken;
|
||||
|
||||
/**
|
||||
* Each entry in this array is an array of integers. Each array
|
||||
* of integers represents a sequence of tokens (by their ordinal
|
||||
* values) that is expected at this point of the parse.
|
||||
*/
|
||||
public int[][] expectedTokenSequences;
|
||||
|
||||
/**
|
||||
* This is a reference to the "tokenImage" array of the generated
|
||||
* parser within which the parse error occurred. This array is
|
||||
* defined in the generated ...Constants interface.
|
||||
*/
|
||||
public String[] tokenImage;
|
||||
|
||||
/**
|
||||
* It uses "currentToken" and "expectedTokenSequences" to generate a parse
|
||||
* error message and returns it. If this object has been created
|
||||
* due to a parse error, and you do not catch it (it gets thrown
|
||||
* from the parser) the correct error message
|
||||
* gets displayed.
|
||||
*/
|
||||
private static String initialise(Token currentToken,
|
||||
int[][] expectedTokenSequences,
|
||||
String[] tokenImage) {
|
||||
String eol = System.getProperty("line.separator", "\n");
|
||||
StringBuffer expected = new StringBuffer();
|
||||
int maxSize = 0;
|
||||
for (int i = 0; i < expectedTokenSequences.length; i++) {
|
||||
if (maxSize < expectedTokenSequences[i].length) {
|
||||
maxSize = expectedTokenSequences[i].length;
|
||||
}
|
||||
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
|
||||
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
|
||||
}
|
||||
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
|
||||
expected.append("...");
|
||||
}
|
||||
expected.append(eol).append(" ");
|
||||
}
|
||||
String retval = "Encountered \"";
|
||||
Token tok = currentToken.next;
|
||||
for (int i = 0; i < maxSize; i++) {
|
||||
if (i != 0) retval += " ";
|
||||
if (tok.kind == 0) {
|
||||
retval += tokenImage[0];
|
||||
break;
|
||||
}
|
||||
retval += " " + tokenImage[tok.kind];
|
||||
retval += " \"";
|
||||
retval += add_escapes(tok.image);
|
||||
retval += " \"";
|
||||
tok = tok.next;
|
||||
}
|
||||
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
|
||||
retval += "." + eol;
|
||||
if (expectedTokenSequences.length == 1) {
|
||||
retval += "Was expecting:" + eol + " ";
|
||||
} else {
|
||||
retval += "Was expecting one of:" + eol + " ";
|
||||
}
|
||||
retval += expected.toString();
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of line string for this machine.
|
||||
*/
|
||||
protected String eol = System.getProperty("line.separator", "\n");
|
||||
|
||||
/**
|
||||
* Used to convert raw characters to their escaped version
|
||||
* when these raw version cannot be used as part of an ASCII
|
||||
* string literal.
|
||||
*/
|
||||
static String add_escapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
{
|
||||
case 0 :
|
||||
continue;
|
||||
case '\b':
|
||||
retval.append("\\b");
|
||||
continue;
|
||||
case '\t':
|
||||
retval.append("\\t");
|
||||
continue;
|
||||
case '\n':
|
||||
retval.append("\\n");
|
||||
continue;
|
||||
case '\f':
|
||||
retval.append("\\f");
|
||||
continue;
|
||||
case '\r':
|
||||
retval.append("\\r");
|
||||
continue;
|
||||
case '\"':
|
||||
retval.append("\\\"");
|
||||
continue;
|
||||
case '\'':
|
||||
retval.append("\\\'");
|
||||
continue;
|
||||
case '\\':
|
||||
retval.append("\\\\");
|
||||
continue;
|
||||
default:
|
||||
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
|
||||
String s = "0000" + Integer.toString(ch, 16);
|
||||
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
|
||||
} else {
|
||||
retval.append(ch);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return retval.toString();
|
||||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=bf6325585417e7bd5d488795e151433b (do not edit this line) */
|
@ -1,469 +0,0 @@
|
||||
/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.1 */
|
||||
/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
|
||||
package com.google.gson;
|
||||
|
||||
/**
|
||||
* An implementation of interface CharStream, where the stream is assumed to
|
||||
* contain only ASCII characters (without unicode processing).
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
final class SimpleCharStream
|
||||
{
|
||||
/** Whether parser is static. */
|
||||
public static final boolean staticFlag = false;
|
||||
int bufsize;
|
||||
int available;
|
||||
int tokenBegin;
|
||||
/** Position in buffer. */
|
||||
public int bufpos = -1;
|
||||
protected int bufline[];
|
||||
protected int bufcolumn[];
|
||||
|
||||
protected int column = 0;
|
||||
protected int line = 1;
|
||||
|
||||
protected boolean prevCharIsCR = false;
|
||||
protected boolean prevCharIsLF = false;
|
||||
|
||||
protected java.io.Reader inputStream;
|
||||
|
||||
protected char[] buffer;
|
||||
protected int maxNextCharInd = 0;
|
||||
protected int inBuf = 0;
|
||||
protected int tabSize = 8;
|
||||
|
||||
protected void setTabSize(int i) { tabSize = i; }
|
||||
protected int getTabSize(int i) { return tabSize; }
|
||||
|
||||
|
||||
protected void ExpandBuff(boolean wrapAround)
|
||||
{
|
||||
char[] newbuffer = new char[bufsize + 2048];
|
||||
int newbufline[] = new int[bufsize + 2048];
|
||||
int newbufcolumn[] = new int[bufsize + 2048];
|
||||
|
||||
try
|
||||
{
|
||||
if (wrapAround)
|
||||
{
|
||||
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
|
||||
buffer = newbuffer;
|
||||
|
||||
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
|
||||
bufline = newbufline;
|
||||
|
||||
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
|
||||
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
|
||||
bufcolumn = newbufcolumn;
|
||||
|
||||
maxNextCharInd = (bufpos += (bufsize - tokenBegin));
|
||||
}
|
||||
else
|
||||
{
|
||||
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
|
||||
buffer = newbuffer;
|
||||
|
||||
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
|
||||
bufline = newbufline;
|
||||
|
||||
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
|
||||
bufcolumn = newbufcolumn;
|
||||
|
||||
maxNextCharInd = (bufpos -= tokenBegin);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new Error(t.getMessage());
|
||||
}
|
||||
|
||||
|
||||
bufsize += 2048;
|
||||
available = bufsize;
|
||||
tokenBegin = 0;
|
||||
}
|
||||
|
||||
protected void FillBuff() throws java.io.IOException
|
||||
{
|
||||
if (maxNextCharInd == available)
|
||||
{
|
||||
if (available == bufsize)
|
||||
{
|
||||
if (tokenBegin > 2048)
|
||||
{
|
||||
bufpos = maxNextCharInd = 0;
|
||||
available = tokenBegin;
|
||||
}
|
||||
else if (tokenBegin < 0)
|
||||
bufpos = maxNextCharInd = 0;
|
||||
else
|
||||
ExpandBuff(false);
|
||||
}
|
||||
else if (available > tokenBegin)
|
||||
available = bufsize;
|
||||
else if ((tokenBegin - available) < 2048)
|
||||
ExpandBuff(true);
|
||||
else
|
||||
available = tokenBegin;
|
||||
}
|
||||
|
||||
int i;
|
||||
try {
|
||||
if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1)
|
||||
{
|
||||
inputStream.close();
|
||||
throw new java.io.IOException();
|
||||
}
|
||||
else
|
||||
maxNextCharInd += i;
|
||||
return;
|
||||
}
|
||||
catch(java.io.IOException e) {
|
||||
--bufpos;
|
||||
backup(0);
|
||||
if (tokenBegin == -1)
|
||||
tokenBegin = bufpos;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/** Start. */
|
||||
public char BeginToken() throws java.io.IOException
|
||||
{
|
||||
tokenBegin = -1;
|
||||
char c = readChar();
|
||||
tokenBegin = bufpos;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
protected void UpdateLineColumn(char c)
|
||||
{
|
||||
column++;
|
||||
|
||||
if (prevCharIsLF)
|
||||
{
|
||||
prevCharIsLF = false;
|
||||
line += (column = 1);
|
||||
}
|
||||
else if (prevCharIsCR)
|
||||
{
|
||||
prevCharIsCR = false;
|
||||
if (c == '\n')
|
||||
{
|
||||
prevCharIsLF = true;
|
||||
}
|
||||
else
|
||||
line += (column = 1);
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '\r' :
|
||||
prevCharIsCR = true;
|
||||
break;
|
||||
case '\n' :
|
||||
prevCharIsLF = true;
|
||||
break;
|
||||
case '\t' :
|
||||
column--;
|
||||
column += (tabSize - (column % tabSize));
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
bufline[bufpos] = line;
|
||||
bufcolumn[bufpos] = column;
|
||||
}
|
||||
|
||||
/** Read a character. */
|
||||
public char readChar() throws java.io.IOException
|
||||
{
|
||||
if (inBuf > 0)
|
||||
{
|
||||
--inBuf;
|
||||
|
||||
if (++bufpos == bufsize)
|
||||
bufpos = 0;
|
||||
|
||||
return buffer[bufpos];
|
||||
}
|
||||
|
||||
if (++bufpos >= maxNextCharInd)
|
||||
FillBuff();
|
||||
|
||||
char c = buffer[bufpos];
|
||||
|
||||
UpdateLineColumn(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @see #getEndColumn
|
||||
*/
|
||||
|
||||
public int getColumn() {
|
||||
return bufcolumn[bufpos];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @see #getEndLine
|
||||
*/
|
||||
|
||||
public int getLine() {
|
||||
return bufline[bufpos];
|
||||
}
|
||||
|
||||
/** Get token end column number. */
|
||||
public int getEndColumn() {
|
||||
return bufcolumn[bufpos];
|
||||
}
|
||||
|
||||
/** Get token end line number. */
|
||||
public int getEndLine() {
|
||||
return bufline[bufpos];
|
||||
}
|
||||
|
||||
/** Get token beginning column number. */
|
||||
public int getBeginColumn() {
|
||||
return bufcolumn[tokenBegin];
|
||||
}
|
||||
|
||||
/** Get token beginning line number. */
|
||||
public int getBeginLine() {
|
||||
return bufline[tokenBegin];
|
||||
}
|
||||
|
||||
/** Backup a number of characters. */
|
||||
public void backup(int amount) {
|
||||
|
||||
inBuf += amount;
|
||||
if ((bufpos -= amount) < 0)
|
||||
bufpos += bufsize;
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.Reader dstream, int startline,
|
||||
int startcolumn, int buffersize)
|
||||
{
|
||||
inputStream = dstream;
|
||||
line = startline;
|
||||
column = startcolumn - 1;
|
||||
|
||||
available = bufsize = buffersize;
|
||||
buffer = new char[buffersize];
|
||||
bufline = new int[buffersize];
|
||||
bufcolumn = new int[buffersize];
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.Reader dstream, int startline,
|
||||
int startcolumn)
|
||||
{
|
||||
this(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.Reader dstream)
|
||||
{
|
||||
this(dstream, 1, 1, 4096);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.Reader dstream, int startline,
|
||||
int startcolumn, int buffersize)
|
||||
{
|
||||
inputStream = dstream;
|
||||
line = startline;
|
||||
column = startcolumn - 1;
|
||||
|
||||
if (buffer == null || buffersize != buffer.length)
|
||||
{
|
||||
available = bufsize = buffersize;
|
||||
buffer = new char[buffersize];
|
||||
bufline = new int[buffersize];
|
||||
bufcolumn = new int[buffersize];
|
||||
}
|
||||
prevCharIsLF = prevCharIsCR = false;
|
||||
tokenBegin = inBuf = maxNextCharInd = 0;
|
||||
bufpos = -1;
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.Reader dstream, int startline,
|
||||
int startcolumn)
|
||||
{
|
||||
ReInit(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.Reader dstream)
|
||||
{
|
||||
ReInit(dstream, 1, 1, 4096);
|
||||
}
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
|
||||
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.InputStream dstream, int startline,
|
||||
int startcolumn, int buffersize)
|
||||
{
|
||||
this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
|
||||
int startcolumn) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
this(dstream, encoding, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.InputStream dstream, int startline,
|
||||
int startcolumn)
|
||||
{
|
||||
this(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
this(dstream, encoding, 1, 1, 4096);
|
||||
}
|
||||
|
||||
/** Constructor. */
|
||||
public SimpleCharStream(java.io.InputStream dstream)
|
||||
{
|
||||
this(dstream, 1, 1, 4096);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
|
||||
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, int startline,
|
||||
int startcolumn, int buffersize)
|
||||
{
|
||||
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
ReInit(dstream, encoding, 1, 1, 4096);
|
||||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream)
|
||||
{
|
||||
ReInit(dstream, 1, 1, 4096);
|
||||
}
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
|
||||
int startcolumn) throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
ReInit(dstream, encoding, startline, startcolumn, 4096);
|
||||
}
|
||||
/** Reinitialise. */
|
||||
public void ReInit(java.io.InputStream dstream, int startline,
|
||||
int startcolumn)
|
||||
{
|
||||
ReInit(dstream, startline, startcolumn, 4096);
|
||||
}
|
||||
/** Get token literal value. */
|
||||
public String GetImage()
|
||||
{
|
||||
if (bufpos >= tokenBegin)
|
||||
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
|
||||
else
|
||||
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
|
||||
new String(buffer, 0, bufpos + 1);
|
||||
}
|
||||
|
||||
/** Get the suffix. */
|
||||
public char[] GetSuffix(int len)
|
||||
{
|
||||
char[] ret = new char[len];
|
||||
|
||||
if ((bufpos + 1) >= len)
|
||||
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
|
||||
else
|
||||
{
|
||||
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
|
||||
len - bufpos - 1);
|
||||
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Reset buffer when finished. */
|
||||
public void Done()
|
||||
{
|
||||
buffer = null;
|
||||
bufline = null;
|
||||
bufcolumn = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to adjust line and column numbers for the start of a token.
|
||||
*/
|
||||
public void adjustBeginLineColumn(int newLine, int newCol)
|
||||
{
|
||||
int start = tokenBegin;
|
||||
int len;
|
||||
|
||||
if (bufpos >= tokenBegin)
|
||||
{
|
||||
len = bufpos - tokenBegin + inBuf + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
|
||||
}
|
||||
|
||||
int i = 0, j = 0, k = 0;
|
||||
int nextColDiff = 0, columnDiff = 0;
|
||||
|
||||
while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
|
||||
{
|
||||
bufline[j] = newLine;
|
||||
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
|
||||
bufcolumn[j] = newCol + columnDiff;
|
||||
columnDiff = nextColDiff;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i < len)
|
||||
{
|
||||
bufline[j] = newLine++;
|
||||
bufcolumn[j] = newCol + columnDiff;
|
||||
|
||||
while (i++ < len)
|
||||
{
|
||||
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
|
||||
bufline[j] = newLine++;
|
||||
else
|
||||
bufline[j] = newLine;
|
||||
}
|
||||
}
|
||||
|
||||
line = bufline[j];
|
||||
column = bufcolumn[j];
|
||||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=351e3d8e62614bff24f1b9ba2fd77764 (do not edit this line) */
|
@ -1,74 +0,0 @@
|
||||
package com.google.gson;
|
||||
|
||||
final class StringUnmarshaller {
|
||||
static String unmarshall(String str) {
|
||||
str = str.substring(1, str.length()-1);
|
||||
|
||||
int len = str.length();
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
char c = str.charAt(i);
|
||||
++i;
|
||||
if (c == '\\') {
|
||||
char c1 = str.charAt(i);
|
||||
++i;
|
||||
if (c1 == 'u') { // This is a unicode escape
|
||||
// TODO(inder): Handle the case where code points are of size bigger than 4
|
||||
int codePoint = getCodePoint(str, i);
|
||||
sb.appendCodePoint(codePoint);
|
||||
i += 4;
|
||||
} else {
|
||||
char escapedChar = getEscapedChar(str, c1);
|
||||
sb.append(escapedChar);
|
||||
}
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static int getCodePoint(String str, int i) {
|
||||
// int codePoint = Character.codePointAt(str, i);
|
||||
String s = str.substring(i, i+4);
|
||||
int codePoint = Integer.parseInt(s, 16);
|
||||
return codePoint;
|
||||
}
|
||||
|
||||
private static char getEscapedChar(String str, char c) {
|
||||
char ch;
|
||||
switch (c) {
|
||||
case 'n':
|
||||
ch = '\n';
|
||||
break;
|
||||
case 'b':
|
||||
ch = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
ch = '\f';
|
||||
break;
|
||||
case 't':
|
||||
ch = '\t';
|
||||
break;
|
||||
case 'r':
|
||||
ch = '\r';
|
||||
break;
|
||||
case '\"':
|
||||
ch = '\"';
|
||||
break;
|
||||
case '\'':
|
||||
ch = '\'';
|
||||
break;
|
||||
case '\\':
|
||||
ch = '\\';
|
||||
break;
|
||||
case '/':
|
||||
ch = '/';
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected character: " + c + " in " + str);
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */
|
||||
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
|
||||
package com.google.gson;
|
||||
|
||||
/**
|
||||
* Describes the input token stream.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
final class Token implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* The version identifier for this Serializable class.
|
||||
* Increment only if the <i>serialized</i> form of the
|
||||
* class changes.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* An integer that describes the kind of this token. This numbering
|
||||
* system is determined by JavaCCParser, and a table of these numbers is
|
||||
* stored in the file ...Constants.java.
|
||||
*/
|
||||
public int kind;
|
||||
|
||||
/** The line number of the first character of this Token. */
|
||||
public int beginLine;
|
||||
/** The column number of the first character of this Token. */
|
||||
public int beginColumn;
|
||||
/** The line number of the last character of this Token. */
|
||||
public int endLine;
|
||||
/** The column number of the last character of this Token. */
|
||||
public int endColumn;
|
||||
|
||||
/**
|
||||
* The string image of the token.
|
||||
*/
|
||||
public String image;
|
||||
|
||||
/**
|
||||
* A reference to the next regular (non-special) token from the input
|
||||
* stream. If this is the last token from the input stream, or if the
|
||||
* token manager has not read tokens beyond this one, this field is
|
||||
* set to null. This is true only if this token is also a regular
|
||||
* token. Otherwise, see below for a description of the contents of
|
||||
* this field.
|
||||
*/
|
||||
public Token next;
|
||||
|
||||
/**
|
||||
* This field is used to access special tokens that occur prior to this
|
||||
* token, but after the immediately preceding regular (non-special) token.
|
||||
* If there are no such special tokens, this field is set to null.
|
||||
* When there are more than one such special token, this field refers
|
||||
* to the last of these special tokens, which in turn refers to the next
|
||||
* previous special token through its specialToken field, and so on
|
||||
* until the first special token (whose specialToken field is null).
|
||||
* The next fields of special tokens refer to other special tokens that
|
||||
* immediately follow it (without an intervening regular token). If there
|
||||
* is no such token, this field is null.
|
||||
*/
|
||||
public Token specialToken;
|
||||
|
||||
/**
|
||||
* An optional attribute value of the Token.
|
||||
* Tokens which are not used as syntactic sugar will often contain
|
||||
* meaningful values that will be used later on by the compiler or
|
||||
* interpreter. This attribute value is often different from the image.
|
||||
* Any subclass of Token that actually wants to return a non-null value can
|
||||
* override this method as appropriate.
|
||||
*/
|
||||
public Object getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* No-argument constructor
|
||||
*/
|
||||
public Token() {}
|
||||
|
||||
/**
|
||||
* Constructs a new token for the specified Image.
|
||||
*/
|
||||
public Token(int kind)
|
||||
{
|
||||
this(kind, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new token for the specified Image and Kind.
|
||||
*/
|
||||
public Token(int kind, String image)
|
||||
{
|
||||
this.kind = kind;
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Token object, by default. However, if you want, you
|
||||
* can create and return subclass objects based on the value of ofKind.
|
||||
* Simply add the cases to the switch for all those special cases.
|
||||
* For example, if you have a subclass of Token called IDToken that
|
||||
* you want to create if ofKind is ID, simply add something like :
|
||||
*
|
||||
* case MyParserConstants.ID : return new IDToken(ofKind, image);
|
||||
*
|
||||
* to the following switch statement. Then you can cast matchedToken
|
||||
* variable to the appropriate type and use sit in your lexical actions.
|
||||
*/
|
||||
public static Token newToken(int ofKind, String image)
|
||||
{
|
||||
switch(ofKind)
|
||||
{
|
||||
default : return new Token(ofKind, image);
|
||||
}
|
||||
}
|
||||
|
||||
public static Token newToken(int ofKind)
|
||||
{
|
||||
return newToken(ofKind, null);
|
||||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=f683548fa415467062989dfb10c566e6 (do not edit this line) */
|
@ -1,148 +0,0 @@
|
||||
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */
|
||||
/* JavaCCOptions: */
|
||||
package com.google.gson;
|
||||
|
||||
/** Token Manager Error. */
|
||||
@SuppressWarnings("all")
|
||||
final class TokenMgrError extends Error
|
||||
{
|
||||
|
||||
/**
|
||||
* The version identifier for this Serializable class.
|
||||
* Increment only if the <i>serialized</i> form of the
|
||||
* class changes.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Ordinals for various reasons why an Error of this type can be thrown.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lexical error occurred.
|
||||
*/
|
||||
static final int LEXICAL_ERROR = 0;
|
||||
|
||||
/**
|
||||
* An attempt was made to create a second instance of a static token manager.
|
||||
*/
|
||||
static final int STATIC_LEXER_ERROR = 1;
|
||||
|
||||
/**
|
||||
* Tried to change to an invalid lexical state.
|
||||
*/
|
||||
static final int INVALID_LEXICAL_STATE = 2;
|
||||
|
||||
/**
|
||||
* Detected (and bailed out of) an infinite loop in the token manager.
|
||||
*/
|
||||
static final int LOOP_DETECTED = 3;
|
||||
|
||||
/**
|
||||
* Indicates the reason why the exception is thrown. It will have
|
||||
* one of the above 4 values.
|
||||
*/
|
||||
int errorCode;
|
||||
|
||||
/**
|
||||
* Replaces unprintable characters by their escaped (or unicode escaped)
|
||||
* equivalents in the given string
|
||||
*/
|
||||
protected static final String addEscapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
{
|
||||
case 0 :
|
||||
continue;
|
||||
case '\b':
|
||||
retval.append("\\b");
|
||||
continue;
|
||||
case '\t':
|
||||
retval.append("\\t");
|
||||
continue;
|
||||
case '\n':
|
||||
retval.append("\\n");
|
||||
continue;
|
||||
case '\f':
|
||||
retval.append("\\f");
|
||||
continue;
|
||||
case '\r':
|
||||
retval.append("\\r");
|
||||
continue;
|
||||
case '\"':
|
||||
retval.append("\\\"");
|
||||
continue;
|
||||
case '\'':
|
||||
retval.append("\\\'");
|
||||
continue;
|
||||
case '\\':
|
||||
retval.append("\\\\");
|
||||
continue;
|
||||
default:
|
||||
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
|
||||
String s = "0000" + Integer.toString(ch, 16);
|
||||
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
|
||||
} else {
|
||||
retval.append(ch);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return retval.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a detailed message for the Error when it is thrown by the
|
||||
* token manager to indicate a lexical error.
|
||||
* Parameters :
|
||||
* EOFSeen : indicates if EOF caused the lexical error
|
||||
* curLexState : lexical state in which this error occurred
|
||||
* errorLine : line number when the error occurred
|
||||
* errorColumn : column number when the error occurred
|
||||
* errorAfter : prefix that was seen before this error occurred
|
||||
* curchar : the offending character
|
||||
* Note: You can customize the lexical error message by modifying this method.
|
||||
*/
|
||||
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
|
||||
return("Lexical error at line " +
|
||||
errorLine + ", column " +
|
||||
errorColumn + ". Encountered: " +
|
||||
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
|
||||
"after : \"" + addEscapes(errorAfter) + "\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* You can also modify the body of this method to customize your error messages.
|
||||
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
|
||||
* of end-users concern, so you can return something like :
|
||||
*
|
||||
* "Internal Error : Please file a bug report .... "
|
||||
*
|
||||
* from this method for such cases in the release version of your parser.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructors of various flavors follow.
|
||||
*/
|
||||
|
||||
/** No arg constructor. */
|
||||
public TokenMgrError() {
|
||||
}
|
||||
|
||||
/** Constructor with message and reason. */
|
||||
public TokenMgrError(String message, int reason) {
|
||||
super(message);
|
||||
errorCode = reason;
|
||||
}
|
||||
|
||||
/** Full Constructor. */
|
||||
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
|
||||
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=f9c23e3fca926dbaf51c810110262be0 (do not edit this line) */
|
@ -1,249 +0,0 @@
|
||||
/**
|
||||
* Adapted from the Json parser grammar from http://code.google.com/p/jsonparser/
|
||||
*
|
||||
* Author: Inderjeet Singh
|
||||
*/
|
||||
|
||||
options {
|
||||
STATIC = false;
|
||||
UNICODE_INPUT = true;
|
||||
}
|
||||
|
||||
PARSER_BEGIN(JsonParserJavacc)
|
||||
|
||||
package com.google.gson;
|
||||
import java.io.EOFException;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
final class JsonParserJavacc {
|
||||
|
||||
}
|
||||
|
||||
PARSER_END(JsonParserJavacc)
|
||||
|
||||
SKIP : { " " | "\t" | "\n" | "\r" }
|
||||
/*
|
||||
* Technically Json does not allow leading zeros in numbers, but we
|
||||
* will allow that.
|
||||
*/
|
||||
TOKEN : {
|
||||
<EXPONENT : ("e"|"E")["+","-","0"-"9"](["0"-"9"])*>
|
||||
| <DIGITS : (["0"-"9"])+>
|
||||
| <NULL : "null">
|
||||
| <NAN : "NaN">
|
||||
| <INFINITY : "Infinity">
|
||||
| <BOOLEAN : ("true" | "false")>
|
||||
| <IDENTIFIER_SANS_EXPONENT : ["a"-"d","f"-"z","A"-"D","F"-"Z", "_"] (["a"-"z","A"-"Z","0"-"9","_"])* >
|
||||
| <IDENTIFIER_STARTS_WITH_EXPONENT : ["e","E"] (["a"-"z","A"-"Z","0"-"9","_"])* >
|
||||
| <#HEX_CHAR : ["a"-"f","A"-"F","0"-"9"]>
|
||||
| <UNICODE_CHAR : "\\u" <HEX_CHAR><HEX_CHAR><HEX_CHAR><HEX_CHAR> >
|
||||
| <#ESCAPE_CHAR: "\\" ["n","t","b","r","f","\\","'","\"", "/"] >
|
||||
| <SINGLE_QUOTE_LITERAL: "\'" ( (~["\'","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\'" >
|
||||
| <DOUBLE_QUOTE_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\"" >
|
||||
| <QUOTE : "\""> : STRING_STATE
|
||||
}
|
||||
<STRING_STATE> MORE : { "\\" : ESC_STATE }
|
||||
<STRING_STATE> TOKEN : {
|
||||
<ENDQUOTE : <QUOTE> > : DEFAULT
|
||||
| <CHAR : ~["\"","\\"]>
|
||||
}
|
||||
<ESC_STATE> TOKEN : {
|
||||
<CNTRL_ESC : ["\"","\\","/","b","f","n","r","t"]> : STRING_STATE
|
||||
}
|
||||
<ESC_STATE> MORE : { "u" : HEX_STATE }
|
||||
<HEX_STATE> TOKEN : {
|
||||
<#HEX : ["a"-"f","A"-"F","0"-"9"]>
|
||||
| <HEX_ESC : <HEX><HEX><HEX><HEX> > : STRING_STATE
|
||||
}
|
||||
|
||||
public JsonElement parse() :
|
||||
{
|
||||
JsonElement json = null;
|
||||
}
|
||||
{
|
||||
(<EOF>){
|
||||
throw new JsonParseException(new EOFException());
|
||||
} |
|
||||
[")]}'\n"]( json=JsonObject() |
|
||||
json=JsonArray() |
|
||||
json=JsonPrimitive() |
|
||||
json=JsonNull())
|
||||
{ return json; }
|
||||
}
|
||||
|
||||
private JsonObject JsonObject() :
|
||||
{
|
||||
JsonObject o = new JsonObject();
|
||||
}
|
||||
{
|
||||
"{" [ Pair(o) ("," Pair(o))* ] "}"
|
||||
{ return o; }
|
||||
}
|
||||
|
||||
private JsonNull JsonNull() :
|
||||
{
|
||||
Token t;
|
||||
}
|
||||
{
|
||||
t = <NULL> { return JsonNull.createJsonNull(); }
|
||||
}
|
||||
|
||||
private void Pair(JsonObject o) :
|
||||
{
|
||||
JsonPrimitive property;
|
||||
JsonElement value;
|
||||
}
|
||||
{
|
||||
property=JsonMemberName() ":" value=JsonValue()
|
||||
{
|
||||
o.add(property.getAsString(), value);
|
||||
}
|
||||
}
|
||||
|
||||
private JsonPrimitive JsonMemberName() :
|
||||
{ Token t; JsonPrimitive value; }
|
||||
{
|
||||
t= Identifier() { return new JsonPrimitive(t.image); } |
|
||||
value=JsonString() { return value; }
|
||||
}
|
||||
|
||||
private JsonArray JsonArray() :
|
||||
{ JsonArray array = new JsonArray(); }
|
||||
{
|
||||
"[" (
|
||||
array=JsonArrayEmpty(array) {return array;} |
|
||||
JsonArrayElement(array) (JsonArrayNextElement(array))* "]" {return array; } )
|
||||
}
|
||||
|
||||
private JsonArray JsonArrayEmpty(JsonArray array) :
|
||||
{ }
|
||||
{
|
||||
"]" { return array; }
|
||||
}
|
||||
|
||||
private JsonArray JsonArrayElement(JsonArray array) :
|
||||
{ JsonElement element = null; }
|
||||
{
|
||||
element=JsonValue() {array.add(element);}
|
||||
{ return array; }
|
||||
}
|
||||
|
||||
private JsonArray JsonArrayNextElement(JsonArray array) :
|
||||
{ JsonElement element = null; }
|
||||
{
|
||||
"," element=JsonValue() {array.add(element);}
|
||||
{ return array; }
|
||||
}
|
||||
|
||||
private JsonElement JsonValue() :
|
||||
{ JsonElement o = null; }
|
||||
{
|
||||
( o=JsonString() |
|
||||
o=JsonNumber() |
|
||||
o=JsonObject() |
|
||||
o=JsonArray() |
|
||||
o=JsonBoolean() |
|
||||
o=JsonNull() )
|
||||
{ return o; }
|
||||
}
|
||||
|
||||
private JsonPrimitive JsonBoolean() :
|
||||
{ Token t; }
|
||||
{
|
||||
t=<BOOLEAN> {
|
||||
boolean value = Boolean.valueOf(t.image);
|
||||
return new JsonPrimitive(value);
|
||||
}
|
||||
}
|
||||
|
||||
private JsonPrimitive JsonPrimitive() :
|
||||
{
|
||||
JsonPrimitive value;
|
||||
}
|
||||
{
|
||||
( value=JsonString()) { return value; } |
|
||||
( value=JsonNumber()) { return value; } |
|
||||
( value=JsonBoolean()) { return value; }
|
||||
}
|
||||
|
||||
private JsonPrimitive JsonNumber() :
|
||||
{
|
||||
String intpart = null,
|
||||
fracpart = null,
|
||||
exppart = null;
|
||||
JsonPrimitive value;
|
||||
}
|
||||
{
|
||||
LOOKAHEAD(2)
|
||||
(value=JsonSpecialNumbers()) {return value; } |
|
||||
(intpart=JsonInt() [ fracpart=JsonFrac() ] [ exppart=JsonExp() ])
|
||||
{
|
||||
Number n;
|
||||
if (exppart != null || fracpart != null) {
|
||||
fracpart = (fracpart == null) ? "" : fracpart;
|
||||
exppart = (exppart == null) ? "" : exppart;
|
||||
n = new java.math.BigDecimal(intpart + fracpart + exppart);
|
||||
} else {
|
||||
n = new java.math.BigInteger(intpart);
|
||||
}
|
||||
return new JsonPrimitive(n);
|
||||
}
|
||||
}
|
||||
|
||||
private JsonPrimitive JsonSpecialNumbers() :
|
||||
{
|
||||
boolean negative = false;
|
||||
}
|
||||
{
|
||||
(<NAN>) {return new JsonPrimitive(Double.NaN); } |
|
||||
(["-" {negative = true;}]<INFINITY>) {return new JsonPrimitive(negative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY); }
|
||||
}
|
||||
|
||||
private String JsonInt() :
|
||||
{
|
||||
String digits;
|
||||
boolean negative = false;
|
||||
}
|
||||
{
|
||||
["-" { negative = true; } ] digits=Digits()
|
||||
{
|
||||
if(negative)
|
||||
return "-" + digits;
|
||||
return digits;
|
||||
}
|
||||
}
|
||||
|
||||
private String JsonFrac() :
|
||||
{ String digits; }
|
||||
{
|
||||
"." digits=Digits()
|
||||
{ return "." + digits; }
|
||||
}
|
||||
|
||||
private String JsonExp() :
|
||||
{ Token t; }
|
||||
{
|
||||
t = <EXPONENT> {return t.image;}
|
||||
}
|
||||
|
||||
private Token Identifier() :
|
||||
{ Token t; }
|
||||
{
|
||||
(t = <IDENTIFIER_STARTS_WITH_EXPONENT> | t = <IDENTIFIER_SANS_EXPONENT>) {return t;}
|
||||
}
|
||||
|
||||
private String Digits() :
|
||||
{ Token t; }
|
||||
{
|
||||
t=<DIGITS>
|
||||
{ return t.image; }
|
||||
}
|
||||
|
||||
private JsonPrimitive JsonString() :
|
||||
{ Token t; }
|
||||
{
|
||||
(t=<SINGLE_QUOTE_LITERAL> | t=<DOUBLE_QUOTE_LITERAL>) {
|
||||
String value = StringUnmarshaller.unmarshall(t.image);
|
||||
return new JsonPrimitive(value);
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package com.google.gson;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link StringUnmarshaller}.
|
||||
*
|
||||
* @author Inderjeet Singh
|
||||
*/
|
||||
public class StringUnmarshallerTest extends TestCase {
|
||||
|
||||
public void testCtrlN() {
|
||||
assertEquals("a\nb", StringUnmarshaller.unmarshall("'a\\nb'"));
|
||||
}
|
||||
|
||||
public void testCtrlR() {
|
||||
assertEquals("a\rb", StringUnmarshaller.unmarshall("'a\\rb'"));
|
||||
}
|
||||
|
||||
public void testCtrlT() {
|
||||
assertEquals("\tb", StringUnmarshaller.unmarshall("'\\tb'"));
|
||||
}
|
||||
|
||||
public void testBackSpace() {
|
||||
assertEquals("\b foo", StringUnmarshaller.unmarshall("'\\b foo'"));
|
||||
}
|
||||
|
||||
public void testFormFeed() {
|
||||
assertEquals("\f bar", StringUnmarshaller.unmarshall("'\\f bar'"));
|
||||
}
|
||||
|
||||
public void testSingleQuote() {
|
||||
assertEquals("a'b", StringUnmarshaller.unmarshall("'a'b'"));
|
||||
}
|
||||
|
||||
public void testSingleQuoteEscaped() {
|
||||
assertEquals("a'b", StringUnmarshaller.unmarshall("'a\\'b'"));
|
||||
}
|
||||
|
||||
public void testDoubleQuote() {
|
||||
assertEquals("a\"b", StringUnmarshaller.unmarshall("'a\"b'"));
|
||||
}
|
||||
|
||||
public void testDoubleQuoteEscaped() {
|
||||
assertEquals("a\"b", StringUnmarshaller.unmarshall("'a\\\"b'"));
|
||||
}
|
||||
|
||||
public void testBackslash() {
|
||||
assertEquals("a\\b", StringUnmarshaller.unmarshall("'a\\\\b'"));
|
||||
}
|
||||
|
||||
public void testUnicodeString() {
|
||||
assertEquals("\u03a9b", StringUnmarshaller.unmarshall("'\\u03a9b'"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user