From 16be7167ec8470cc6ba24e188b6fd6d70afe109d Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Thu, 5 Mar 2009 23:05:29 +0000 Subject: [PATCH] Updated Gson grammar to support floating point numbers without a +/- after the E. So, 1.234567899E8 is now accepted by Gson as a valid floating point number. This fixed the bug http://code.google.com/p/google-gson/issues/detail?id=94 Also, updated Gson to use Javacc 4.2. --- gson/pom.xml | 6 +- .../java/com/google/gson/JsonParserImpl.java | 196 +++--- .../google/gson/JsonParserImplConstants.java | 62 +- .../gson/JsonParserImplTokenManager.java | 635 ++++++++++-------- gson/src/main/javacc/JsonParser.jj | 21 +- .../google/gson/functional/PrimitiveTest.java | 10 + 6 files changed, 522 insertions(+), 408 deletions(-) diff --git a/gson/pom.xml b/gson/pom.xml index 1a3bd8cb..0557335d 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -38,7 +38,7 @@ Google Code Issue Tracking http://code.google.com/p/google-gson/issues/list - + junit @@ -138,10 +138,10 @@ net.java.dev.javacc javacc - 4.0 + 4.2 - + org.apache.maven.plugins maven-jxr-plugin diff --git a/gson/src/main/java/com/google/gson/JsonParserImpl.java b/gson/src/main/java/com/google/gson/JsonParserImpl.java index cd61b682..4d7cf001 100644 --- a/gson/src/main/java/com/google/gson/JsonParserImpl.java +++ b/gson/src/main/java/com/google/gson/JsonParserImpl.java @@ -7,10 +7,10 @@ final class JsonParserImpl implements JsonParserImplConstants { final public JsonElement parse() throws ParseException { JsonElement json = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 25: + case 26: json = JsonObject(); break; - case 29: + case 30: json = JsonArray(); break; case DIGITS: @@ -19,7 +19,7 @@ final class JsonParserImpl implements JsonParserImplConstants { case BOOLEAN: case SINGLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL: - case 31: + case 32: json = JsonPrimitive(); break; case NULL: @@ -36,9 +36,10 @@ final class JsonParserImpl implements JsonParserImplConstants { final private JsonObject JsonObject() throws ParseException { JsonObject o = new JsonObject(); - jj_consume_token(25); + jj_consume_token(26); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IDENTIFIER: + case IDENTIFIER_SANS_EXPONENT: + case IDENTIFIER_STARTS_WITH_EXPONENT: case SINGLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL: Members(o); @@ -47,7 +48,7 @@ final class JsonParserImpl implements JsonParserImplConstants { jj_la1[1] = jj_gen; ; } - jj_consume_token(26); + jj_consume_token(27); {if (true) return o;} throw new Error("Missing return statement in function"); } @@ -62,8 +63,8 @@ final class JsonParserImpl implements JsonParserImplConstants { final private void Members(JsonObject o) throws ParseException { Pair(o); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 27: - jj_consume_token(27); + case 28: + jj_consume_token(28); Members(o); break; default: @@ -76,7 +77,7 @@ final class JsonParserImpl implements JsonParserImplConstants { JsonPrimitive property; JsonElement value; property = JsonMemberName(); - jj_consume_token(28); + jj_consume_token(29); value = JsonValue(); o.add(property.getAsString(), value); } @@ -84,9 +85,10 @@ final class JsonParserImpl implements JsonParserImplConstants { final private JsonPrimitive JsonMemberName() throws ParseException { Token t; JsonPrimitive value; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case IDENTIFIER: - t = jj_consume_token(IDENTIFIER); - {if (true) return new JsonPrimitive(t.image);} + 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: @@ -103,7 +105,7 @@ final class JsonParserImpl implements JsonParserImplConstants { final private JsonArray JsonArray() throws ParseException { JsonArray array = new JsonArray(); - jj_consume_token(29); + jj_consume_token(30); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DIGITS: case NULL: @@ -112,16 +114,16 @@ final class JsonParserImpl implements JsonParserImplConstants { case BOOLEAN: case SINGLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL: - case 25: - case 29: - case 31: + case 26: + case 30: + case 32: Elements(array); break; default: jj_la1[4] = jj_gen; ; } - jj_consume_token(30); + jj_consume_token(31); array.reverse(); {if (true) return array;} throw new Error("Missing return statement in function"); @@ -131,8 +133,8 @@ final class JsonParserImpl implements JsonParserImplConstants { JsonElement element; element = JsonValue(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 27: - jj_consume_token(27); + case 28: + jj_consume_token(28); Elements(array); break; default: @@ -152,13 +154,13 @@ final class JsonParserImpl implements JsonParserImplConstants { case DIGITS: case NAN: case INFINITY: - case 31: + case 32: o = JsonNumber(); break; - case 25: + case 26: o = JsonObject(); break; - case 29: + case 30: o = JsonArray(); break; case BOOLEAN: @@ -195,7 +197,7 @@ final class JsonParserImpl implements JsonParserImplConstants { case DIGITS: case NAN: case INFINITY: - case 31: + case 32: value = JsonNumber(); {if (true) return value;} break; @@ -222,10 +224,10 @@ final class JsonParserImpl implements JsonParserImplConstants { } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DIGITS: - case 31: + case 32: intpart = JsonInt(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 32: + case 33: fracpart = JsonFrac(); break; default: @@ -233,7 +235,7 @@ final class JsonParserImpl implements JsonParserImplConstants { ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case E: + case EXPONENT: exppart = JsonExp(); break; default: @@ -267,10 +269,10 @@ final class JsonParserImpl implements JsonParserImplConstants { {if (true) return new JsonPrimitive(Double.NaN);} break; case INFINITY: - case 31: + case 32: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 31: - jj_consume_token(31); + case 32: + jj_consume_token(32); negative = true; break; default: @@ -292,8 +294,8 @@ final class JsonParserImpl implements JsonParserImplConstants { String digits; boolean negative = false; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 31: - jj_consume_token(31); + case 32: + jj_consume_token(32); negative = true; break; default: @@ -309,7 +311,7 @@ final class JsonParserImpl implements JsonParserImplConstants { final private String JsonFrac() throws ParseException { String digits; - jj_consume_token(32); + jj_consume_token(33); digits = Digits(); {if (true) return "." + digits;} throw new Error("Missing return statement in function"); @@ -317,10 +319,26 @@ final class JsonParserImpl implements JsonParserImplConstants { final private String JsonExp() throws ParseException { Token t; - String digits; - t = jj_consume_token(E); - digits = Digits(); - {if (true) return t.image + digits;} + 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[14] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return t;} throw new Error("Missing return statement in function"); } @@ -341,7 +359,7 @@ final class JsonParserImpl implements JsonParserImplConstants { t = jj_consume_token(DOUBLE_QUOTE_LITERAL); break; default: - jj_la1[14] = jj_gen; + jj_la1[15] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -350,19 +368,19 @@ final class JsonParserImpl implements JsonParserImplConstants { throw new Error("Missing return statement in function"); } - final private boolean jj_2_1(int xla) { + 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); } } - final private boolean jj_3R_4() { - if (jj_scan_token(31)) return true; + private boolean jj_3R_4() { + if (jj_scan_token(32)) return true; return false; } - final private boolean jj_3R_3() { + private boolean jj_3R_3() { Token xsp; xsp = jj_scanpos; if (jj_3R_4()) jj_scanpos = xsp; @@ -370,17 +388,17 @@ final class JsonParserImpl implements JsonParserImplConstants { return false; } - final private boolean jj_3_1() { + private boolean jj_3_1() { if (jj_3R_1()) return true; return false; } - final private boolean jj_3R_2() { + private boolean jj_3R_2() { if (jj_scan_token(NAN)) return true; return false; } - final private boolean jj_3R_1() { + private boolean jj_3R_1() { Token xsp; xsp = jj_scanpos; if (jj_3R_2()) { @@ -390,97 +408,107 @@ final class JsonParserImpl implements JsonParserImplConstants { return false; } + /** Generated Token Manager. */ public JsonParserImplTokenManager token_source; SimpleCharStream jj_input_stream; - public Token token, jj_nt; + /** 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; - public boolean lookingAhead = false; - private boolean jj_semLA; private int jj_gen; - final private int[] jj_la1 = new int[15]; + final private int[] jj_la1 = new int[16]; static private int[] jj_la1_0; static private int[] jj_la1_1; static { - jj_la1_0(); - jj_la1_1(); + jj_la1_init_0(); + jj_la1_init_1(); } - private static void jj_la1_0() { - jj_la1_0 = new int[] {0xa20187c0,0x18800,0x8000000,0x18800,0xa20187c0,0x8000000,0xa20187c0,0x80018740,0x0,0x20,0x80000040,0x80000000,0x80000300,0x80000000,0x18000,}; + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x440307c0,0x31800,0x10000000,0x31800,0x440307c0,0x10000000,0x440307c0,0x30740,0x0,0x20,0x40,0x0,0x300,0x0,0x1800,0x30000,}; } - private static void jj_la1_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,}; + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0x1,0x0,0x0,0x0,0x1,0x0,0x1,0x1,0x2,0x0,0x1,0x1,0x1,0x1,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 JsonParserImpl(java.io.InputStream stream) { this(stream, null); } + /** Constructor with InputStream and supplied encoding */ public JsonParserImpl(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 JsonParserImplTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; 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 < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Constructor. */ public JsonParserImpl(java.io.Reader stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new JsonParserImplTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; 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 < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; 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 JsonParserImpl(JsonParserImplTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; 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(JsonParserImplTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 15; i++) jj_la1[i] = -1; + for (int i = 0; i < 16; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } - final private Token jj_consume_token(int kind) throws ParseException { + 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(); @@ -506,7 +534,7 @@ final class JsonParserImpl implements JsonParserImplConstants { static private final class LookaheadSuccess extends java.lang.Error { } final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - final private boolean jj_scan_token(int kind) { + private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { @@ -527,6 +555,8 @@ final class JsonParserImpl implements JsonParserImplConstants { return false; } + +/** Get the next Token. */ final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); @@ -535,8 +565,9 @@ final class JsonParserImpl implements JsonParserImplConstants { return token; } +/** Get the specific Token. */ final public Token getToken(int index) { - Token t = lookingAhead ? jj_scanpos : token; + Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); @@ -544,14 +575,14 @@ final class JsonParserImpl implements JsonParserImplConstants { return t; } - final private int jj_ntk() { + 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.Vector jj_expentries = new java.util.Vector(); + 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]; @@ -566,36 +597,31 @@ final class JsonParserImpl implements JsonParserImplConstants { for (int i = 0; i < jj_endpos; i++) { jj_expentry[i] = jj_lasttokens[i]; } - boolean exists = false; - for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) { - int[] oldentry = (int[])(e.nextElement()); + jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { + int[] oldentry = (int[])(it.next()); if (oldentry.length == jj_expentry.length) { - exists = true; for (int i = 0; i < jj_expentry.length; i++) { if (oldentry[i] != jj_expentry[i]) { - exists = false; - break; + continue jj_entries_loop; } } - if (exists) break; + jj_expentries.add(jj_expentry); + break jj_entries_loop; } } - if (!exists) jj_expentries.addElement(jj_expentry); if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; } } + /** Generate ParseException. */ public ParseException generateParseException() { - jj_expentries.removeAllElements(); - boolean[] la1tokens = new boolean[33]; - for (int i = 0; i < 33; i++) { - la1tokens[i] = false; - } + jj_expentries.clear(); + boolean[] la1tokens = new boolean[34]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 15; i++) { + for (int i = 0; i < 16; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } diff --git a/gson/src/main/java/com/google/gson/JsonParserImplConstants.java b/gson/src/main/java/com/google/gson/JsonParserImplConstants.java index 1d2d419a..18c8cd9f 100644 --- a/gson/src/main/java/com/google/gson/JsonParserImplConstants.java +++ b/gson/src/main/java/com/google/gson/JsonParserImplConstants.java @@ -1,47 +1,79 @@ /* Generated By:JavaCC: Do not edit this line. JsonParserImplConstants.java */ package com.google.gson; + +/** + * Token literal values and constants. + * Generated by org.javacc.parser.OtherFilesGen#start() + */ @SuppressWarnings("all") interface JsonParserImplConstants { + /** End of File. */ int EOF = 0; - int E = 5; + /** 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; - int IDENTIFIER = 11; - int HEX_CHAR = 12; - int UNICODE_CHAR = 13; - int ESCAPE_CHAR = 14; - int SINGLE_QUOTE_LITERAL = 15; - int DOUBLE_QUOTE_LITERAL = 16; - int QUOTE = 17; - int ENDQUOTE = 19; - int CHAR = 20; - int CNTRL_ESC = 21; - int HEX = 23; - int HEX_ESC = 24; + /** 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 = { "", "\" \"", "\"\\t\"", "\"\\n\"", "\"\\r\"", - "", + "", "", "\"null\"", "\"NaN\"", "\"Infinity\"", "", - "", + "", + "", "", "", "", diff --git a/gson/src/main/java/com/google/gson/JsonParserImplTokenManager.java b/gson/src/main/java/com/google/gson/JsonParserImplTokenManager.java index f850ef7b..62574800 100644 --- a/gson/src/main/java/com/google/gson/JsonParserImplTokenManager.java +++ b/gson/src/main/java/com/google/gson/JsonParserImplTokenManager.java @@ -1,53 +1,26 @@ /* Generated By:JavaCC: Do not edit this line. JsonParserImplTokenManager.java */ package com.google.gson; +/** Token Manager. */ @SuppressWarnings("all") final class JsonParserImplTokenManager implements JsonParserImplConstants { + + /** Debug output. */ public java.io.PrintStream debugStream = System.out; + /** Set debug output. */ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -private final int jjMoveStringLiteralDfa0_3() +private int jjMoveStringLiteralDfa0_3() { return jjMoveNfa_3(0, 0); } -private final void jjCheckNAdd(int state) +private int jjMoveNfa_3(int startState, int curPos) { - if (jjrounds[state] != jjround) - { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } -} -private final void jjAddStates(int start, int end) -{ - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); -} -private final void jjCheckNAddTwoStates(int state1, int state2) -{ - jjCheckNAdd(state1); - jjCheckNAdd(state2); -} -private final void jjCheckNAddStates(int start, int end) -{ - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); -} -private final void jjCheckNAddStates(int start) -{ - jjCheckNAdd(jjnextStates[start]); - jjCheckNAdd(jjnextStates[start + 1]); -} -private final int jjMoveNfa_3(int startState, int curPos) -{ - int[] nextStates; int startsAt = 0; jjnewStateCnt = 4; int i = 1; jjstateSet[0] = startState; - int j, kind = 0x7fffffff; + int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) @@ -55,7 +28,7 @@ private final int jjMoveNfa_3(int startState, int curPos) if (curChar < 64) { long l = 1L << curChar; - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -72,8 +45,8 @@ private final int jjMoveNfa_3(int startState, int curPos) jjstateSet[jjnewStateCnt++] = 3; break; case 3: - if ((0x3ff000000000000L & l) != 0L && kind > 24) - kind = 24; + if ((0x3ff000000000000L & l) != 0L && kind > 25) + kind = 25; break; default : break; } @@ -82,7 +55,7 @@ private final int jjMoveNfa_3(int startState, int curPos) else if (curChar < 128) { long l = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -99,8 +72,8 @@ private final int jjMoveNfa_3(int startState, int curPos) jjstateSet[jjnewStateCnt++] = 3; break; case 3: - if ((0x7e0000007eL & l) != 0L && kind > 24) - kind = 24; + if ((0x7e0000007eL & l) != 0L && kind > 25) + kind = 25; break; default : break; } @@ -113,7 +86,7 @@ private final int jjMoveNfa_3(int startState, int curPos) long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -142,37 +115,37 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0) if ((active0 & 0x380L) != 0L) { jjmatchedKind = 11; - return 12; + return 10; } - if ((active0 & 0x20000L) != 0L) - return 41; + if ((active0 & 0x40000L) != 0L) + return 43; return -1; case 1: if ((active0 & 0x380L) != 0L) { jjmatchedKind = 11; jjmatchedPos = 1; - return 12; + return 10; } return -1; case 2: if ((active0 & 0x100L) != 0L) - return 12; + return 10; if ((active0 & 0x280L) != 0L) { jjmatchedKind = 11; jjmatchedPos = 2; - return 12; + return 10; } return -1; case 3: if ((active0 & 0x80L) != 0L) - return 12; + return 10; if ((active0 & 0x200L) != 0L) { jjmatchedKind = 11; jjmatchedPos = 3; - return 12; + return 10; } return -1; case 4: @@ -180,7 +153,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0) { jjmatchedKind = 11; jjmatchedPos = 4; - return 12; + return 10; } return -1; case 5: @@ -188,7 +161,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0) { jjmatchedKind = 11; jjmatchedPos = 5; - return 12; + return 10; } return -1; case 6: @@ -196,7 +169,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0) { jjmatchedKind = 11; jjmatchedPos = 6; - return 12; + return 10; } return -1; default : @@ -207,53 +180,45 @@ private final int jjStartNfa_0(int pos, long active0) { return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); } -private final int jjStopAtPos(int pos, int kind) +private int jjStopAtPos(int pos, int kind) { jjmatchedKind = kind; jjmatchedPos = pos; return pos + 1; } -private final int jjStartNfaWithStates_0(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_0(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_0() +private int jjMoveStringLiteralDfa0_0() { switch(curChar) { case 34: - return jjStartNfaWithStates_0(0, 17, 41); + return jjStartNfaWithStates_0(0, 18, 43); case 44: - return jjStopAtPos(0, 27); - case 45: - return jjStopAtPos(0, 31); - case 46: - return jjStopAtPos(0, 32); - case 58: return jjStopAtPos(0, 28); + case 45: + return jjStopAtPos(0, 32); + case 46: + return jjStopAtPos(0, 33); + case 58: + return jjStopAtPos(0, 29); case 73: return jjMoveStringLiteralDfa1_0(0x200L); case 78: return jjMoveStringLiteralDfa1_0(0x100L); case 91: - return jjStopAtPos(0, 29); - case 93: return jjStopAtPos(0, 30); + case 93: + return jjStopAtPos(0, 31); case 110: return jjMoveStringLiteralDfa1_0(0x80L); case 123: - return jjStopAtPos(0, 25); - case 125: return jjStopAtPos(0, 26); + case 125: + return jjStopAtPos(0, 27); default : - return jjMoveNfa_0(0, 0); + return jjMoveNfa_0(4, 0); } } -private final int jjMoveStringLiteralDfa1_0(long active0) +private int jjMoveStringLiteralDfa1_0(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { @@ -273,10 +238,10 @@ private final int jjMoveStringLiteralDfa1_0(long active0) } return jjStartNfa_0(0, active0); } -private final int jjMoveStringLiteralDfa2_0(long old0, long active0) +private int jjMoveStringLiteralDfa2_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(0, old0); + return jjStartNfa_0(0, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(1, active0); @@ -286,7 +251,7 @@ private final int jjMoveStringLiteralDfa2_0(long old0, long active0) { case 78: if ((active0 & 0x100L) != 0L) - return jjStartNfaWithStates_0(2, 8, 12); + return jjStartNfaWithStates_0(2, 8, 10); break; case 102: return jjMoveStringLiteralDfa3_0(active0, 0x200L); @@ -297,10 +262,10 @@ private final int jjMoveStringLiteralDfa2_0(long old0, long active0) } return jjStartNfa_0(1, active0); } -private final int jjMoveStringLiteralDfa3_0(long old0, long active0) +private int jjMoveStringLiteralDfa3_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(1, old0); + return jjStartNfa_0(1, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(2, active0); @@ -312,17 +277,17 @@ private final int jjMoveStringLiteralDfa3_0(long old0, long active0) return jjMoveStringLiteralDfa4_0(active0, 0x200L); case 108: if ((active0 & 0x80L) != 0L) - return jjStartNfaWithStates_0(3, 7, 12); + return jjStartNfaWithStates_0(3, 7, 10); break; default : break; } return jjStartNfa_0(2, active0); } -private final int jjMoveStringLiteralDfa4_0(long old0, long active0) +private int jjMoveStringLiteralDfa4_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(2, old0); + return jjStartNfa_0(2, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(3, active0); @@ -337,10 +302,10 @@ private final int jjMoveStringLiteralDfa4_0(long old0, long active0) } return jjStartNfa_0(3, active0); } -private final int jjMoveStringLiteralDfa5_0(long old0, long active0) +private int jjMoveStringLiteralDfa5_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(3, old0); + return jjStartNfa_0(3, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(4, active0); @@ -355,10 +320,10 @@ private final int jjMoveStringLiteralDfa5_0(long old0, long active0) } return jjStartNfa_0(4, active0); } -private final int jjMoveStringLiteralDfa6_0(long old0, long active0) +private int jjMoveStringLiteralDfa6_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(4, old0); + return jjStartNfa_0(4, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(5, active0); @@ -373,10 +338,10 @@ private final int jjMoveStringLiteralDfa6_0(long old0, long active0) } return jjStartNfa_0(5, active0); } -private final int jjMoveStringLiteralDfa7_0(long old0, long active0) +private int jjMoveStringLiteralDfa7_0(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(5, old0); + return jjStartNfa_0(5, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(6, active0); @@ -386,27 +351,34 @@ private final int jjMoveStringLiteralDfa7_0(long old0, long active0) { case 121: if ((active0 & 0x200L) != 0L) - return jjStartNfaWithStates_0(7, 9, 12); + return jjStartNfaWithStates_0(7, 9, 10); break; default : break; } return jjStartNfa_0(6, active0); } +private int jjStartNfaWithStates_0(int pos, int kind, int state) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return pos + 1; } + return jjMoveNfa_0(state, pos + 1); +} static final long[] jjbitVec0 = { 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec2 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; -private final int jjMoveNfa_0(int startState, int curPos) +private int jjMoveNfa_0(int startState, int curPos) { - int[] nextStates; int startsAt = 0; - jjnewStateCnt = 41; + jjnewStateCnt = 43; int i = 1; jjstateSet[0] = startState; - int j, kind = 0x7fffffff; + int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) @@ -414,128 +386,145 @@ private final int jjMoveNfa_0(int startState, int curPos) if (curChar < 64) { long l = 1L << curChar; - MatchLoop: do + do { switch(jjstateSet[--i]) { - case 41: + case 43: if ((0xfffffffbffffdbffL & l) != 0L) jjCheckNAddStates(0, 3); else if (curChar == 34) { - if (kind > 16) - kind = 16; + if (kind > 17) + kind = 17; } break; - case 0: + case 4: if ((0x3ff000000000000L & l) != 0L) { if (kind > 6) kind = 6; - jjCheckNAdd(2); + jjCheckNAdd(0); } else if (curChar == 34) jjCheckNAddStates(0, 3); else if (curChar == 39) jjCheckNAddStates(4, 7); break; - case 1: - if ((0x280000000000L & l) != 0L && kind > 5) - kind = 5; - break; - case 2: + case 0: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 6) kind = 6; - jjCheckNAdd(2); + jjCheckNAdd(0); break; - case 12: + case 10: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 11) kind = 11; - jjstateSet[jjnewStateCnt++] = 12; + jjstateSet[jjnewStateCnt++] = 10; + break; + case 12: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 13; + break; + case 13: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 14; break; case 14: if ((0x3ff000000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 15; break; case 15: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 16; - break; - case 16: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 17; + if ((0x3ff000000000000L & l) != 0L && kind > 14) + kind = 14; break; case 17: - if ((0x3ff000000000000L & l) != 0L && kind > 13) - kind = 13; - break; - case 19: if (curChar == 39) jjCheckNAddStates(4, 7); break; - case 20: + case 18: if ((0xffffff7fffffdbffL & l) != 0L) jjCheckNAddStates(4, 7); break; - case 22: + case 20: if ((0x808400000000L & l) != 0L) jjCheckNAddStates(4, 7); break; + case 22: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 23; + break; + case 23: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 24; + break; case 24: if ((0x3ff000000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 25; break; case 25: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 26; - break; - case 26: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 27; - break; - case 27: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(4, 7); break; - case 29: - if (curChar == 39 && kind > 15) - kind = 15; + case 27: + if (curChar == 39 && kind > 16) + kind = 16; break; - case 30: + case 28: if (curChar == 34) jjCheckNAddStates(0, 3); break; - case 31: + case 29: if ((0xfffffffbffffdbffL & l) != 0L) jjCheckNAddStates(0, 3); break; - case 33: + case 31: if ((0x808400000000L & l) != 0L) jjCheckNAddStates(0, 3); break; + case 33: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 34; + break; + case 34: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 35; + break; case 35: if ((0x3ff000000000000L & l) != 0L) jjstateSet[jjnewStateCnt++] = 36; break; case 36: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 37; - break; - case 37: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 38; - break; - case 38: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(0, 3); break; + case 38: + if (curChar == 34 && kind > 17) + kind = 17; + break; case 40: - if (curChar == 34 && kind > 16) - kind = 16; + if ((0x3ff280000000000L & l) == 0L) + break; + if (kind > 5) + kind = 5; + jjCheckNAdd(41); + break; + case 41: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 5) + kind = 5; + jjCheckNAdd(41); + break; + case 42: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 12) + kind = 12; + jjstateSet[jjnewStateCnt++] = 42; break; default : break; } @@ -544,80 +533,90 @@ private final int jjMoveNfa_0(int startState, int curPos) else if (curChar < 128) { long l = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { - case 41: + case 43: if ((0xffffffffefffffffL & l) != 0L) jjCheckNAddStates(0, 3); else if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 34; + jjstateSet[jjnewStateCnt++] = 32; if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 33; + jjstateSet[jjnewStateCnt++] = 31; break; - case 0: - if ((0x7fffffe87fffffeL & l) != 0L) + case 4: + if ((0x7ffffde87ffffdeL & l) != 0L) { if (kind > 11) kind = 11; - jjCheckNAdd(12); + jjCheckNAdd(10); + } + else if ((0x2000000020L & l) != 0L) + { + if (kind > 12) + kind = 12; + jjCheckNAddTwoStates(40, 42); } else if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 13; - if ((0x2000000020L & l) != 0L) - { - if (kind > 5) - kind = 5; - jjstateSet[jjnewStateCnt++] = 1; - } - else if (curChar == 102) - jjstateSet[jjnewStateCnt++] = 9; + jjstateSet[jjnewStateCnt++] = 11; + if (curChar == 102) + jjstateSet[jjnewStateCnt++] = 7; else if (curChar == 116) - jjstateSet[jjnewStateCnt++] = 5; + jjstateSet[jjnewStateCnt++] = 3; break; - case 3: + case 1: if (curChar == 101 && kind > 10) kind = 10; break; - case 4: + case 2: if (curChar == 117) - jjCheckNAdd(3); + jjCheckNAdd(1); + break; + case 3: + if (curChar == 114) + jjstateSet[jjnewStateCnt++] = 2; break; case 5: - if (curChar == 114) - jjstateSet[jjnewStateCnt++] = 4; + if (curChar == 115) + jjCheckNAdd(1); break; case 6: - if (curChar == 116) + if (curChar == 108) jjstateSet[jjnewStateCnt++] = 5; break; case 7: - if (curChar == 115) - jjCheckNAdd(3); + if (curChar == 97) + jjstateSet[jjnewStateCnt++] = 6; break; case 8: - if (curChar == 108) + if (curChar == 102) jjstateSet[jjnewStateCnt++] = 7; break; case 9: - if (curChar == 97) - jjstateSet[jjnewStateCnt++] = 8; + if ((0x7ffffde87ffffdeL & l) == 0L) + break; + if (kind > 11) + kind = 11; + jjCheckNAdd(10); break; case 10: - if (curChar == 102) - jjstateSet[jjnewStateCnt++] = 9; - break; - case 11: - case 12: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 11) kind = 11; - jjCheckNAdd(12); + jjCheckNAdd(10); + break; + case 11: + if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 12; + break; + case 12: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 13; break; case 13: - if (curChar == 117) + if ((0x7e0000007eL & l) != 0L) jjstateSet[jjnewStateCnt++] = 14; break; case 14: @@ -625,35 +624,35 @@ private final int jjMoveNfa_0(int startState, int curPos) jjstateSet[jjnewStateCnt++] = 15; break; case 15: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 16; + if ((0x7e0000007eL & l) != 0L && kind > 14) + kind = 14; break; case 16: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 17; - break; - case 17: - if ((0x7e0000007eL & l) != 0L && kind > 13) - kind = 13; + if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 11; break; case 18: - if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 13; - break; - case 20: if ((0xffffffffefffffffL & l) != 0L) jjCheckNAddStates(4, 7); break; - case 21: + case 19: if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 22; + jjstateSet[jjnewStateCnt++] = 20; break; - case 22: + case 20: if ((0x14404410000000L & l) != 0L) jjCheckNAddStates(4, 7); break; - case 23: + case 21: if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 22; + break; + case 22: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 23; + break; + case 23: + if ((0x7e0000007eL & l) != 0L) jjstateSet[jjnewStateCnt++] = 24; break; case 24: @@ -661,35 +660,35 @@ private final int jjMoveNfa_0(int startState, int curPos) jjstateSet[jjnewStateCnt++] = 25; break; case 25: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 26; - break; - case 26: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 27; - break; - case 27: if ((0x7e0000007eL & l) != 0L) jjCheckNAddStates(4, 7); break; - case 28: + case 26: if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 23; + jjstateSet[jjnewStateCnt++] = 21; break; - case 31: + case 29: if ((0xffffffffefffffffL & l) != 0L) jjCheckNAddStates(0, 3); break; - case 32: + case 30: if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 33; + jjstateSet[jjnewStateCnt++] = 31; break; - case 33: + case 31: if ((0x14404410000000L & l) != 0L) jjCheckNAddStates(0, 3); break; - case 34: + case 32: if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 33; + break; + case 33: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 34; + break; + case 34: + if ((0x7e0000007eL & l) != 0L) jjstateSet[jjnewStateCnt++] = 35; break; case 35: @@ -697,20 +696,26 @@ private final int jjMoveNfa_0(int startState, int curPos) jjstateSet[jjnewStateCnt++] = 36; break; case 36: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 37; - break; - case 37: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 38; - break; - case 38: if ((0x7e0000007eL & l) != 0L) jjCheckNAddStates(0, 3); break; - case 39: + case 37: if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 34; + jjstateSet[jjnewStateCnt++] = 32; + break; + case 39: + if ((0x2000000020L & l) == 0L) + break; + if (kind > 12) + kind = 12; + jjCheckNAddTwoStates(40, 42); + break; + case 42: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 12) + kind = 12; + jjCheckNAdd(42); break; default : break; } @@ -723,16 +728,16 @@ private final int jjMoveNfa_0(int startState, int curPos) long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { - case 41: - case 31: + case 43: + case 29: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjCheckNAddStates(0, 3); break; - case 20: + case 18: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjAddStates(4, 7); break; @@ -747,7 +752,7 @@ private final int jjMoveNfa_0(int startState, int curPos) kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 41 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 43 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } @@ -765,32 +770,23 @@ private final int jjStartNfa_2(int pos, long active0) { return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); } -private final int jjStartNfaWithStates_2(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_2(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_2() +private int jjMoveStringLiteralDfa0_2() { switch(curChar) { case 117: - return jjStopAtPos(0, 22); + return jjStopAtPos(0, 23); default : return jjMoveNfa_2(0, 0); } } -private final int jjMoveNfa_2(int startState, int curPos) +private int jjMoveNfa_2(int startState, int curPos) { - int[] nextStates; int startsAt = 0; jjnewStateCnt = 1; int i = 1; jjstateSet[0] = startState; - int j, kind = 0x7fffffff; + int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) @@ -798,13 +794,13 @@ private final int jjMoveNfa_2(int startState, int curPos) if (curChar < 64) { long l = 1L << curChar; - MatchLoop: do + do { switch(jjstateSet[--i]) { case 0: if ((0x800400000000L & l) != 0L) - kind = 21; + kind = 22; break; default : break; } @@ -813,13 +809,13 @@ private final int jjMoveNfa_2(int startState, int curPos) else if (curChar < 128) { long l = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { case 0: if ((0x14404410000000L & l) != 0L) - kind = 21; + kind = 22; break; default : break; } @@ -832,7 +828,7 @@ private final int jjMoveNfa_2(int startState, int curPos) long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -865,32 +861,23 @@ private final int jjStartNfa_1(int pos, long active0) { return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1); } -private final int jjStartNfaWithStates_1(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_1(state, pos + 1); -} -private final int jjMoveStringLiteralDfa0_1() +private int jjMoveStringLiteralDfa0_1() { switch(curChar) { case 92: - return jjStopAtPos(0, 18); + return jjStopAtPos(0, 19); default : return jjMoveNfa_1(0, 0); } } -private final int jjMoveNfa_1(int startState, int curPos) +private int jjMoveNfa_1(int startState, int curPos) { - int[] nextStates; int startsAt = 0; jjnewStateCnt = 2; int i = 1; jjstateSet[0] = startState; - int j, kind = 0x7fffffff; + int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) @@ -898,25 +885,25 @@ private final int jjMoveNfa_1(int startState, int curPos) if (curChar < 64) { long l = 1L << curChar; - MatchLoop: do + do { switch(jjstateSet[--i]) { case 0: if ((0xfffffffbffffffffL & l) != 0L) { - if (kind > 20) - kind = 20; + if (kind > 21) + kind = 21; } else if (curChar == 34) { - if (kind > 19) - kind = 19; + if (kind > 20) + kind = 20; } break; case 1: if ((0xfffffffbffffffffL & l) != 0L) - kind = 20; + kind = 21; break; default : break; } @@ -925,13 +912,13 @@ private final int jjMoveNfa_1(int startState, int curPos) else if (curChar < 128) { long l = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { case 0: if ((0xffffffffefffffffL & l) != 0L) - kind = 20; + kind = 21; break; default : break; } @@ -944,13 +931,13 @@ private final int jjMoveNfa_1(int startState, int curPos) long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { case 0: - if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 20) - kind = 20; + if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 21) + kind = 21; break; default : break; } @@ -970,7 +957,7 @@ private final int jjMoveNfa_1(int startState, int curPos) } } static final int[] jjnextStates = { - 31, 32, 39, 40, 20, 21, 28, 29, + 29, 30, 37, 38, 18, 19, 26, 27, }; private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { @@ -978,48 +965,59 @@ private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, lo { case 0: return ((jjbitVec2[i2] & l2) != 0L); - default : + default : if ((jjbitVec0[i1] & l1) != 0L) return true; return false; } } + +/** Token literal values. */ 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, "\42", null, null, null, null, null, -null, null, "\173", "\175", "\54", "\72", "\133", "\135", "\55", "\56", }; +"\111\156\146\151\156\151\164\171", null, null, null, null, null, null, null, null, "\42", null, null, null, null, +null, null, null, "\173", "\175", "\54", "\72", "\133", "\135", "\55", "\56", }; + +/** Lexer state names. */ public static final String[] lexStateNames = { - "DEFAULT", - "STRING_STATE", - "ESC_STATE", - "HEX_STATE", + "DEFAULT", + "STRING_STATE", + "ESC_STATE", + "HEX_STATE", }; + +/** Lex State array. */ public static final int[] jjnewLexState = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 0, -1, 1, 3, -1, 1, - -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 0, -1, 1, 3, -1, + 1, -1, -1, -1, -1, -1, -1, -1, -1, }; static final long[] jjtoToken = { - 0x1ff3bafe1L, + 0x3fe775fe1L, }; static final long[] jjtoSkip = { 0x1eL, }; static final long[] jjtoMore = { - 0x440000L, + 0x880000L, }; protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[41]; -private final int[] jjstateSet = new int[82]; +private final int[] jjrounds = new int[43]; +private final int[] jjstateSet = new int[86]; protected char curChar; +/** Constructor. */ public JsonParserImplTokenManager(SimpleCharStream stream){ if (SimpleCharStream.staticFlag) throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); input_stream = stream; } + +/** Constructor. */ public JsonParserImplTokenManager(SimpleCharStream stream, int lexState){ this(stream); SwitchTo(lexState); } + +/** Reinitialise parser. */ public void ReInit(SimpleCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; @@ -1027,18 +1025,22 @@ public void ReInit(SimpleCharStream stream) input_stream = stream; ReInitRounds(); } -private final void ReInitRounds() +private void ReInitRounds() { int i; jjround = 0x80000001; - for (i = 41; i-- > 0;) + for (i = 43; i-- > 0;) jjrounds[i] = 0x80000000; } + +/** Reinitialise parser. */ public void ReInit(SimpleCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } + +/** Switch to specified lex state. */ public void SwitchTo(int lexState) { if (lexState >= 4 || lexState < 0) @@ -1049,14 +1051,27 @@ public void SwitchTo(int lexState) protected Token jjFillToken() { - Token t = Token.newToken(jjmatchedKind); - t.kind = jjmatchedKind; + final Token t; + final String curTokenImage; + final int beginLine; + final int endLine; + final int beginColumn; + final int endColumn; String im = jjstrLiteralImages[jjmatchedKind]; - t.image = (im == null) ? input_stream.GetImage() : im; - t.beginLine = input_stream.getBeginLine(); - t.beginColumn = input_stream.getBeginColumn(); - t.endLine = input_stream.getEndLine(); - t.endColumn = input_stream.getEndColumn(); + curTokenImage = (im == null) ? input_stream.GetImage() : im; + beginLine = input_stream.getBeginLine(); + beginColumn = input_stream.getBeginColumn(); + endLine = input_stream.getEndLine(); + endColumn = input_stream.getEndColumn(); + t = Token.newToken(jjmatchedKind); + t.kind = jjmatchedKind; + t.image = curTokenImage; + + t.beginLine = beginLine; + t.endLine = endLine; + t.beginColumn = beginColumn; + t.endColumn = endColumn; + return t; } @@ -1067,22 +1082,21 @@ int jjround; int jjmatchedPos; int jjmatchedKind; +/** Get the next Token. */ public Token getNextToken() { - int kind; - Token specialToken = null; Token matchedToken; int curPos = 0; EOFLoop : for (;;) - { - try - { + { + try + { curChar = input_stream.BeginToken(); - } + } catch(java.io.IOException e) - { + { jjmatchedKind = 0; matchedToken = jjFillToken(); return matchedToken; @@ -1169,4 +1183,31 @@ public Token getNextToken() } } +private void jjCheckNAdd(int state) +{ + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } +} +private void jjAddStates(int start, int end) +{ + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); +} +private void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} + +private void jjCheckNAddStates(int start, int end) +{ + do { + jjCheckNAdd(jjnextStates[start]); + } while (start++ != end); +} + } diff --git a/gson/src/main/javacc/JsonParser.jj b/gson/src/main/javacc/JsonParser.jj index afd4a94f..21e9abc1 100755 --- a/gson/src/main/javacc/JsonParser.jj +++ b/gson/src/main/javacc/JsonParser.jj @@ -26,13 +26,14 @@ SKIP : { " " | "\t" | "\n" | "\r" } * will allow that. */ TOKEN : { - + | | | | | - | + | + | | <#HEX_CHAR : ["a"-"f","A"-"F","0"-"9"]> | > | <#ESCAPE_CHAR: "\\" ["n","t","b","r","f","\\","'","\"", "/"] > @@ -104,7 +105,7 @@ private void Pair(JsonObject o) : private JsonPrimitive JsonMemberName() : { Token t; JsonPrimitive value; } { - t= { return new JsonPrimitive(t.image); } | + t= Identifier() { return new JsonPrimitive(t.image); } | value=JsonString() { return value; } } @@ -213,14 +214,16 @@ private String JsonFrac() : } private String JsonExp() : +{ Token t; } { - Token t; - String digits; -} + t = {return t.image;} +} + +private Token Identifier() : +{ Token t; } { - t= digits=Digits() - { return t.image + digits; } -} + (t = | t = ) {return t;} +} private String Digits() : { Token t; } diff --git a/gson/src/test/java/com/google/gson/functional/PrimitiveTest.java b/gson/src/test/java/com/google/gson/functional/PrimitiveTest.java index b62fdb91..c81285d2 100644 --- a/gson/src/test/java/com/google/gson/functional/PrimitiveTest.java +++ b/gson/src/test/java/com/google/gson/functional/PrimitiveTest.java @@ -205,6 +205,16 @@ public class PrimitiveTest extends TestCase { assertEquals(expected.doubleValue(), actual1); } + public void testLargeDoubleDeserialization() { + String doubleValue = "1.234567899E8"; + Double expected = Double.valueOf(doubleValue); + Double actual = gson.fromJson(doubleValue, Double.class); + assertEquals(expected, actual); + + double actual1 = gson.fromJson(doubleValue, double.class); + assertEquals(expected.doubleValue(), actual1); + } + public void testPrimitiveDoubleAutoboxedInASingleElementArrayDeserialization() { double expected = -122.08; double actual = gson.fromJson("[-122.08]", double.class);