Update Parser to add members to an JsonObject within a loop rather than a recursive call.

This commit is contained in:
Joel Leitch 2010-05-19 20:44:27 +00:00
parent e7e2e59f73
commit 2610a2920d
4 changed files with 46 additions and 78 deletions

View File

@ -73,13 +73,26 @@ final class JsonParserJavacc implements JsonParserJavaccConstants {
case IDENTIFIER_STARTS_WITH_EXPONENT:
case SINGLE_QUOTE_LITERAL:
case DOUBLE_QUOTE_LITERAL:
Members(o);
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[3] = jj_gen;
jj_la1[4] = jj_gen;
;
}
jj_consume_token(28);
jj_consume_token(29);
{if (true) return o;}
throw new Error("Missing return statement in function");
}
@ -91,19 +104,6 @@ final class JsonParserJavacc implements JsonParserJavaccConstants {
throw new Error("Missing return statement in function");
}
final private void Members(JsonObject o) throws ParseException {
Pair(o);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 29:
jj_consume_token(29);
Members(o);
break;
default:
jj_la1[4] = jj_gen;
;
}
}
final private void Pair(JsonObject o) throws ParseException {
JsonPrimitive property;
JsonElement value;
@ -153,15 +153,15 @@ final class JsonParserJavacc implements JsonParserJavaccConstants {
case 31:
case 33:
JsonArrayElement(array);
label_1:
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 29:
case 28:
;
break;
default:
jj_la1[6] = jj_gen;
break label_1;
break label_2;
}
JsonArrayNextElement(array);
}
@ -192,7 +192,7 @@ final class JsonParserJavacc implements JsonParserJavaccConstants {
final private JsonArray JsonArrayNextElement(JsonArray array) throws ParseException {
JsonElement element = null;
jj_consume_token(29);
jj_consume_token(28);
element = JsonValue();
array.add(element);
{if (true) return array;}
@ -430,36 +430,36 @@ final class JsonParserJavacc implements JsonParserJavaccConstants {
finally { jj_save(0, xla); }
}
private boolean jj_3R_3() {
if (jj_scan_token(NAN)) return true;
return false;
}
private boolean jj_3R_2() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_3()) {
jj_scanpos = xsp;
if (jj_3R_4()) return true;
}
return false;
}
private boolean jj_3R_5() {
private boolean jj_3R_6() {
if (jj_scan_token(33)) return true;
return false;
}
private boolean jj_3R_4() {
private boolean jj_3R_5() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_5()) jj_scanpos = xsp;
if (jj_3R_6()) jj_scanpos = xsp;
if (jj_scan_token(INFINITY)) return true;
return false;
}
private boolean jj_3_1() {
if (jj_3R_2()) return true;
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;
}
@ -482,7 +482,7 @@ final class JsonParserJavacc implements JsonParserJavaccConstants {
jj_la1_init_1();
}
private static void jj_la1_init_0() {
jj_la1_0 = new int[] {0x4000000,0x880307c0,0x8c0307c1,0x31800,0x20000000,0x31800,0x20000000,0x880307c0,0x880307c0,0x30740,0x0,0x20,0x40,0x0,0x300,0x0,0x1800,0x30000,};
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,};

View File

@ -88,8 +88,8 @@ interface JsonParserJavaccConstants {
"<HEX_ESC>",
"\")]}\\\'\\n\"",
"\"{\"",
"\"}\"",
"\",\"",
"\"}\"",
"\":\"",
"\"[\"",
"\"]\"",

View File

@ -1,10 +1,8 @@
/* Generated By:JavaCC: Do not edit this line. JsonParserJavaccTokenManager.java */
package com.google.gson;
import java.io.EOFException;
/** Token Manager. */
@SuppressWarnings("all")
final class JsonParserJavaccTokenManager implements JsonParserJavaccConstants
class JsonParserJavaccTokenManager implements JsonParserJavaccConstants
{
/** Debug output. */
@ -196,7 +194,7 @@ private int jjMoveStringLiteralDfa0_0()
case 41:
return jjMoveStringLiteralDfa1_0(0x4000000L);
case 44:
return jjStopAtPos(0, 29);
return jjStopAtPos(0, 28);
case 45:
return jjStopAtPos(0, 33);
case 46:
@ -216,7 +214,7 @@ private int jjMoveStringLiteralDfa0_0()
case 123:
return jjStopAtPos(0, 27);
case 125:
return jjStopAtPos(0, 28);
return jjStopAtPos(0, 29);
default :
return jjMoveNfa_0(4, 0);
}
@ -771,18 +769,6 @@ private int jjMoveNfa_0(int startState, int curPos)
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_2(int pos, long active0)
{
switch (pos)
{
default :
return -1;
}
}
private final int jjStartNfa_2(int pos, long active0)
{
return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
}
private int jjMoveStringLiteralDfa0_2()
{
switch(curChar)
@ -862,18 +848,6 @@ private int jjMoveNfa_2(int startState, int curPos)
catch(java.io.IOException e) { return curPos; }
}
}
private final int jjStopStringLiteralDfa_1(int pos, long active0)
{
switch (pos)
{
default :
return -1;
}
}
private final int jjStartNfa_1(int pos, long active0)
{
return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
}
private int jjMoveStringLiteralDfa0_1()
{
switch(curChar)
@ -989,7 +963,7 @@ private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, lo
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, "\156\165\154\154", "\116\141\116",
"\111\156\146\151\156\151\164\171", null, null, null, null, null, null, null, null, "\42", null, null, null, null,
null, null, null, "\51\135\175\47\12", "\173", "\175", "\54", "\72", "\133", "\135",
null, null, null, "\51\135\175\47\12", "\173", "\54", "\175", "\72", "\133", "\135",
"\55", "\56", };
/** Lexer state names. */

View File

@ -76,7 +76,7 @@ private JsonObject JsonObject() :
JsonObject o = new JsonObject();
}
{
"{" [ Members(o) ] "}"
"{" [ Pair(o) ("," Pair(o))* ] "}"
{ return o; }
}
@ -88,12 +88,6 @@ private JsonNull JsonNull() :
t = <NULL> { return JsonNull.createJsonNull(); }
}
private void Members(JsonObject o) :
{ }
{
Pair(o) [ "," Members(o) ]
}
private void Pair(JsonObject o) :
{
JsonPrimitive property;