/* Generated By:JavaCC: Do not edit this line. JsonParserGenerate.java */
package net.sf.sojo.interchange.json.generate;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import net.sf.sojo.interchange.json.JsonWalkerInterceptor;
public class JsonParserGenerate implements JsonParserGenerateConstants {
protected static boolean printValues = false;
public static void main(String args[]) throws ParseException {
try {
JsonParserGenerate parser = new JsonParserGenerate(System.in);
Object ret = new Object();
while (ret != null) {
ret = parser.parse();
}
System.exit (0);
} catch (ParseException e) {
e.printStackTrace();
}
}
public static void setInputStream(java.io.InputStream stream) {
new JsonParserGenerate(stream);
}
public static void setPrintValues (boolean pvPrint) {
printValues = pvPrint;
}
final public Object parse() throws ParseException, ParseException {
Object value;
try {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EOL:
jj_consume_token(EOL);
{if (true) return null;}
break;
case TRUE:
case FALSE:
case NULL:
case NUMBER:
case STRING:
case 19:
case 23:
value = value();
if (printValues) {
System.out.println("==> RESULT: " + value);
}
{if (true) return value;}
break;
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
} catch (ParseException e) {
{if (true) throw e;}
} catch (TokenMgrError te) {
{if (true) throw new ParseException(te.getMessage());}
}
throw new Error("Missing return statement in function");
}
final public Object value() throws ParseException {
List list = null;
Map map = null;
String string;
Token t;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING:
string = string();
{if (true) return string;}
break;
case NUMBER:
t = jj_consume_token(NUMBER);
if (t.image.indexOf(".") < 0) {
{if (true) return new Long(t.image);}
} else {
{if (true) return new Double(t.image);}
}
break;
case 19:
map = object();
{if (true) return map;}
break;
case 23:
list = array();
{if (true) return list;}
break;
case TRUE:
t = jj_consume_token(TRUE);
{if (true) return Boolean.TRUE;}
break;
case FALSE:
t = jj_consume_token(FALSE);
{if (true) return Boolean.FALSE;}
break;
case NULL:
t = jj_consume_token(NULL);
{if (true) return null;}
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
final public String string() throws ParseException {
Token t;
t = jj_consume_token(STRING);
String s = t.image;
// remove quota
s = s.substring(1);
s = s.substring(0, (s.length() - 1) );
s = JsonWalkerInterceptor.handleControlCharacterBack(s);
{if (true) return s;}
throw new Error("Missing return statement in function");
}
final public Map object() throws ParseException {
Object value;
String key;
Token t;
Map map = new HashMap();
jj_consume_token(19);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING:
key = string();
jj_consume_token(20);
value = value();
map.put(key, value);
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 21:
;
break;
default:
jj_la1[2] = jj_gen;
break label_1;
}
jj_consume_token(21);
key = string();
jj_consume_token(20);
value = value();
map.put(key, value);
}
break;
default:
jj_la1[3] = jj_gen;
;
}
jj_consume_token(22);
{if (true) return map;}
throw new Error("Missing return statement in function");
}
final public List array() throws ParseException {
Object value;
List list = new ArrayList();
jj_consume_token(23);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TRUE:
case FALSE:
case NULL:
case NUMBER:
case STRING:
case 19:
case 23:
value = value();
list.add(value);
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 21:
;
break;
default:
jj_la1[4] = jj_gen;
break label_2;
}
jj_consume_token(21);
value = value();
list.add(value);
}
break;
default:
jj_la1[5] = jj_gen;
;
}
jj_consume_token(24);
{if (true) return list;}
throw new Error("Missing return statement in function");
}
public JsonParserGenerateTokenManager token_source;
SimpleCharStream jj_input_stream;
public Token token, jj_nt;
private int jj_ntk;
private int jj_gen;
final private int[] jj_la1 = new int[6];
static private int[] jj_la1_0;
static {
jj_la1_0();
}
private static void jj_la1_0() {
jj_la1_0 = new int[] {0x8c06e0,0x8806e0,0x200000,0x400,0x200000,0x8806e0,};
}
public JsonParserGenerate(java.io.InputStream stream) {
this(stream, null);
}
public JsonParserGenerate(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 JsonParserGenerateTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 6; i++) jj_la1[i] = -1;
}
public void ReInit(java.io.InputStream stream) {
ReInit(stream, null);
}
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 < 6; i++) jj_la1[i] = -1;
}
public JsonParserGenerate(java.io.Reader stream) {
jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new JsonParserGenerateTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 6; i++) jj_la1[i] = -1;
}
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 < 6; i++) jj_la1[i] = -1;
}
public JsonParserGenerate(JsonParserGenerateTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 6; i++) jj_la1[i] = -1;
}
public void ReInit(JsonParserGenerateTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 6; i++) jj_la1[i] = -1;
}
final 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++;
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
}
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;
}
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;
}
final 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 int[] jj_expentry;
private int jj_kind = -1;
public ParseException generateParseException() {
jj_expentries.removeAllElements();
boolean[] la1tokens = new boolean[25];
for (int i = 0; i < 25; i++) {
la1tokens[i] = false;
}
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 6; 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;
}
}
}
}
for (int i = 0; i < 25; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.addElement(jj_expentry);
}
}
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.elementAt(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
final public void enable_tracing() {
}
final public void disable_tracing() {
}
}
|