More formatting

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-01-03 15:35:30 +00:00
parent 346e41a6e5
commit 05b2a299c0
12 changed files with 2190 additions and 2184 deletions

View file

@ -18,9 +18,8 @@ public class ItemList {
private String sp = ",";
List items = new ArrayList();
public ItemList(){}
public ItemList() {
}
public ItemList(String s) {
this.split(s, sp, items);
@ -44,29 +43,31 @@ public class ItemList {
}
public void split(String s, String sp, List append, boolean isMultiToken) {
if(s==null || sp==null)
if (s == null || sp == null) {
return;
}
if (isMultiToken) {
StringTokenizer tokens = new StringTokenizer(s, sp);
while (tokens.hasMoreTokens()) {
append.add(tokens.nextToken().trim());
}
}
else{
} else {
this.split(s, sp, append);
}
}
public void split(String s, String sp, List append) {
if(s==null || sp==null)
if (s == null || sp == null) {
return;
}
int pos = 0;
int prevPos = 0;
do {
prevPos = pos;
pos = s.indexOf(sp, pos);
if(pos==-1)
if (pos == -1) {
break;
}
append.add(s.substring(prevPos, pos).trim());
pos += sp.length();
} while (pos != -1);
@ -78,14 +79,16 @@ public class ItemList {
}
public void add(int i, String item) {
if(item==null)
if (item == null) {
return;
}
items.add(i, item.trim());
}
public void add(String item) {
if(item==null)
if (item == null) {
return;
}
items.add(item.trim());
}
@ -125,9 +128,9 @@ public class ItemList {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < items.size(); i++) {
if(i==0)
if (i == 0) {
sb.append(items.get(i));
else{
} else {
sb.append(sp);
sb.append(items.get(i));
}

View file

@ -10,7 +10,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* A JSON array. JSONObject supports java.util.List interface.
*
@ -39,10 +38,11 @@ public class JSONArray extends ArrayList implements List, JSONAware, JSONStreamA
out.write('[');
while (iter.hasNext()) {
if(first)
if (first) {
first = false;
else
} else {
out.write(',');
}
Object value = iter.next();
if (value == null) {
@ -69,8 +69,9 @@ public class JSONArray extends ArrayList implements List, JSONAware, JSONStreamA
* @return JSON text, or "null" if list is null.
*/
public static String toJSONString(List list) {
if(list == null)
if (list == null) {
return "null";
}
boolean first = true;
StringBuffer sb = new StringBuffer();
@ -78,10 +79,11 @@ public class JSONArray extends ArrayList implements List, JSONAware, JSONStreamA
sb.append('[');
while (iter.hasNext()) {
if(first)
if (first) {
first = false;
else
} else {
sb.append(',');
}
Object value = iter.next();
if (value == null) {
@ -101,7 +103,4 @@ public class JSONArray extends ArrayList implements List, JSONAware, JSONStreamA
public String toString() {
return toJSONString();
}
}

View file

@ -38,10 +38,11 @@ public class JSONObject extends HashMap implements Map, JSONAware, JSONStreamAwa
out.write('{');
while (iter.hasNext()) {
if(first)
if (first) {
first = false;
else
} else {
out.write(',');
}
Map.Entry entry = (Map.Entry) iter.next();
out.write('\"');
out.write(escape(String.valueOf(entry.getKey())));
@ -66,8 +67,9 @@ public class JSONObject extends HashMap implements Map, JSONAware, JSONStreamAwa
* @return JSON text, or "null" if map is null.
*/
public static String toJSONString(Map map) {
if(map == null)
if (map == null) {
return "null";
}
StringBuffer sb = new StringBuffer();
boolean first = true;
@ -75,10 +77,11 @@ public class JSONObject extends HashMap implements Map, JSONAware, JSONStreamAwa
sb.append('{');
while (iter.hasNext()) {
if(first)
if (first) {
first = false;
else
} else {
sb.append(',');
}
Map.Entry entry = (Map.Entry) iter.next();
toJSONString(String.valueOf(entry.getKey()), entry.getValue(), sb);
@ -93,10 +96,11 @@ public class JSONObject extends HashMap implements Map, JSONAware, JSONStreamAwa
private static String toJSONString(String key, Object value, StringBuffer sb) {
sb.append('\"');
if(key == null)
if (key == null) {
sb.append("null");
else
} else {
JSONValue.escape(key, sb);
}
sb.append('\"').append(':');
sb.append(JSONValue.toJSONString(value));

View file

@ -14,7 +14,6 @@ import java.util.Map;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
/**
* @author FangYidong<fangyidong@yahoo.com.cn>
*/
@ -40,8 +39,7 @@ public class JSONValue {
try {
JSONParser parser = new JSONParser();
return parser.parse(in);
}
catch(Exception e){
} catch (Exception e) {
return null;
}
}
@ -106,18 +104,20 @@ public class JSONValue {
}
if (value instanceof Double) {
if(((Double)value).isInfinite() || ((Double)value).isNaN())
if (((Double) value).isInfinite() || ((Double) value).isNaN()) {
out.write("null");
else
} else {
out.write(value.toString());
}
return;
}
if (value instanceof Float) {
if(((Float)value).isInfinite() || ((Float)value).isNaN())
if (((Float) value).isInfinite() || ((Float) value).isNaN()) {
out.write("null");
else
} else {
out.write(value.toString());
}
return;
}
@ -169,40 +169,49 @@ public class JSONValue {
* @return JSON text, or "null" if value is null or it's an NaN or an INF number.
*/
public static String toJSONString(Object value) {
if(value == null)
if (value == null) {
return "null";
}
if(value instanceof String)
if (value instanceof String) {
return "\"" + escape((String) value) + "\"";
}
if (value instanceof Double) {
if(((Double)value).isInfinite() || ((Double)value).isNaN())
if (((Double) value).isInfinite() || ((Double) value).isNaN()) {
return "null";
else
} else {
return value.toString();
}
}
if (value instanceof Float) {
if(((Float)value).isInfinite() || ((Float)value).isNaN())
if (((Float) value).isInfinite() || ((Float) value).isNaN()) {
return "null";
else
} else {
return value.toString();
}
}
if (value instanceof Number) {
return value.toString();
}
if(value instanceof Number)
if (value instanceof Boolean) {
return value.toString();
}
if(value instanceof Boolean)
return value.toString();
if((value instanceof JSONAware))
if ((value instanceof JSONAware)) {
return ((JSONAware) value).toJSONString();
}
if(value instanceof Map)
if (value instanceof Map) {
return JSONObject.toJSONString((Map) value);
}
if(value instanceof List)
if (value instanceof List) {
return JSONArray.toJSONString((List) value);
}
return value.toString();
}
@ -213,8 +222,9 @@ public class JSONValue {
* @return
*/
public static String escape(String s) {
if(s==null)
if (s == null) {
return null;
}
StringBuffer sb = new StringBuffer();
escape(s, sb);
return sb.toString();
@ -261,12 +271,10 @@ public class JSONValue {
sb.append('0');
}
sb.append(ss.toUpperCase());
}
else{
} else {
sb.append(ch);
}
}
}//for
}
}

View file

@ -106,5 +106,4 @@ public interface ContentHandler {
* @throws ParseException
*/
boolean primitive(Object value) throws ParseException, IOException;
}

View file

@ -14,7 +14,6 @@ import java.util.Map;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
/**
* Parser for JSON text. Please note that JSONParser is NOT thread-safe.
*
@ -29,15 +28,15 @@ public class JSONParser {
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 = new Yylex((Reader) null);
private Yytoken token = null;
private int status = S_INIT;
private int peekStatus(LinkedList statusStack) {
if(statusStack.size()==0)
if (statusStack.size() == 0) {
return -1;
}
Integer status = (Integer) statusStack.getFirst();
return status.intValue();
}
@ -79,8 +78,7 @@ public class JSONParser {
StringReader in = new StringReader(s);
try {
return parse(in, containerFactory);
}
catch(IOException ie){
} catch (IOException ie) {
/*
* Actually it will never happen.
*/
@ -140,10 +138,11 @@ public class JSONParser {
break;
case S_IN_FINISHED_VALUE:
if(token.type==Yytoken.TYPE_EOF)
if (token.type == Yytoken.TYPE_EOF) {
return valueStack.removeFirst();
else
} else {
throw new ParseException(getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, token);
}
case S_IN_OBJECT:
switch (token.type) {
@ -155,8 +154,7 @@ public class JSONParser {
valueStack.addFirst(key);
status = S_PASSED_PAIR_KEY;
statusStack.addFirst(new Integer(status));
}
else{
} else {
status = S_IN_ERROR;
}
break;
@ -165,8 +163,7 @@ public class JSONParser {
statusStack.removeFirst();
valueStack.removeFirst();
status = peekStatus(statusStack);
}
else{
} else {
status = S_IN_FINISHED_VALUE;
}
break;
@ -225,8 +222,7 @@ public class JSONParser {
statusStack.removeFirst();
valueStack.removeFirst();
status = peekStatus(statusStack);
}
else{
} else {
status = S_IN_FINISHED_VALUE;
}
break;
@ -257,8 +253,7 @@ public class JSONParser {
throw new ParseException(getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, token);
}
} while (token.type != Yytoken.TYPE_EOF);
}
catch(IOException ie){
} catch (IOException ie) {
throw ie;
}
@ -267,27 +262,32 @@ public class JSONParser {
private void nextToken() throws ParseException, IOException {
token = lexer.yylex();
if(token == null)
if (token == null) {
token = new Yytoken(Yytoken.TYPE_EOF, null);
}
}
private Map createObjectContainer(ContainerFactory containerFactory) {
if(containerFactory == null)
if (containerFactory == null) {
return new JSONObject();
}
Map m = containerFactory.createObjectContainer();
if(m == null)
if (m == null) {
return new JSONObject();
}
return m;
}
private List createArrayContainer(ContainerFactory containerFactory) {
if(containerFactory == null)
if (containerFactory == null) {
return new JSONArray();
}
List l = containerFactory.creatArrayContainer();
if(l == null)
if (l == null) {
return new JSONArray();
}
return l;
}
@ -299,8 +299,7 @@ public class JSONParser {
StringReader in = new StringReader(s);
try {
parse(in, contentHandler, isResume);
}
catch(IOException ie){
} catch (IOException ie) {
/*
* Actually it will never happen.
*/
@ -330,8 +329,7 @@ public class JSONParser {
if (!isResume) {
reset(in);
handlerStatusStack = new LinkedList();
}
else{
} else {
if (handlerStatusStack == null) {
isResume = false;
reset(in);
@ -351,20 +349,23 @@ public class JSONParser {
case Yytoken.TYPE_VALUE:
status = S_IN_FINISHED_VALUE;
statusStack.addFirst(new Integer(status));
if(!contentHandler.primitive(token.value))
if (!contentHandler.primitive(token.value)) {
return;
}
break;
case Yytoken.TYPE_LEFT_BRACE:
status = S_IN_OBJECT;
statusStack.addFirst(new Integer(status));
if(!contentHandler.startObject())
if (!contentHandler.startObject()) {
return;
}
break;
case Yytoken.TYPE_LEFT_SQUARE:
status = S_IN_ARRAY;
statusStack.addFirst(new Integer(status));
if(!contentHandler.startArray())
if (!contentHandler.startArray()) {
return;
}
break;
default:
status = S_IN_ERROR;
@ -377,8 +378,7 @@ public class JSONParser {
contentHandler.endJSON();
status = S_END;
return;
}
else{
} else {
status = S_IN_ERROR;
throw new ParseException(getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, token);
}
@ -393,10 +393,10 @@ public class JSONParser {
String key = (String) token.value;
status = S_PASSED_PAIR_KEY;
statusStack.addFirst(new Integer(status));
if(!contentHandler.startObjectEntry(key))
if (!contentHandler.startObjectEntry(key)) {
return;
}
else{
} else {
status = S_IN_ERROR;
}
break;
@ -404,12 +404,12 @@ public class JSONParser {
if (statusStack.size() > 1) {
statusStack.removeFirst();
status = peekStatus(statusStack);
}
else{
} else {
status = S_IN_FINISHED_VALUE;
}
if(!contentHandler.endObject())
if (!contentHandler.endObject()) {
return;
}
break;
default:
status = S_IN_ERROR;
@ -425,26 +425,30 @@ public class JSONParser {
case Yytoken.TYPE_VALUE:
statusStack.removeFirst();
status = peekStatus(statusStack);
if(!contentHandler.primitive(token.value))
if (!contentHandler.primitive(token.value)) {
return;
if(!contentHandler.endObjectEntry())
}
if (!contentHandler.endObjectEntry()) {
return;
}
break;
case Yytoken.TYPE_LEFT_SQUARE:
statusStack.removeFirst();
statusStack.addFirst(new Integer(S_IN_PAIR_VALUE));
status = S_IN_ARRAY;
statusStack.addFirst(new Integer(status));
if(!contentHandler.startArray())
if (!contentHandler.startArray()) {
return;
}
break;
case Yytoken.TYPE_LEFT_BRACE:
statusStack.removeFirst();
statusStack.addFirst(new Integer(S_IN_PAIR_VALUE));
status = S_IN_OBJECT;
statusStack.addFirst(new Integer(status));
if(!contentHandler.startObject())
if (!contentHandler.startObject()) {
return;
}
break;
default:
status = S_IN_ERROR;
@ -458,8 +462,9 @@ public class JSONParser {
*/
statusStack.removeFirst();
status = peekStatus(statusStack);
if(!contentHandler.endObjectEntry())
if (!contentHandler.endObjectEntry()) {
return;
}
break;
case S_IN_ARRAY:
@ -468,31 +473,34 @@ public class JSONParser {
case Yytoken.TYPE_COMMA:
break;
case Yytoken.TYPE_VALUE:
if(!contentHandler.primitive(token.value))
if (!contentHandler.primitive(token.value)) {
return;
}
break;
case Yytoken.TYPE_RIGHT_SQUARE:
if (statusStack.size() > 1) {
statusStack.removeFirst();
status = peekStatus(statusStack);
}
else{
} else {
status = S_IN_FINISHED_VALUE;
}
if(!contentHandler.endArray())
if (!contentHandler.endArray()) {
return;
}
break;
case Yytoken.TYPE_LEFT_BRACE:
status = S_IN_OBJECT;
statusStack.addFirst(new Integer(status));
if(!contentHandler.startObject())
if (!contentHandler.startObject()) {
return;
}
break;
case Yytoken.TYPE_LEFT_SQUARE:
status = S_IN_ARRAY;
statusStack.addFirst(new Integer(status));
if(!contentHandler.startArray())
if (!contentHandler.startArray()) {
return;
}
break;
default:
status = S_IN_ERROR;
@ -509,20 +517,16 @@ public class JSONParser {
throw new ParseException(getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, token);
}
} while (token.type != Yytoken.TYPE_EOF);
}
catch(IOException ie){
} catch (IOException ie) {
status = S_IN_ERROR;
throw ie;
}
catch(ParseException pe){
} catch (ParseException pe) {
status = S_IN_ERROR;
throw pe;
}
catch(RuntimeException re){
} catch (RuntimeException re) {
status = S_IN_ERROR;
throw re;
}
catch(Error e){
} catch (Error e) {
status = S_IN_ERROR;
throw e;
}

View file

@ -8,11 +8,9 @@ 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;

View file

@ -1,19 +1,14 @@
/* The following code was generated by JFlex 1.4.2 */
package org.json.simple.parser;
class Yylex {
/** This character denotes the end of file */
public static final int YYEOF = -1;
/** initial size of the lookahead buffer */
private static final int ZZ_BUFFERSIZE = 16384;
/** lexical states */
public static final int YYINITIAL = 0;
public static final int STRING_BEGIN = 2;
/**
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
@ -23,33 +18,29 @@ class Yylex {
private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1
};
/**
* Translates characters to character classes
*/
private static final String ZZ_CMAP_PACKED =
"\11\0\1\7\1\7\2\0\1\7\22\0\1\7\1\0\1\11\10\0"+
"\1\6\1\31\1\2\1\4\1\12\12\3\1\32\6\0\4\1\1\5"+
"\1\1\24\0\1\27\1\10\1\30\3\0\1\22\1\13\2\1\1\21"+
"\1\14\5\0\1\23\1\0\1\15\3\0\1\16\1\24\1\17\1\20"+
"\5\0\1\25\1\0\1\26\uff82\0";
"\11\0\1\7\1\7\2\0\1\7\22\0\1\7\1\0\1\11\10\0"
+ "\1\6\1\31\1\2\1\4\1\12\12\3\1\32\6\0\4\1\1\5"
+ "\1\1\24\0\1\27\1\10\1\30\3\0\1\22\1\13\2\1\1\21"
+ "\1\14\5\0\1\23\1\0\1\15\3\0\1\16\1\24\1\17\1\20"
+ "\5\0\1\25\1\0\1\26\uff82\0";
/**
* Translates characters to character classes
*/
private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
/**
* Translates DFA states to action switch labels.
*/
private static final int[] ZZ_ACTION = zzUnpackAction();
private static final String ZZ_ACTION_PACKED_0 =
"\2\0\2\1\1\2\1\3\1\4\3\1\1\5\1\6"+
"\1\7\1\10\1\11\1\12\1\13\1\14\1\15\5\0"+
"\1\14\1\16\1\17\1\20\1\21\1\22\1\23\1\24"+
"\1\0\1\25\1\0\1\25\4\0\1\26\1\27\2\0"+
"\1\30";
"\2\0\2\1\1\2\1\3\1\4\3\1\1\5\1\6"
+ "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\5\0"
+ "\1\14\1\16\1\17\1\20\1\21\1\22\1\23\1\24"
+ "\1\0\1\25\1\0\1\25\4\0\1\26\1\27\2\0"
+ "\1\30";
private static int[] zzUnpackAction() {
int[] result = new int[45];
@ -65,24 +56,23 @@ class Yylex {
while (i < l) {
int count = packed.charAt(i++);
int value = packed.charAt(i++);
do result[j++] = value; while (--count > 0);
do {
result[j++] = value;
} while (--count > 0);
}
return j;
}
/**
* Translates a state to a row index in the transition table
*/
private static final int[] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
"\0\0\0\33\0\66\0\121\0\154\0\207\0\66\0\242"+
"\0\275\0\330\0\66\0\66\0\66\0\66\0\66\0\66"+
"\0\363\0\u010e\0\66\0\u0129\0\u0144\0\u015f\0\u017a\0\u0195"+
"\0\66\0\66\0\66\0\66\0\66\0\66\0\66\0\66"+
"\0\u01b0\0\u01cb\0\u01e6\0\u01e6\0\u0201\0\u021c\0\u0237\0\u0252"+
"\0\66\0\66\0\u026d\0\u0288\0\66";
"\0\0\0\33\0\66\0\121\0\154\0\207\0\66\0\242"
+ "\0\275\0\330\0\66\0\66\0\66\0\66\0\66\0\66"
+ "\0\363\0\u010e\0\66\0\u0129\0\u0144\0\u015f\0\u017a\0\u0195"
+ "\0\66\0\66\0\66\0\66\0\66\0\66\0\66\0\66"
+ "\0\u01b0\0\u01cb\0\u01e6\0\u01e6\0\u0201\0\u021c\0\u0237\0\u0252"
+ "\0\66\0\66\0\u026d\0\u0288\0\66";
private static int[] zzUnpackRowMap() {
int[] result = new int[45];
@ -101,7 +91,6 @@ class Yylex {
}
return j;
}
/**
* The transition table of the DFA
*/
@ -173,8 +162,7 @@ class Yylex {
-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,
};
-1, -1, -1, -1, -1,};
/* error codes */
private static final int ZZ_UNKNOWN_ERROR = 0;
@ -187,16 +175,14 @@ class Yylex {
"Error: could not match input",
"Error: pushback value was too large"
};
/**
* ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
*/
private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\2\0\1\11\3\1\1\11\3\1\6\11\2\1\1\11"+
"\5\0\10\11\1\0\1\1\1\0\1\1\4\0\2\11"+
"\2\0\1\11";
"\2\0\1\11\3\1\1\11\3\1\6\11\2\1\1\11"
+ "\5\0\10\11\1\0\1\1\1\0\1\1\4\0\2\11"
+ "\2\0\1\11";
private static int[] zzUnpackAttribute() {
int[] result = new int[45];
@ -212,54 +198,43 @@ class Yylex {
while (i < l) {
int count = packed.charAt(i++);
int value = packed.charAt(i++);
do result[j++] = value; while (--count > 0);
do {
result[j++] = value;
} while (--count > 0);
}
return j;
}
/** the input device */
private java.io.Reader zzReader;
/** the current state of the DFA */
private int zzState;
/** the current lexical state */
private int zzLexicalState = YYINITIAL;
/** this buffer contains the current text to be matched and is
the source of the yytext() string */
private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
/** the textposition at the last accepting state */
private int zzMarkedPos;
/** the current text position in the buffer */
private int zzCurrentPos;
/** startRead marks the beginning of the yytext() string in the buffer */
private int zzStartRead;
/** endRead marks the last character in the buffer, that has been read
from input */
private int zzEndRead;
/** number of newlines encountered up to the start of the matched text */
private int yyline;
/** the number of characters up to the start of the matched text */
private int yychar;
/**
* the number of characters from the last newline up to the start of the
* matched text
*/
private int yycolumn;
/**
* zzAtBOL == true <=> the scanner is currently at the beginning of a line
*/
private boolean zzAtBOL = true;
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
@ -270,8 +245,6 @@ int getPosition(){
return yychar;
}
/**
* Creates a new scanner
* There is also a java.io.InputStream version of this constructor.
@ -305,12 +278,13 @@ int getPosition(){
while (i < 90) {
int count = packed.charAt(i++);
char value = packed.charAt(i++);
do map[j++] = value; while (--count > 0);
do {
map[j++] = value;
} while (--count > 0);
}
return map;
}
/**
* Refills the input buffer.
*
@ -364,7 +338,6 @@ int getPosition(){
return true;
}
/**
* Closes the input stream.
*/
@ -372,10 +345,10 @@ int getPosition(){
zzAtEOF = true; /* indicate end of file */
zzEndRead = zzStartRead; /* invalidate buffer */
if (zzReader != null)
if (zzReader != null) {
zzReader.close();
}
}
/**
* Resets the scanner to read from a new input stream.
@ -397,7 +370,6 @@ int getPosition(){
zzLexicalState = YYINITIAL;
}
/**
* Returns the current lexical state.
*/
@ -405,7 +377,6 @@ int getPosition(){
return zzLexicalState;
}
/**
* Enters a new lexical state
*
@ -415,7 +386,6 @@ int getPosition(){
zzLexicalState = newState;
}
/**
* Returns the text matched by the current regular expression.
*/
@ -423,7 +393,6 @@ int getPosition(){
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
}
/**
* Returns the character at position <tt>pos</tt> from the
* matched text.
@ -439,7 +408,6 @@ int getPosition(){
return zzBuffer[zzStartRead + pos];
}
/**
* Returns the length of the matched text region.
*/
@ -447,7 +415,6 @@ int getPosition(){
return zzMarkedPos - zzStartRead;
}
/**
* Reports an error that occured while scanning.
*
@ -466,15 +433,13 @@ int getPosition(){
String message;
try {
message = ZZ_ERROR_MSG[errorCode];
}
catch (ArrayIndexOutOfBoundsException e) {
} catch (ArrayIndexOutOfBoundsException e) {
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}
throw new Error(message);
}
/**
* Pushes the specified amount of characters back into the input stream.
*
@ -484,13 +449,13 @@ int getPosition(){
* This number must not be greater than yylength()!
*/
public void yypushback(int number) {
if ( number > yylength() )
if (number > yylength()) {
zzScanError(ZZ_PUSHBACK_2BIG);
}
zzMarkedPos -= number;
}
/**
* Resumes scanning until the next regular expression is matched,
* the end of input is encountered or an I/O-Error occurs.
@ -525,16 +490,16 @@ int getPosition(){
zzState = ZZ_LEXSTATE[zzLexicalState];
zzForAction: {
zzForAction:
{
while (true) {
if (zzCurrentPosL < zzEndReadL)
if (zzCurrentPosL < zzEndReadL) {
zzInput = zzBufferL[zzCurrentPosL++];
else if (zzAtEOF) {
} else if (zzAtEOF) {
zzInput = YYEOF;
break zzForAction;
}
else {
} else {
// store back cached positions
zzCurrentPos = zzCurrentPosL;
zzMarkedPos = zzMarkedPosL;
@ -547,20 +512,23 @@ int getPosition(){
if (eof) {
zzInput = YYEOF;
break zzForAction;
}
else {
} else {
zzInput = zzBufferL[zzCurrentPosL++];
}
}
int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]];
if (zzNext == -1) break zzForAction;
if (zzNext == -1) {
break zzForAction;
}
zzState = zzNext;
int zzAttributes = zzAttrL[zzState];
if ((zzAttributes & 1) == 1) {
zzAction = zzState;
zzMarkedPosL = zzCurrentPosL;
if ( (zzAttributes & 8) == 8 ) break zzForAction;
if ((zzAttributes & 8) == 8) {
break zzForAction;
}
}
}
@ -570,119 +538,143 @@ int getPosition(){
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
case 11:
{ sb.append(yytext());
case 11: {
sb.append(yytext());
}
case 25: break;
case 4:
{ sb.delete(0, sb.length());yybegin(STRING_BEGIN);
case 25:
break;
case 4: {
sb.delete(0, sb.length());
yybegin(STRING_BEGIN);
}
case 26: break;
case 16:
{ sb.append('\b');
case 26:
break;
case 16: {
sb.append('\b');
}
case 27: break;
case 6:
{ return new Yytoken(Yytoken.TYPE_RIGHT_BRACE,null);
case 27:
break;
case 6: {
return new Yytoken(Yytoken.TYPE_RIGHT_BRACE, null);
}
case 28: break;
case 23:
{ Boolean val=Boolean.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);
case 28:
break;
case 23: {
Boolean val = Boolean.valueOf(yytext());
return new Yytoken(Yytoken.TYPE_VALUE, val);
}
case 29: break;
case 22:
{ return new Yytoken(Yytoken.TYPE_VALUE, null);
case 29:
break;
case 22: {
return new Yytoken(Yytoken.TYPE_VALUE, null);
}
case 30: break;
case 13:
{ yybegin(YYINITIAL);return new Yytoken(Yytoken.TYPE_VALUE, sb.toString());
case 30:
break;
case 13: {
yybegin(YYINITIAL);
return new Yytoken(Yytoken.TYPE_VALUE, sb.toString());
}
case 31: break;
case 12:
{ sb.append('\\');
case 31:
break;
case 12: {
sb.append('\\');
}
case 32: break;
case 21:
{ Double val=Double.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);
case 32:
break;
case 21: {
Double val = Double.valueOf(yytext());
return new Yytoken(Yytoken.TYPE_VALUE, val);
}
case 33: break;
case 1:
{ throw new ParseException(yychar, ParseException.ERROR_UNEXPECTED_CHAR, new Character(yycharat(0)));
case 33:
break;
case 1: {
throw new ParseException(yychar, ParseException.ERROR_UNEXPECTED_CHAR, new Character(yycharat(0)));
}
case 34: break;
case 8:
{ return new Yytoken(Yytoken.TYPE_RIGHT_SQUARE,null);
case 34:
break;
case 8: {
return new Yytoken(Yytoken.TYPE_RIGHT_SQUARE, null);
}
case 35: break;
case 19:
{ sb.append('\r');
case 35:
break;
case 19: {
sb.append('\r');
}
case 36: break;
case 15:
{ sb.append('/');
case 36:
break;
case 15: {
sb.append('/');
}
case 37: break;
case 10:
{ return new Yytoken(Yytoken.TYPE_COLON,null);
case 37:
break;
case 10: {
return new Yytoken(Yytoken.TYPE_COLON, null);
}
case 38: break;
case 14:
{ sb.append('"');
case 38:
break;
case 14: {
sb.append('"');
}
case 39: break;
case 5:
{ return new Yytoken(Yytoken.TYPE_LEFT_BRACE,null);
case 39:
break;
case 5: {
return new Yytoken(Yytoken.TYPE_LEFT_BRACE, null);
}
case 40: break;
case 17:
{ sb.append('\f');
case 40:
break;
case 17: {
sb.append('\f');
}
case 41: break;
case 24:
{ try{
case 41:
break;
case 24: {
try {
int ch = Integer.parseInt(yytext().substring(2), 16);
sb.append((char) ch);
}
catch(Exception e){
} catch (Exception e) {
throw new ParseException(yychar, ParseException.ERROR_UNEXPECTED_EXCEPTION, e);
}
}
case 42: break;
case 20:
{ sb.append('\t');
case 42:
break;
case 20: {
sb.append('\t');
}
case 43: break;
case 7:
{ return new Yytoken(Yytoken.TYPE_LEFT_SQUARE,null);
case 43:
break;
case 7: {
return new Yytoken(Yytoken.TYPE_LEFT_SQUARE, null);
}
case 44: break;
case 2:
{ Long val=Long.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);
case 44:
break;
case 2: {
Long val = Long.valueOf(yytext());
return new Yytoken(Yytoken.TYPE_VALUE, val);
}
case 45: break;
case 18:
{ sb.append('\n');
case 45:
break;
case 18: {
sb.append('\n');
}
case 46: break;
case 9:
{ return new Yytoken(Yytoken.TYPE_COMMA,null);
case 46:
break;
case 9: {
return new Yytoken(Yytoken.TYPE_COMMA, null);
}
case 47: break;
case 3:
{
case 47:
break;
case 3: {
}
case 48: break;
case 48:
break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
zzAtEOF = true;
return null;
}
else {
} else {
zzScanError(ZZ_NO_MATCH);
}
}
}
}
}

View file

@ -16,7 +16,6 @@ public class Yytoken {
public static final int TYPE_COMMA = 5;
public static final int TYPE_COLON = 6;
public static final int TYPE_EOF = -1;//end of file
public int type = 0;
public Object value = null;