diff --git a/src/main/java/org/json/simple/ItemList.java b/src/main/java/org/json/simple/ItemList.java new file mode 100644 index 0000000..d387458 --- /dev/null +++ b/src/main/java/org/json/simple/ItemList.java @@ -0,0 +1,148 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple; + +import java.util.Collection; +import java.util.StringTokenizer; +import java.util.ArrayList; +import java.util.List; + +public class ItemList +{ + private String sp; + List items; + + public ItemList() { + this.sp = ","; + this.items = new ArrayList(); + } + + public ItemList(final String s) { + this.sp = ","; + this.items = new ArrayList(); + this.split(s, this.sp, this.items); + } + + public ItemList(final String s, final String sp) { + this.sp = ","; + this.items = new ArrayList(); + this.split(this.sp = s, sp, this.items); + } + + public ItemList(final String s, final String sp, final boolean isMultiToken) { + this.sp = ","; + this.split(s, sp, this.items = new ArrayList(), isMultiToken); + } + + public List getItems() { + return this.items; + } + + public String[] getArray() { + return (String[])this.items.toArray(); + } + + public void split(final String s, final String sp, final List append, final boolean isMultiToken) { + if (s == null || sp == null) { + return; + } + if (isMultiToken) { + final StringTokenizer tokens = new StringTokenizer(s, sp); + while (tokens.hasMoreTokens()) { + append.add(tokens.nextToken().trim()); + } + } + else { + this.split(s, sp, append); + } + } + + public void split(final String s, final String sp, final List append) { + if (s == null || sp == null) { + return; + } + int pos = 0; + int prevPos = 0; + do { + prevPos = pos; + pos = s.indexOf(sp, pos); + if (pos == -1) { + break; + } + append.add(s.substring(prevPos, pos).trim()); + pos += sp.length(); + } while (pos != -1); + append.add(s.substring(prevPos).trim()); + } + + public void setSP(final String sp) { + this.sp = sp; + } + + public void add(final int i, final String item) { + if (item == null) { + return; + } + this.items.add(i, item.trim()); + } + + public void add(final String item) { + if (item == null) { + return; + } + this.items.add(item.trim()); + } + + public void addAll(final ItemList list) { + this.items.addAll(list.items); + } + + public void addAll(final String s) { + this.split(s, this.sp, this.items); + } + + public void addAll(final String s, final String sp) { + this.split(s, sp, this.items); + } + + public void addAll(final String s, final String sp, final boolean isMultiToken) { + this.split(s, sp, this.items, isMultiToken); + } + + public String get(final int i) { + return this.items.get(i); + } + + public int size() { + return this.items.size(); + } + + public String toString() { + return this.toString(this.sp); + } + + public String toString(final String sp) { + final StringBuffer sb = new StringBuffer(); + for (int i = 0; i < this.items.size(); ++i) { + if (i == 0) { + sb.append(this.items.get(i)); + } + else { + sb.append(sp); + sb.append(this.items.get(i)); + } + } + return sb.toString(); + } + + public void clear() { + this.items.clear(); + } + + public void reset() { + this.sp = ","; + this.items.clear(); + } +} diff --git a/src/main/java/org/json/simple/JSONArray.java b/src/main/java/org/json/simple/JSONArray.java new file mode 100644 index 0000000..08dd8d8 --- /dev/null +++ b/src/main/java/org/json/simple/JSONArray.java @@ -0,0 +1,81 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple; + +import java.io.IOException; +import java.util.Iterator; +import java.io.Writer; +import java.util.List; +import java.util.ArrayList; + +public class JSONArray extends ArrayList implements List, JSONAware, JSONStreamAware +{ + private static final long serialVersionUID = 3957988303675231981L; + + public static void writeJSONString(final List list, final Writer out) throws IOException { + if (list == null) { + out.write("null"); + return; + } + boolean first = true; + final Iterator iter = list.iterator(); + out.write(91); + while (iter.hasNext()) { + if (first) { + first = false; + } + else { + out.write(44); + } + final Object value = iter.next(); + if (value == null) { + out.write("null"); + } + else { + JSONValue.writeJSONString(value, out); + } + } + out.write(93); + } + + public void writeJSONString(final Writer out) throws IOException { + writeJSONString(this, out); + } + + public static String toJSONString(final List list) { + if (list == null) { + return "null"; + } + boolean first = true; + final StringBuffer sb = new StringBuffer(); + final Iterator iter = list.iterator(); + sb.append('['); + while (iter.hasNext()) { + if (first) { + first = false; + } + else { + sb.append(','); + } + final Object value = iter.next(); + if (value == null) { + sb.append("null"); + } + else { + sb.append(JSONValue.toJSONString(value)); + } + } + sb.append(']'); + return sb.toString(); + } + + public String toJSONString() { + return toJSONString(this); + } + + public String toString() { + return this.toJSONString(); + } +} diff --git a/src/main/java/org/json/simple/JSONAware.java b/src/main/java/org/json/simple/JSONAware.java new file mode 100644 index 0000000..cbe735b --- /dev/null +++ b/src/main/java/org/json/simple/JSONAware.java @@ -0,0 +1,10 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple; + +public interface JSONAware +{ + String toJSONString(); +} diff --git a/src/main/java/org/json/simple/JSONObject.java b/src/main/java/org/json/simple/JSONObject.java new file mode 100644 index 0000000..2e7b5c5 --- /dev/null +++ b/src/main/java/org/json/simple/JSONObject.java @@ -0,0 +1,105 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple; + +import java.io.IOException; +import java.util.Iterator; +import java.io.Writer; +import java.util.Map; +import java.util.HashMap; + +public class JSONObject extends HashMap implements Map, JSONAware, JSONStreamAware +{ + private static final long serialVersionUID = -503443796854799292L; + + public JSONObject() { + } + + public JSONObject(final Map map) { + super(map); + } + + public static void writeJSONString(final Map map, final Writer out) throws IOException { + if (map == null) { + out.write("null"); + return; + } + boolean first = true; + final Iterator iter = map.entrySet().iterator(); + out.write(123); + while (iter.hasNext()) { + if (first) { + first = false; + } + else { + out.write(44); + } + final Entry entry = iter.next(); + out.write(34); + out.write(escape(String.valueOf(entry.getKey()))); + out.write(34); + out.write(58); + JSONValue.writeJSONString(entry.getValue(), out); + } + out.write(125); + } + + public void writeJSONString(final Writer out) throws IOException { + writeJSONString(this, out); + } + + public static String toJSONString(final Map map) { + if (map == null) { + return "null"; + } + final StringBuffer sb = new StringBuffer(); + boolean first = true; + final Iterator iter = map.entrySet().iterator(); + sb.append('{'); + while (iter.hasNext()) { + if (first) { + first = false; + } + else { + sb.append(','); + } + final Entry entry = iter.next(); + toJSONString(String.valueOf(entry.getKey()), entry.getValue(), sb); + } + sb.append('}'); + return sb.toString(); + } + + public String toJSONString() { + return toJSONString(this); + } + + private static String toJSONString(final String key, final Object value, final StringBuffer sb) { + sb.append('\"'); + if (key == null) { + sb.append("null"); + } + else { + JSONValue.escape(key, sb); + } + sb.append('\"').append(':'); + sb.append(JSONValue.toJSONString(value)); + return sb.toString(); + } + + public String toString() { + return this.toJSONString(); + } + + public static String toString(final String key, final Object value) { + final StringBuffer sb = new StringBuffer(); + toJSONString(key, value, sb); + return sb.toString(); + } + + public static String escape(final String s) { + return JSONValue.escape(s); + } +} diff --git a/src/main/java/org/json/simple/JSONStreamAware.java b/src/main/java/org/json/simple/JSONStreamAware.java new file mode 100644 index 0000000..dcac38f --- /dev/null +++ b/src/main/java/org/json/simple/JSONStreamAware.java @@ -0,0 +1,13 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple; + +import java.io.IOException; +import java.io.Writer; + +public interface JSONStreamAware +{ + void writeJSONString(final Writer p0) throws IOException; +} diff --git a/src/main/java/org/json/simple/JSONValue.java b/src/main/java/org/json/simple/JSONValue.java new file mode 100644 index 0000000..d7c1641 --- /dev/null +++ b/src/main/java/org/json/simple/JSONValue.java @@ -0,0 +1,199 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple; + +import java.util.List; +import java.util.Map; +import java.io.Writer; +import org.json.simple.parser.ParseException; +import java.io.IOException; +import java.io.StringReader; +import org.json.simple.parser.JSONParser; +import java.io.Reader; + +public class JSONValue +{ + public static Object parse(final Reader in) { + try { + final JSONParser parser = new JSONParser(); + return parser.parse(in); + } + catch (Exception e) { + return null; + } + } + + public static Object parse(final String s) { + final StringReader in = new StringReader(s); + return parse(in); + } + + public static Object parseWithException(final Reader in) throws IOException, ParseException { + final JSONParser parser = new JSONParser(); + return parser.parse(in); + } + + public static Object parseWithException(final String s) throws ParseException { + final JSONParser parser = new JSONParser(); + return parser.parse(s); + } + + public static void writeJSONString(final Object value, final Writer out) throws IOException { + if (value == null) { + out.write("null"); + return; + } + if (value instanceof String) { + out.write(34); + out.write(escape((String)value)); + out.write(34); + return; + } + if (value instanceof Double) { + if (((Double)value).isInfinite() || ((Double)value).isNaN()) { + out.write("null"); + } + else { + out.write(value.toString()); + } + return; + } + if (value instanceof Float) { + if (((Float)value).isInfinite() || ((Float)value).isNaN()) { + out.write("null"); + } + else { + out.write(value.toString()); + } + return; + } + if (value instanceof Number) { + out.write(value.toString()); + return; + } + if (value instanceof Boolean) { + out.write(value.toString()); + return; + } + if (value instanceof JSONStreamAware) { + ((JSONStreamAware)value).writeJSONString(out); + return; + } + if (value instanceof JSONAware) { + out.write(((JSONAware)value).toJSONString()); + return; + } + if (value instanceof Map) { + JSONObject.writeJSONString((Map)value, out); + return; + } + if (value instanceof List) { + JSONArray.writeJSONString((List)value, out); + return; + } + out.write(value.toString()); + } + + public static String toJSONString(final Object value) { + if (value == null) { + return "null"; + } + if (value instanceof String) { + return "\"" + escape((String)value) + "\""; + } + if (value instanceof Double) { + if (((Double)value).isInfinite() || ((Double)value).isNaN()) { + return "null"; + } + return value.toString(); + } + else if (value instanceof Float) { + if (((Float)value).isInfinite() || ((Float)value).isNaN()) { + return "null"; + } + return value.toString(); + } + else { + if (value instanceof Number) { + return value.toString(); + } + if (value instanceof Boolean) { + return value.toString(); + } + if (value instanceof JSONAware) { + return ((JSONAware)value).toJSONString(); + } + if (value instanceof Map) { + return JSONObject.toJSONString((Map)value); + } + if (value instanceof List) { + return JSONArray.toJSONString((List)value); + } + return value.toString(); + } + } + + public static String escape(final String s) { + if (s == null) { + return null; + } + final StringBuffer sb = new StringBuffer(); + escape(s, sb); + return sb.toString(); + } + + static void escape(final String s, final StringBuffer sb) { + for (int i = 0; i < s.length(); ++i) { + final char ch = s.charAt(i); + switch (ch) { + case '\"': { + sb.append("\\\""); + break; + } + case '\\': { + sb.append("\\\\"); + break; + } + case '\b': { + sb.append("\\b"); + break; + } + case '\f': { + sb.append("\\f"); + break; + } + case '\n': { + sb.append("\\n"); + break; + } + case '\r': { + sb.append("\\r"); + break; + } + case '\t': { + sb.append("\\t"); + break; + } + case '/': { + sb.append("\\/"); + break; + } + default: { + if ((ch >= '\0' && ch <= '\u001f') || (ch >= '\u007f' && ch <= '\u009f') || (ch >= '\u2000' && ch <= '\u20ff')) { + final String ss = Integer.toHexString(ch); + sb.append("\\u"); + for (int k = 0; k < 4 - ss.length(); ++k) { + sb.append('0'); + } + sb.append(ss.toUpperCase()); + break; + } + sb.append(ch); + break; + } + } + } + } +} diff --git a/src/main/java/org/json/simple/parser/ContainerFactory.java b/src/main/java/org/json/simple/parser/ContainerFactory.java new file mode 100644 index 0000000..cfaf1e3 --- /dev/null +++ b/src/main/java/org/json/simple/parser/ContainerFactory.java @@ -0,0 +1,15 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple.parser; + +import java.util.List; +import java.util.Map; + +public interface ContainerFactory +{ + Map createObjectContainer(); + + List creatArrayContainer(); +} diff --git a/src/main/java/org/json/simple/parser/ContentHandler.java b/src/main/java/org/json/simple/parser/ContentHandler.java new file mode 100644 index 0000000..e374ef1 --- /dev/null +++ b/src/main/java/org/json/simple/parser/ContentHandler.java @@ -0,0 +1,28 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple.parser; + +import java.io.IOException; + +public interface ContentHandler +{ + void startJSON() throws ParseException, IOException; + + void endJSON() throws ParseException, IOException; + + boolean startObject() throws ParseException, IOException; + + boolean endObject() throws ParseException, IOException; + + boolean startObjectEntry(final String p0) throws ParseException, IOException; + + boolean endObjectEntry() throws ParseException, IOException; + + boolean startArray() throws ParseException, IOException; + + boolean endArray() throws ParseException, IOException; + + boolean primitive(final Object p0) throws ParseException, IOException; +} diff --git a/src/main/java/org/json/simple/parser/JSONParser.java b/src/main/java/org/json/simple/parser/JSONParser.java new file mode 100644 index 0000000..3284ff6 --- /dev/null +++ b/src/main/java/org/json/simple/parser/JSONParser.java @@ -0,0 +1,534 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple.parser; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import java.io.StringReader; +import java.io.Reader; +import java.util.LinkedList; + +public class JSONParser +{ + public static final int S_INIT = 0; + public static final int S_IN_FINISHED_VALUE = 1; + public static final int S_IN_OBJECT = 2; + public static final int S_IN_ARRAY = 3; + public static final int S_PASSED_PAIR_KEY = 4; + public static final int S_IN_PAIR_VALUE = 5; + public static final int S_END = 6; + public static final int S_IN_ERROR = -1; + private LinkedList handlerStatusStack; + private Yylex lexer; + private Yytoken token; + private int status; + + public JSONParser() { + this.lexer = new Yylex((Reader)null); + this.token = null; + this.status = 0; + } + + private int peekStatus(final LinkedList statusStack) { + if (statusStack.size() == 0) { + return -1; + } + final Integer status = statusStack.getFirst(); + return status; + } + + public void reset() { + this.token = null; + this.status = 0; + this.handlerStatusStack = null; + } + + public void reset(final Reader in) { + this.lexer.yyreset(in); + this.reset(); + } + + public int getPosition() { + return this.lexer.getPosition(); + } + + public Object parse(final String s) throws ParseException { + return this.parse(s, (ContainerFactory)null); + } + + public Object parse(final String s, final ContainerFactory containerFactory) throws ParseException { + final StringReader in = new StringReader(s); + try { + return this.parse(in, containerFactory); + } + catch (IOException ie) { + throw new ParseException(-1, 2, ie); + } + } + + public Object parse(final Reader in) throws IOException, ParseException { + return this.parse(in, (ContainerFactory)null); + } + + public Object parse(final Reader in, final ContainerFactory containerFactory) throws IOException, ParseException { + this.reset(in); + final LinkedList statusStack = new LinkedList(); + final LinkedList valueStack = new LinkedList(); + try { + do { + this.nextToken(); + Label_0922: { + switch (this.status) { + case 0: { + switch (this.token.type) { + case 0: { + this.status = 1; + statusStack.addFirst(new Integer(this.status)); + valueStack.addFirst(this.token.value); + break Label_0922; + } + case 1: { + this.status = 2; + statusStack.addFirst(new Integer(this.status)); + valueStack.addFirst(this.createObjectContainer(containerFactory)); + break Label_0922; + } + case 3: { + this.status = 3; + statusStack.addFirst(new Integer(this.status)); + valueStack.addFirst(this.createArrayContainer(containerFactory)); + break Label_0922; + } + default: { + this.status = -1; + break Label_0922; + } + } + break; + } + case 1: { + if (this.token.type == -1) { + return valueStack.removeFirst(); + } + throw new ParseException(this.getPosition(), 1, this.token); + } + case 2: { + switch (this.token.type) { + case 5: { + break Label_0922; + } + case 0: { + if (this.token.value instanceof String) { + final String key = (String)this.token.value; + valueStack.addFirst(key); + this.status = 4; + statusStack.addFirst(new Integer(this.status)); + break Label_0922; + } + this.status = -1; + break Label_0922; + } + case 2: { + if (valueStack.size() > 1) { + statusStack.removeFirst(); + valueStack.removeFirst(); + this.status = this.peekStatus(statusStack); + break Label_0922; + } + this.status = 1; + break Label_0922; + } + default: { + this.status = -1; + break Label_0922; + } + } + break; + } + case 4: { + switch (this.token.type) { + case 6: { + break; + } + case 0: { + statusStack.removeFirst(); + final String key = valueStack.removeFirst(); + final Map parent = valueStack.getFirst(); + parent.put(key, this.token.value); + this.status = this.peekStatus(statusStack); + break; + } + case 3: { + statusStack.removeFirst(); + final String key = valueStack.removeFirst(); + final Map parent = valueStack.getFirst(); + final List newArray = this.createArrayContainer(containerFactory); + parent.put(key, newArray); + this.status = 3; + statusStack.addFirst(new Integer(this.status)); + valueStack.addFirst(newArray); + break; + } + case 1: { + statusStack.removeFirst(); + final String key = valueStack.removeFirst(); + final Map parent = valueStack.getFirst(); + final Map newObject = this.createObjectContainer(containerFactory); + parent.put(key, newObject); + this.status = 2; + statusStack.addFirst(new Integer(this.status)); + valueStack.addFirst(newObject); + break; + } + default: { + this.status = -1; + break; + } + } + break; + } + case 3: { + switch (this.token.type) { + case 5: { + break; + } + case 0: { + final List val = valueStack.getFirst(); + val.add(this.token.value); + break; + } + case 4: { + if (valueStack.size() > 1) { + statusStack.removeFirst(); + valueStack.removeFirst(); + this.status = this.peekStatus(statusStack); + break; + } + this.status = 1; + break; + } + case 1: { + final List val = valueStack.getFirst(); + final Map newObject2 = this.createObjectContainer(containerFactory); + val.add(newObject2); + this.status = 2; + statusStack.addFirst(new Integer(this.status)); + valueStack.addFirst(newObject2); + break; + } + case 3: { + final List val = valueStack.getFirst(); + final List newArray = this.createArrayContainer(containerFactory); + val.add(newArray); + this.status = 3; + statusStack.addFirst(new Integer(this.status)); + valueStack.addFirst(newArray); + break; + } + default: { + this.status = -1; + break; + } + } + break; + } + case -1: { + throw new ParseException(this.getPosition(), 1, this.token); + } + } + } + if (this.status == -1) { + throw new ParseException(this.getPosition(), 1, this.token); + } + } while (this.token.type != -1); + } + catch (IOException ie) { + throw ie; + } + throw new ParseException(this.getPosition(), 1, this.token); + } + + private void nextToken() throws ParseException, IOException { + this.token = this.lexer.yylex(); + if (this.token == null) { + this.token = new Yytoken(-1, null); + } + } + + private Map createObjectContainer(final ContainerFactory containerFactory) { + if (containerFactory == null) { + return new JSONObject(); + } + final Map m = containerFactory.createObjectContainer(); + if (m == null) { + return new JSONObject(); + } + return m; + } + + private List createArrayContainer(final ContainerFactory containerFactory) { + if (containerFactory == null) { + return new JSONArray(); + } + final List l = containerFactory.creatArrayContainer(); + if (l == null) { + return new JSONArray(); + } + return l; + } + + public void parse(final String s, final ContentHandler contentHandler) throws ParseException { + this.parse(s, contentHandler, false); + } + + public void parse(final String s, final ContentHandler contentHandler, final boolean isResume) throws ParseException { + final StringReader in = new StringReader(s); + try { + this.parse(in, contentHandler, isResume); + } + catch (IOException ie) { + throw new ParseException(-1, 2, ie); + } + } + + public void parse(final Reader in, final ContentHandler contentHandler) throws IOException, ParseException { + this.parse(in, contentHandler, false); + } + + public void parse(final Reader in, final ContentHandler contentHandler, boolean isResume) throws IOException, ParseException { + if (!isResume) { + this.reset(in); + this.handlerStatusStack = new LinkedList(); + } + else if (this.handlerStatusStack == null) { + isResume = false; + this.reset(in); + this.handlerStatusStack = new LinkedList(); + } + final LinkedList statusStack = this.handlerStatusStack; + try { + do { + Label_0911: { + switch (this.status) { + case 0: { + contentHandler.startJSON(); + this.nextToken(); + switch (this.token.type) { + case 0: { + this.status = 1; + statusStack.addFirst(new Integer(this.status)); + if (!contentHandler.primitive(this.token.value)) { + return; + } + break Label_0911; + } + case 1: { + this.status = 2; + statusStack.addFirst(new Integer(this.status)); + if (!contentHandler.startObject()) { + return; + } + break Label_0911; + } + case 3: { + this.status = 3; + statusStack.addFirst(new Integer(this.status)); + if (!contentHandler.startArray()) { + return; + } + break Label_0911; + } + default: { + this.status = -1; + break Label_0911; + } + } + break; + } + case 1: { + this.nextToken(); + if (this.token.type == -1) { + contentHandler.endJSON(); + this.status = 6; + return; + } + this.status = -1; + throw new ParseException(this.getPosition(), 1, this.token); + } + case 2: { + this.nextToken(); + switch (this.token.type) { + case 5: { + break Label_0911; + } + case 0: { + if (!(this.token.value instanceof String)) { + this.status = -1; + break Label_0911; + } + final String key = (String)this.token.value; + this.status = 4; + statusStack.addFirst(new Integer(this.status)); + if (!contentHandler.startObjectEntry(key)) { + return; + } + break Label_0911; + } + case 2: { + if (statusStack.size() > 1) { + statusStack.removeFirst(); + this.status = this.peekStatus(statusStack); + } + else { + this.status = 1; + } + if (!contentHandler.endObject()) { + return; + } + break Label_0911; + } + default: { + this.status = -1; + break Label_0911; + } + } + break; + } + case 4: { + this.nextToken(); + switch (this.token.type) { + case 6: { + break Label_0911; + } + case 0: { + statusStack.removeFirst(); + this.status = this.peekStatus(statusStack); + if (!contentHandler.primitive(this.token.value)) { + return; + } + if (!contentHandler.endObjectEntry()) { + return; + } + break Label_0911; + } + case 3: { + statusStack.removeFirst(); + statusStack.addFirst(new Integer(5)); + this.status = 3; + statusStack.addFirst(new Integer(this.status)); + if (!contentHandler.startArray()) { + return; + } + break Label_0911; + } + case 1: { + statusStack.removeFirst(); + statusStack.addFirst(new Integer(5)); + this.status = 2; + statusStack.addFirst(new Integer(this.status)); + if (!contentHandler.startObject()) { + return; + } + break Label_0911; + } + default: { + this.status = -1; + break Label_0911; + } + } + break; + } + case 5: { + statusStack.removeFirst(); + this.status = this.peekStatus(statusStack); + if (!contentHandler.endObjectEntry()) { + return; + } + break; + } + case 3: { + this.nextToken(); + switch (this.token.type) { + case 5: { + break Label_0911; + } + case 0: { + if (!contentHandler.primitive(this.token.value)) { + return; + } + break Label_0911; + } + case 4: { + if (statusStack.size() > 1) { + statusStack.removeFirst(); + this.status = this.peekStatus(statusStack); + } + else { + this.status = 1; + } + if (!contentHandler.endArray()) { + return; + } + break Label_0911; + } + case 1: { + this.status = 2; + statusStack.addFirst(new Integer(this.status)); + if (!contentHandler.startObject()) { + return; + } + break Label_0911; + } + case 3: { + this.status = 3; + statusStack.addFirst(new Integer(this.status)); + if (!contentHandler.startArray()) { + return; + } + break Label_0911; + } + default: { + this.status = -1; + break Label_0911; + } + } + break; + } + case 6: { + return; + } + case -1: { + throw new ParseException(this.getPosition(), 1, this.token); + } + } + } + if (this.status == -1) { + throw new ParseException(this.getPosition(), 1, this.token); + } + } while (this.token.type != -1); + } + catch (IOException ie) { + this.status = -1; + throw ie; + } + catch (ParseException pe) { + this.status = -1; + throw pe; + } + catch (RuntimeException re) { + this.status = -1; + throw re; + } + catch (Error e) { + this.status = -1; + throw e; + } + this.status = -1; + throw new ParseException(this.getPosition(), 1, this.token); + } +} diff --git a/src/main/java/org/json/simple/parser/ParseException.java b/src/main/java/org/json/simple/parser/ParseException.java new file mode 100644 index 0000000..9e2fe8a --- /dev/null +++ b/src/main/java/org/json/simple/parser/ParseException.java @@ -0,0 +1,77 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple.parser; + +public class ParseException extends Exception +{ + private static final long serialVersionUID = -7880698968187728548L; + public static final int ERROR_UNEXPECTED_CHAR = 0; + public static final int ERROR_UNEXPECTED_TOKEN = 1; + public static final int ERROR_UNEXPECTED_EXCEPTION = 2; + private int errorType; + private Object unexpectedObject; + private int position; + + public ParseException(final int errorType) { + this(-1, errorType, null); + } + + public ParseException(final int errorType, final Object unexpectedObject) { + this(-1, errorType, unexpectedObject); + } + + public ParseException(final int position, final int errorType, final Object unexpectedObject) { + this.position = position; + this.errorType = errorType; + this.unexpectedObject = unexpectedObject; + } + + public int getErrorType() { + return this.errorType; + } + + public void setErrorType(final int errorType) { + this.errorType = errorType; + } + + public int getPosition() { + return this.position; + } + + public void setPosition(final int position) { + this.position = position; + } + + public Object getUnexpectedObject() { + return this.unexpectedObject; + } + + public void setUnexpectedObject(final Object unexpectedObject) { + this.unexpectedObject = unexpectedObject; + } + + public String toString() { + final StringBuffer sb = new StringBuffer(); + switch (this.errorType) { + case 0: { + sb.append("Unexpected character (").append(this.unexpectedObject).append(") at position ").append(this.position).append("."); + break; + } + case 1: { + sb.append("Unexpected token ").append(this.unexpectedObject).append(" at position ").append(this.position).append("."); + break; + } + case 2: { + sb.append("Unexpected exception at position ").append(this.position).append(": ").append(this.unexpectedObject); + break; + } + default: { + sb.append("Unkown error at position ").append(this.position).append("."); + break; + } + } + return sb.toString(); + } +} diff --git a/src/main/java/org/json/simple/parser/Yylex.java b/src/main/java/org/json/simple/parser/Yylex.java new file mode 100644 index 0000000..b7943ff --- /dev/null +++ b/src/main/java/org/json/simple/parser/Yylex.java @@ -0,0 +1,456 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple.parser; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.InputStream; +import java.io.Reader; + +class Yylex +{ + public static final int YYEOF = -1; + private static final int ZZ_BUFFERSIZE = 16384; + public static final int YYINITIAL = 0; + public static final int STRING_BEGIN = 2; + private static final int[] ZZ_LEXSTATE; + private static final String ZZ_CMAP_PACKED = "\t\u0000\u0001\u0007\u0001\u0007\u0002\u0000\u0001\u0007\u0012\u0000\u0001\u0007\u0001\u0000\u0001\t\b\u0000\u0001\u0006\u0001\u0019\u0001\u0002\u0001\u0004\u0001\n\n\u0003\u0001\u001a\u0006\u0000\u0004\u0001\u0001\u0005\u0001\u0001\u0014\u0000\u0001\u0017\u0001\b\u0001\u0018\u0003\u0000\u0001\u0012\u0001\u000b\u0002\u0001\u0001\u0011\u0001\f\u0005\u0000\u0001\u0013\u0001\u0000\u0001\r\u0003\u0000\u0001\u000e\u0001\u0014\u0001\u000f\u0001\u0010\u0005\u0000\u0001\u0015\u0001\u0000\u0001\u0016\uff82\u0000"; + private static final char[] ZZ_CMAP; + private static final int[] ZZ_ACTION; + private static final String ZZ_ACTION_PACKED_0 = "\u0002\u0000\u0002\u0001\u0001\u0002\u0001\u0003\u0001\u0004\u0003\u0001\u0001\u0005\u0001\u0006\u0001\u0007\u0001\b\u0001\t\u0001\n\u0001\u000b\u0001\f\u0001\r\u0005\u0000\u0001\f\u0001\u000e\u0001\u000f\u0001\u0010\u0001\u0011\u0001\u0012\u0001\u0013\u0001\u0014\u0001\u0000\u0001\u0015\u0001\u0000\u0001\u0015\u0004\u0000\u0001\u0016\u0001\u0017\u0002\u0000\u0001\u0018"; + private static final int[] ZZ_ROWMAP; + private static final String ZZ_ROWMAP_PACKED_0 = "\u0000\u0000\u0000\u001b\u00006\u0000Q\u0000l\u0000\u0087\u00006\u0000¢\u0000½\u0000\u00d8\u00006\u00006\u00006\u00006\u00006\u00006\u0000\u00f3\u0000\u010e\u00006\u0000\u0129\u0000\u0144\u0000\u015f\u0000\u017a\u0000\u0195\u00006\u00006\u00006\u00006\u00006\u00006\u00006\u00006\u0000\u01b0\u0000\u01cb\u0000\u01e6\u0000\u01e6\u0000\u0201\u0000\u021c\u0000\u0237\u0000\u0252\u00006\u00006\u0000\u026d\u0000\u0288\u00006"; + private static final int[] ZZ_TRANS; + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + private static final String[] ZZ_ERROR_MSG; + private static final int[] ZZ_ATTRIBUTE; + private static final String ZZ_ATTRIBUTE_PACKED_0 = "\u0002\u0000\u0001\t\u0003\u0001\u0001\t\u0003\u0001\u0006\t\u0002\u0001\u0001\t\u0005\u0000\b\t\u0001\u0000\u0001\u0001\u0001\u0000\u0001\u0001\u0004\u0000\u0002\t\u0002\u0000\u0001\t"; + private Reader zzReader; + private int zzState; + private int zzLexicalState; + private char[] zzBuffer; + private int zzMarkedPos; + private int zzCurrentPos; + private int zzStartRead; + private int zzEndRead; + private int yyline; + private int yychar; + private int yycolumn; + private boolean zzAtBOL; + private boolean zzAtEOF; + private StringBuffer sb; + + private static int[] zzUnpackAction() { + final int[] result = new int[45]; + int offset = 0; + offset = zzUnpackAction("\u0002\u0000\u0002\u0001\u0001\u0002\u0001\u0003\u0001\u0004\u0003\u0001\u0001\u0005\u0001\u0006\u0001\u0007\u0001\b\u0001\t\u0001\n\u0001\u000b\u0001\f\u0001\r\u0005\u0000\u0001\f\u0001\u000e\u0001\u000f\u0001\u0010\u0001\u0011\u0001\u0012\u0001\u0013\u0001\u0014\u0001\u0000\u0001\u0015\u0001\u0000\u0001\u0015\u0004\u0000\u0001\u0016\u0001\u0017\u0002\u0000\u0001\u0018", offset, result); + return result; + } + + private static int zzUnpackAction(final String packed, final int offset, final int[] result) { + int i = 0; + int j = offset; + final int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + final int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + + private static int[] zzUnpackRowMap() { + final int[] result = new int[45]; + int offset = 0; + offset = zzUnpackRowMap("\u0000\u0000\u0000\u001b\u00006\u0000Q\u0000l\u0000\u0087\u00006\u0000¢\u0000½\u0000\u00d8\u00006\u00006\u00006\u00006\u00006\u00006\u0000\u00f3\u0000\u010e\u00006\u0000\u0129\u0000\u0144\u0000\u015f\u0000\u017a\u0000\u0195\u00006\u00006\u00006\u00006\u00006\u00006\u00006\u00006\u0000\u01b0\u0000\u01cb\u0000\u01e6\u0000\u01e6\u0000\u0201\u0000\u021c\u0000\u0237\u0000\u0252\u00006\u00006\u0000\u026d\u0000\u0288\u00006", offset, result); + return result; + } + + private static int zzUnpackRowMap(final String packed, final int offset, final int[] result) { + int i = 0; + int j = offset; + int high; + for (int l = packed.length(); i < l; high = packed.charAt(i++) << 16, result[j++] = (high | packed.charAt(i++))) {} + return j; + } + + private static int[] zzUnpackAttribute() { + final int[] result = new int[45]; + int offset = 0; + offset = zzUnpackAttribute("\u0002\u0000\u0001\t\u0003\u0001\u0001\t\u0003\u0001\u0006\t\u0002\u0001\u0001\t\u0005\u0000\b\t\u0001\u0000\u0001\u0001\u0001\u0000\u0001\u0001\u0004\u0000\u0002\t\u0002\u0000\u0001\t", offset, result); + return result; + } + + private static int zzUnpackAttribute(final String packed, final int offset, final int[] result) { + int i = 0; + int j = offset; + final int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + final int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + + int getPosition() { + return this.yychar; + } + + Yylex(final Reader in) { + this.zzLexicalState = 0; + this.zzBuffer = new char[16384]; + this.zzAtBOL = true; + this.sb = new StringBuffer(); + this.zzReader = in; + } + + Yylex(final InputStream in) { + this(new InputStreamReader(in)); + } + + private static char[] zzUnpackCMap(final String packed) { + final char[] map = new char[65536]; + int i = 0; + int j = 0; + while (i < 90) { + int count = packed.charAt(i++); + final char value = packed.charAt(i++); + do { + map[j++] = value; + } while (--count > 0); + } + return map; + } + + private boolean zzRefill() throws IOException { + if (this.zzStartRead > 0) { + System.arraycopy(this.zzBuffer, this.zzStartRead, this.zzBuffer, 0, this.zzEndRead - this.zzStartRead); + this.zzEndRead -= this.zzStartRead; + this.zzCurrentPos -= this.zzStartRead; + this.zzMarkedPos -= this.zzStartRead; + this.zzStartRead = 0; + } + if (this.zzCurrentPos >= this.zzBuffer.length) { + final char[] newBuffer = new char[this.zzCurrentPos * 2]; + System.arraycopy(this.zzBuffer, 0, newBuffer, 0, this.zzBuffer.length); + this.zzBuffer = newBuffer; + } + final int numRead = this.zzReader.read(this.zzBuffer, this.zzEndRead, this.zzBuffer.length - this.zzEndRead); + if (numRead > 0) { + this.zzEndRead += numRead; + return false; + } + if (numRead != 0) { + return true; + } + final int c = this.zzReader.read(); + if (c == -1) { + return true; + } + this.zzBuffer[this.zzEndRead++] = (char)c; + return false; + } + + public final void yyclose() throws IOException { + this.zzAtEOF = true; + this.zzEndRead = this.zzStartRead; + if (this.zzReader != null) { + this.zzReader.close(); + } + } + + public final void yyreset(final Reader reader) { + this.zzReader = reader; + this.zzAtBOL = true; + this.zzAtEOF = false; + final int n = 0; + this.zzStartRead = n; + this.zzEndRead = n; + final int n2 = 0; + this.zzMarkedPos = n2; + this.zzCurrentPos = n2; + final int yyline = 0; + this.yycolumn = yyline; + this.yychar = yyline; + this.yyline = yyline; + this.zzLexicalState = 0; + } + + public final int yystate() { + return this.zzLexicalState; + } + + public final void yybegin(final int newState) { + this.zzLexicalState = newState; + } + + public final String yytext() { + return new String(this.zzBuffer, this.zzStartRead, this.zzMarkedPos - this.zzStartRead); + } + + public final char yycharat(final int pos) { + return this.zzBuffer[this.zzStartRead + pos]; + } + + public final int yylength() { + return this.zzMarkedPos - this.zzStartRead; + } + + private void zzScanError(final int errorCode) { + String message; + try { + message = Yylex.ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = Yylex.ZZ_ERROR_MSG[0]; + } + throw new Error(message); + } + + public void yypushback(final int number) { + if (number > this.yylength()) { + this.zzScanError(2); + } + this.zzMarkedPos -= number; + } + + public Yytoken yylex() throws IOException, ParseException { + int zzEndReadL = this.zzEndRead; + char[] zzBufferL = this.zzBuffer; + final char[] zzCMapL = Yylex.ZZ_CMAP; + final int[] zzTransL = Yylex.ZZ_TRANS; + final int[] zzRowMapL = Yylex.ZZ_ROWMAP; + final int[] zzAttrL = Yylex.ZZ_ATTRIBUTE; + while (true) { + int zzMarkedPosL = this.zzMarkedPos; + this.yychar += zzMarkedPosL - this.zzStartRead; + int zzAction = -1; + final int n = zzMarkedPosL; + this.zzStartRead = n; + this.zzCurrentPos = n; + int zzCurrentPosL = n; + this.zzState = Yylex.ZZ_LEXSTATE[this.zzLexicalState]; + int zzInput; + while (true) { + if (zzCurrentPosL < zzEndReadL) { + zzInput = zzBufferL[zzCurrentPosL++]; + } + else { + if (this.zzAtEOF) { + zzInput = -1; + break; + } + this.zzCurrentPos = zzCurrentPosL; + this.zzMarkedPos = zzMarkedPosL; + final boolean eof = this.zzRefill(); + zzCurrentPosL = this.zzCurrentPos; + zzMarkedPosL = this.zzMarkedPos; + zzBufferL = this.zzBuffer; + zzEndReadL = this.zzEndRead; + if (eof) { + zzInput = -1; + break; + } + zzInput = zzBufferL[zzCurrentPosL++]; + } + final int zzNext = zzTransL[zzRowMapL[this.zzState] + zzCMapL[zzInput]]; + if (zzNext == -1) { + break; + } + this.zzState = zzNext; + final int zzAttributes = zzAttrL[this.zzState]; + if ((zzAttributes & 0x1) != 0x1) { + continue; + } + zzAction = this.zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 0x8) == 0x8) { + break; + } + } + this.zzMarkedPos = zzMarkedPosL; + switch ((zzAction < 0) ? zzAction : Yylex.ZZ_ACTION[zzAction]) { + case 11: { + this.sb.append(this.yytext()); + } + case 25: { + continue; + } + case 4: { + this.sb.delete(0, this.sb.length()); + this.yybegin(2); + } + case 26: { + continue; + } + case 16: { + this.sb.append('\b'); + } + case 27: { + continue; + } + case 6: { + return new Yytoken(2, null); + } + case 28: { + continue; + } + case 23: { + final Boolean val = Boolean.valueOf(this.yytext()); + return new Yytoken(0, val); + } + case 29: { + continue; + } + case 22: { + return new Yytoken(0, null); + } + case 30: { + continue; + } + case 13: { + this.yybegin(0); + return new Yytoken(0, this.sb.toString()); + } + case 31: { + continue; + } + case 12: { + this.sb.append('\\'); + } + case 32: { + continue; + } + case 21: { + final Double val2 = Double.valueOf(this.yytext()); + return new Yytoken(0, val2); + } + case 33: { + continue; + } + case 1: { + throw new ParseException(this.yychar, 0, new Character(this.yycharat(0))); + } + case 34: { + continue; + } + case 8: { + return new Yytoken(4, null); + } + case 35: { + continue; + } + case 19: { + this.sb.append('\r'); + } + case 36: { + continue; + } + case 15: { + this.sb.append('/'); + } + case 37: { + continue; + } + case 10: { + return new Yytoken(6, null); + } + case 38: { + continue; + } + case 14: { + this.sb.append('\"'); + } + case 39: { + continue; + } + case 5: { + return new Yytoken(1, null); + } + case 40: { + continue; + } + case 17: { + this.sb.append('\f'); + } + case 41: { + continue; + } + case 24: { + try { + final int ch = Integer.parseInt(this.yytext().substring(2), 16); + this.sb.append((char)ch); + } + catch (Exception e) { + throw new ParseException(this.yychar, 2, e); + } + } + case 42: { + continue; + } + case 20: { + this.sb.append('\t'); + } + case 43: { + continue; + } + case 7: { + return new Yytoken(3, null); + } + case 44: { + continue; + } + case 2: { + final Long val3 = Long.valueOf(this.yytext()); + return new Yytoken(0, val3); + } + case 45: { + continue; + } + case 18: { + this.sb.append('\n'); + } + case 46: { + continue; + } + case 9: { + return new Yytoken(5, null); + } + case 47: { + continue; + } + case 3: + case 48: { + continue; + } + default: { + if (zzInput == -1 && this.zzStartRead == this.zzCurrentPos) { + this.zzAtEOF = true; + return null; + } + this.zzScanError(1); + continue; + } + } + } + } + + static { + ZZ_LEXSTATE = new int[] { 0, 0, 1, 1 }; + ZZ_CMAP = zzUnpackCMap("\t\u0000\u0001\u0007\u0001\u0007\u0002\u0000\u0001\u0007\u0012\u0000\u0001\u0007\u0001\u0000\u0001\t\b\u0000\u0001\u0006\u0001\u0019\u0001\u0002\u0001\u0004\u0001\n\n\u0003\u0001\u001a\u0006\u0000\u0004\u0001\u0001\u0005\u0001\u0001\u0014\u0000\u0001\u0017\u0001\b\u0001\u0018\u0003\u0000\u0001\u0012\u0001\u000b\u0002\u0001\u0001\u0011\u0001\f\u0005\u0000\u0001\u0013\u0001\u0000\u0001\r\u0003\u0000\u0001\u000e\u0001\u0014\u0001\u000f\u0001\u0010\u0005\u0000\u0001\u0015\u0001\u0000\u0001\u0016\uff82\u0000"); + ZZ_ACTION = zzUnpackAction(); + ZZ_ROWMAP = zzUnpackRowMap(); + ZZ_TRANS = new int[] { 2, 2, 3, 4, 2, 2, 2, 5, 2, 6, 2, 2, 7, 8, 2, 9, 2, 2, 2, 2, 2, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, -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, -1, 4, -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, 4, 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -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, -1, -1, -1, -1, -1, -1, -1, -1, 21, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 16, 16, 16, 16, 16, 16, 16, -1, -1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -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, 34, 35, -1, -1, 34, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -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, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, -1, 39, -1, 39, -1, -1, -1, -1, -1, 39, 39, -1, -1, -1, -1, 39, 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 38, -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, 40, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, 42, -1, 42, -1, -1, -1, -1, -1, 42, 42, -1, -1, -1, -1, 42, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, -1, 43, -1, 43, -1, -1, -1, -1, -1, 43, 43, -1, -1, -1, -1, 43, 43, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, -1, 44, -1, 44, -1, -1, -1, -1, -1, 44, 44, -1, -1, -1, -1, 44, 44, -1, -1, -1, -1, -1, -1, -1, -1 }; + ZZ_ERROR_MSG = new String[] { "Unkown internal scanner error", "Error: could not match input", "Error: pushback value was too large" }; + ZZ_ATTRIBUTE = zzUnpackAttribute(); + } +} diff --git a/src/main/java/org/json/simple/parser/Yytoken.java b/src/main/java/org/json/simple/parser/Yytoken.java new file mode 100644 index 0000000..c931289 --- /dev/null +++ b/src/main/java/org/json/simple/parser/Yytoken.java @@ -0,0 +1,65 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package org.json.simple.parser; + +public class Yytoken +{ + public static final int TYPE_VALUE = 0; + public static final int TYPE_LEFT_BRACE = 1; + public static final int TYPE_RIGHT_BRACE = 2; + public static final int TYPE_LEFT_SQUARE = 3; + public static final int TYPE_RIGHT_SQUARE = 4; + public static final int TYPE_COMMA = 5; + public static final int TYPE_COLON = 6; + public static final int TYPE_EOF = -1; + public int type; + public Object value; + + public Yytoken(final int type, final Object value) { + this.type = 0; + this.value = null; + this.type = type; + this.value = value; + } + + public String toString() { + final StringBuffer sb = new StringBuffer(); + switch (this.type) { + case 0: { + sb.append("VALUE(").append(this.value).append(")"); + break; + } + case 1: { + sb.append("LEFT BRACE({)"); + break; + } + case 2: { + sb.append("RIGHT BRACE(})"); + break; + } + case 3: { + sb.append("LEFT SQUARE([)"); + break; + } + case 4: { + sb.append("RIGHT SQUARE(])"); + break; + } + case 5: { + sb.append("COMMA(,)"); + break; + } + case 6: { + sb.append("COLON(:)"); + break; + } + case -1: { + sb.append("END OF FILE"); + break; + } + } + return sb.toString(); + } +}