/* Generated By:JavaCC: Do not edit this line. ThriftParser.java */ package org.apache.athrift.compiler.parser; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.io.File; import java.io.FileReader; import java.io.FileNotFoundException; import java.io.IOException; import org.apache.athrift.compiler.*; import org.apache.athrift.compiler.ConstType; import org.apache.athrift.compiler.ConstValue; import org.apache.athrift.compiler.Enum; import org.apache.athrift.compiler.Field; import org.apache.athrift.compiler.FieldType; import org.apache.athrift.compiler.FieldType_HMap; import org.apache.athrift.compiler.FieldType_List; import org.apache.athrift.compiler.FieldType_Set; import org.apache.athrift.compiler.Function; import org.apache.athrift.compiler.Service; import org.apache.athrift.compiler.Struct; import org.apache.athrift.compiler.ThriftDescriptor; import org.apache.athrift.compiler.ThrowType; import org.apache.athrift.compiler.Typedef; /** * This class is generated with JavaCC. Do not modify manually. */ public class ThriftParser implements ThriftParserConstants { final public ThriftDescriptor generateThriftDescriptor() throws ParseException { ArrayList constantList = new ArrayList(); ArrayList typedefsList = new ArrayList(); ArrayList enumList = new ArrayList(); ArrayList structList = new ArrayList(); ArrayList exceptionList = new ArrayList(); ArrayList serviceList = new ArrayList(); ArrayList includeList = new ArrayList(); ConstType tmpConstType = null; Typedef tmpTypedef = null; Enum tmpEnum = null; Struct tmpStruct = null; Struct tmpException = null; Service tmpService = null; String tmpIncludeFileName = null; label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INCLUDE: tmpIncludeFileName = getIncludeFileName(); includeList.add(tmpIncludeFileName); break; case NAMESPACE: getNamespace(); break; case CONST: tmpConstType = getConstType(); constantList.add(tmpConstType); break; case TYPEDEF: tmpTypedef = getTypedef(); typedefsList.add(tmpTypedef); break; case ENUM: tmpEnum = getEnum(); enumList.add(tmpEnum); break; case STRUCT: tmpStruct = getStruct(); structList.add(tmpStruct); break; case EXCEPTION: tmpException = getException(); exceptionList.add(tmpException); break; case SERVICE: tmpService = getService(); serviceList.add(tmpService); break; default: jj_la1[0] = jj_gen; jj_consume_token(-1); throw new ParseException(); } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRUCT: case SERVICE: case ENUM: case TYPEDEF: case CONST: case EXCEPTION: case NAMESPACE: case INCLUDE: ; break; default: jj_la1[1] = jj_gen; break label_1; } } jj_consume_token(0); ThriftDescriptor rc = new ThriftDescriptor(); rc.setConstantList(constantList); rc.setTypedefsList(typedefsList); rc.setEnumList(enumList); rc.setStructList(structList); rc.setExceptionList(exceptionList); rc.setServiceList(serviceList); rc.setIncludeList(includeList); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public String getIncludeFileName() throws ParseException { Token t; jj_consume_token(INCLUDE); t = jj_consume_token(Literal); {if (true) return t.image;} throw new Error("Missing return statement in function"); } final public void getNamespace() throws ParseException { jj_consume_token(NAMESPACE); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 45: jj_consume_token(45); break; case Identifier: jj_consume_token(Identifier); break; default: jj_la1[2] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(Identifier); } final public ConstType getConstType() throws ParseException { String name; FieldType fieldType; ConstValue constValue; jj_consume_token(CONST); fieldType = getFieldType(); name = getName(); jj_consume_token(EQUALS); constValue = getConstValue(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ListSeparator: jj_consume_token(ListSeparator); break; default: jj_la1[3] = jj_gen; ; } ConstType rc = new ConstType(); rc.setFieldType(fieldType); rc.setName(name); rc.setConstValue(constValue); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public ConstValue getConstValue() throws ParseException { ArrayList<ConstValue> itemList = null; HashMap<ConstValue, ConstValue> hashMapValue = null; String type = null; String value = null; Token t; ConstValue tmpItem; ConstValue tmpKey; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IntConstant: t = jj_consume_token(IntConstant); type = "int"; value = t.image; break; case DoubleConstant: t = jj_consume_token(DoubleConstant); type = "double"; value = t.image; break; case Identifier: t = jj_consume_token(Identifier); type = "identifier"; value = t.image; break; case LBRACKET: jj_consume_token(LBRACKET); label_2: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACE: case LBRACKET: case Identifier: case Literal: case IntConstant: case DoubleConstant: ; break; default: jj_la1[4] = jj_gen; break label_2; } tmpItem = getConstValue(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ListSeparator: jj_consume_token(ListSeparator); break; default: jj_la1[5] = jj_gen; ; } type = "list"; if (itemList == null) { itemList = new ArrayList<ConstValue>(); } itemList.add(tmpItem); } jj_consume_token(RBRACKET); break; case LBRACE: jj_consume_token(LBRACE); label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACE: case LBRACKET: case Identifier: case Literal: case IntConstant: case DoubleConstant: ; break; default: jj_la1[6] = jj_gen; break label_3; } tmpKey = getConstValue(); jj_consume_token(COLON); tmpItem = getConstValue(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ListSeparator: jj_consume_token(ListSeparator); break; default: jj_la1[7] = jj_gen; ; } type = "map"; if (hashMapValue == null) { hashMapValue = new HashMap<ConstValue, ConstValue>(); } hashMapValue.put(tmpKey, tmpItem); } jj_consume_token(RBRACE); break; case Literal: t = jj_consume_token(Literal); type = "string"; value = t.image; break; default: jj_la1[8] = jj_gen; jj_consume_token(-1); throw new ParseException(); } ConstValue rc = new ConstValue(); rc.setType(type); rc.setValue(value); rc.setItemList(itemList); rc.setItemMap(hashMapValue); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public Struct getException() throws ParseException { String name; Field tmpField; ArrayList<Field> fieldList = new ArrayList<Field>(); jj_consume_token(EXCEPTION); name = getName(); jj_consume_token(LBRACE); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MAP: case LIST: case SET: case FieldReq: case Identifier: case FieldID: ; break; default: jj_la1[9] = jj_gen; break label_4; } tmpField = getField(); fieldList.add(tmpField); } jj_consume_token(RBRACE); Struct rc = new Struct(); rc.setName(name); rc.setFieldList(fieldList); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public FieldType getFieldType() throws ParseException { Token t; String type; FieldType tmpContainerType; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MAP: case LIST: case SET: tmpContainerType = getContainerType(); {if (true) return tmpContainerType;} break; case Identifier: t = jj_consume_token(Identifier); type = t.image; break; default: jj_la1[10] = jj_gen; jj_consume_token(-1); throw new ParseException(); } FieldType rc = new FieldType(); rc.setType(type); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public FieldType getContainerType() throws ParseException { FieldType tmpKey; FieldType tmpValue; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MAP: jj_consume_token(MAP); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CppType: jj_consume_token(CppType); break; default: jj_la1[11] = jj_gen; ; } jj_consume_token(LRACKET); tmpKey = getFieldType(); jj_consume_token(ListSeparator); tmpValue = getFieldType(); jj_consume_token(RRACKET); FieldType_HMap tmpFT_HMap = new FieldType_HMap(); tmpFT_HMap.setKeyType(tmpKey); tmpFT_HMap.setValueType(tmpValue); {if (true) return tmpFT_HMap;} break; case SET: jj_consume_token(SET); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CppType: jj_consume_token(CppType); break; default: jj_la1[12] = jj_gen; ; } jj_consume_token(LRACKET); tmpValue = getFieldType(); jj_consume_token(RRACKET); FieldType_Set tmpFT_Set = new FieldType_Set(); tmpFT_Set.setType(tmpValue); {if (true) return tmpFT_Set;} break; case LIST: jj_consume_token(LIST); jj_consume_token(LRACKET); tmpValue = getFieldType(); jj_consume_token(RRACKET); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CppType: jj_consume_token(CppType); break; default: jj_la1[13] = jj_gen; ; } FieldType_List tmpFT_List = new FieldType_List(); tmpFT_List.setType(tmpValue); {if (true) return tmpFT_List;} break; default: jj_la1[14] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public Field getField() throws ParseException { String theFieldID = null; String theFieldReq = null; FieldType theFieldType; String theName = null; ConstValue theDefaultValue = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FieldID: theFieldID = getFieldID(); break; default: jj_la1[15] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FieldReq: theFieldReq = getFieldReq(); break; default: jj_la1[16] = jj_gen; ; } theFieldType = getFieldType(); theName = getName(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQUALS: jj_consume_token(EQUALS); theDefaultValue = getConstValue(); break; default: jj_la1[17] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ListSeparator: jj_consume_token(ListSeparator); break; default: jj_la1[18] = jj_gen; ; } Field rc = new Field(); rc.setFieldID(theFieldID); rc.setFieldReq(theFieldReq); rc.setFieldType(theFieldType); rc.setName(theName); rc.setDefaultValue(theDefaultValue); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public String getName() throws ParseException { Token t; t = jj_consume_token(Identifier); {if (true) return t.image;} throw new Error("Missing return statement in function"); } final public String getFieldID() throws ParseException { Token t; t = jj_consume_token(FieldID); {if (true) return t.image;} throw new Error("Missing return statement in function"); } final public String getFieldReq() throws ParseException { Token t; t = jj_consume_token(FieldReq); {if (true) return t.image;} throw new Error("Missing return statement in function"); } final public Struct getStruct() throws ParseException { String theName; Field theField; ArrayList<Field> theFieldList = new ArrayList<Field>(); jj_consume_token(STRUCT); theName = getName(); jj_consume_token(LBRACE); label_5: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MAP: case LIST: case SET: case FieldReq: case Identifier: case FieldID: ; break; default: jj_la1[19] = jj_gen; break label_5; } theField = getField(); theFieldList.add(theField); } jj_consume_token(RBRACE); Struct rc = new Struct(); rc.setName(theName); rc.setFieldList(theFieldList); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public ThrowType getThrows() throws ParseException { Field theField; ArrayList<Field> theFieldList = new ArrayList<Field>(); jj_consume_token(THROWS); jj_consume_token(LPAREN); label_6: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MAP: case LIST: case SET: case FieldReq: case Identifier: case FieldID: ; break; default: jj_la1[20] = jj_gen; break label_6; } theField = getField(); theFieldList.add(theField); } jj_consume_token(RPAREN); ThrowType rc = new ThrowType(); rc.setFieldList(theFieldList); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public FieldType getFunctionType() throws ParseException { FieldType theFieldType; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MAP: case LIST: case SET: case Identifier: theFieldType = getFieldType(); {if (true) return theFieldType;} break; case VOID: jj_consume_token(VOID); {if (true) return null;} break; default: jj_la1[21] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public Function getFunction() throws ParseException { boolean isOneWay = false; FieldType theFunctionType; String theName; Field theField; ArrayList<Field> theArgsList = new ArrayList<Field>(); ThrowType theThrowType = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ONEWAY: jj_consume_token(ONEWAY); isOneWay = true; break; default: jj_la1[22] = jj_gen; ; } theFunctionType = getFunctionType(); theName = getName(); jj_consume_token(LPAREN); label_7: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MAP: case LIST: case SET: case FieldReq: case Identifier: case FieldID: ; break; default: jj_la1[23] = jj_gen; break label_7; } theField = getField(); theArgsList.add(theField); } jj_consume_token(RPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case THROWS: theThrowType = getThrows(); break; default: jj_la1[24] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ListSeparator: jj_consume_token(ListSeparator); break; default: jj_la1[25] = jj_gen; ; } Function rc = new Function(); rc.setOneWay(isOneWay); rc.setFunctionType(theFunctionType); rc.setName(theName); rc.setArgsList(theArgsList); rc.setThrowType(theThrowType); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public Service getService() throws ParseException { String theName = null; String theExtendService = null; Function theFunction; ArrayList<Function> theFunctionList = new ArrayList<Function>(); jj_consume_token(SERVICE); theName = getName(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EXTENDS: jj_consume_token(EXTENDS); theExtendService = getName(); break; default: jj_la1[26] = jj_gen; ; } jj_consume_token(LBRACE); label_8: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MAP: case LIST: case SET: case VOID: case ONEWAY: case Identifier: ; break; default: jj_la1[27] = jj_gen; break label_8; } theFunction = getFunction(); theFunctionList.add(theFunction); } jj_consume_token(RBRACE); Service rc = new Service(); rc.setName(theName); rc.setExtendService(theExtendService); rc.setFunctionList(theFunctionList); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public Enum getEnum() throws ParseException { String theName; String theItemName; String theIntConstant = null; ArrayList theItemList = new ArrayList(); Token t; String[] strs = null; jj_consume_token(ENUM); theName = getName(); jj_consume_token(LBRACE); label_9: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case Identifier: ; break; default: jj_la1[28] = jj_gen; break label_9; } theItemName = getName(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQUALS: jj_consume_token(EQUALS); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case HEX_LITERAL: t = jj_consume_token(HEX_LITERAL); theIntConstant = t.image; break; case IntConstant: t = jj_consume_token(IntConstant); theIntConstant = t.image; break; default: jj_la1[29] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: jj_la1[30] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ListSeparator: jj_consume_token(ListSeparator); break; default: jj_la1[31] = jj_gen; ; } strs = new String[2]; strs[0] = theItemName; strs[1] = theIntConstant; theItemList.add(strs); theIntConstant = null; } jj_consume_token(RBRACE); Enum rc = new Enum(); rc.setName(theName); rc.setItemList(theItemList); {if (true) return rc;} throw new Error("Missing return statement in function"); } final public Typedef getTypedef() throws ParseException { String theName; FieldType theFieldType; jj_consume_token(TYPEDEF); theFieldType = getFieldType(); theName = getName(); Typedef rc = new Typedef(); rc.setFieldType(theFieldType); rc.setName(theName); {if (true) return rc;} throw new Error("Missing return statement in function"); } /** Generated Token Manager. */ public ThriftParserTokenManager token_source; SimpleCharStream jj_input_stream; /** Current token. */ public Token token; /** Next token. */ public Token jj_nt; private int jj_ntk; private int jj_gen; final private int[] jj_la1 = new int[32]; static private int[] jj_la1_0; static private int[] jj_la1_1; static { jj_la1_init_0(); jj_la1_init_1(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0xf0800000,0xf0800000,0x0,0x0,0x2200,0x0,0x2200,0x0,0x2200,0x700000,0x700000,0x0,0x0,0x0,0x700000,0x0,0x0,0x800,0x0,0x700000,0x700000,0x2700000,0x4000000,0x700000,0x1000000,0x0,0x8000000,0x6700000,0x0,0x0,0x800,0x0,}; } private static void jj_la1_init_1() { jj_la1_1 = new int[] {0xb,0xb,0x2010,0x20,0x350,0x20,0x350,0x20,0x350,0x1014,0x10,0x800,0x800,0x800,0x0,0x1000,0x4,0x0,0x20,0x1014,0x1014,0x10,0x0,0x1014,0x0,0x20,0x0,0x10,0x10,0x180,0x0,0x20,}; } /** Constructor with InputStream. */ public ThriftParser(java.io.InputStream stream) { this(stream, null); } /** Constructor with InputStream and supplied encoding */ public ThriftParser(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 ThriftParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 32; i++) jj_la1[i] = -1; } /** 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 < 32; i++) jj_la1[i] = -1; } /** Constructor. */ public ThriftParser(java.io.Reader stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new ThriftParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 32; i++) jj_la1[i] = -1; } /** 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 < 32; i++) jj_la1[i] = -1; } /** Constructor with generated Token Manager. */ public ThriftParser(ThriftParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 32; i++) jj_la1[i] = -1; } /** Reinitialise. */ public void ReInit(ThriftParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 32; i++) jj_la1[i] = -1; } 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(); } /** Get the next Token. */ 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; } /** Get the specific 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; } 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.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); private int[] jj_expentry; private int jj_kind = -1; /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[46]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 32; 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; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 46; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.add(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = jj_expentries.get(i); } return new ParseException(token, exptokseq, tokenImage); } /** Enable tracing. */ final public void enable_tracing() { } /** Disable tracing. */ final public void disable_tracing() { } }