0001: /* Generated By:JavaCC: Do not edit this line. SQL.java */
0002: package com.flexive.sqlParser;
0003:
0004: import com.flexive.sqlParser.*;
0005: import java.io.Serializable;
0006: import java.util.ArrayList;
0007:
0008: public class SQL implements SQLConstants {
0009: boolean insideforcedBrace = false;
0010:
0011: /**
0012: * Entry point of the parser.
0013: */
0014: final public FxStatement statement() throws ParseException,
0015: SqlParserException {
0016: FxStatement PI = new FxStatement();
0017: select(PI);
0018: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0019: case END_STMT:
0020: jj_consume_token(END_STMT);
0021: break;
0022: default:
0023: jj_la1[0] = jj_gen;
0024: ;
0025: }
0026: jj_consume_token(0);
0027: PI.cleanup();
0028: {
0029: if (true)
0030: return PI;
0031: }
0032: throw new Error("Missing return statement in function");
0033: }
0034:
0035: /**
0036: * Select expression.
0037: */
0038: final public FxStatement select(final FxStatement PI)
0039: throws ParseException, SqlParserException {
0040: String grp;
0041: String finalQuery = null;
0042: jj_consume_token(SELECT);
0043: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0044: case DISTINCT:
0045: jj_consume_token(DISTINCT);
0046: PI.setDistinct(true);
0047: break;
0048: default:
0049: jj_la1[1] = jj_gen;
0050: ;
0051: }
0052: selectedValues(PI);
0053: from_clause(PI);
0054: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0055: case FILTER:
0056: jj_consume_token(FILTER);
0057: filterList(PI);
0058: break;
0059: default:
0060: jj_la1[2] = jj_gen;
0061: ;
0062: }
0063: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0064: case WHERE:
0065: jj_consume_token(WHERE);
0066: where(PI);
0067: break;
0068: default:
0069: jj_la1[3] = jj_gen;
0070: ;
0071: }
0072: grp = group_by_clause(PI);
0073: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0074: case ORDER_BY:
0075: order_by(PI);
0076: break;
0077: default:
0078: jj_la1[4] = jj_gen;
0079: ;
0080: }
0081: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0082: case UNION:
0083: jj_consume_token(UNION);
0084: {
0085: if (true)
0086: throw new SqlParserException(
0087: "ex.sqlSearch.unionNotSupported");
0088: }
0089: select(PI);
0090: break;
0091: default:
0092: jj_la1[5] = jj_gen;
0093: ;
0094: }
0095: {
0096: if (true)
0097: return PI;
0098: }
0099: throw new Error("Missing return statement in function");
0100: }
0101:
0102: /**
0103: * Order by.
0104: * eg. ORDER BY ct.COL1,ct.COL2 ASC
0105: */
0106: final public void order_by(final FxStatement PI)
0107: throws ParseException, SqlParserException {
0108: jj_consume_token(ORDER_BY);
0109: symItemListOrder(PI);
0110: }
0111:
0112: /**
0113: * Group by.
0114: * eg. GROUP BY ct.COL1,ct.COL2
0115: */
0116: final public String group_by_clause(final FxStatement PI)
0117: throws ParseException {
0118: String grp = "";
0119: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0120: case GROUP_BY:
0121: jj_consume_token(GROUP_BY);
0122: grp = symItemList(PI);
0123: {
0124: if (true)
0125: return "GROUP BY " + grp;
0126: }
0127: break;
0128: default:
0129: jj_la1[6] = jj_gen;
0130: {
0131: if (true)
0132: return "";
0133: }
0134: }
0135: throw new Error("Missing return statement in function");
0136: }
0137:
0138: /**
0139: * Sym item list order.
0140: * For example "<alias.colum> ASC, <alias.colum> DESC, ..."
0141: */
0142: final public void symItemListOrder(final FxStatement PI)
0143: throws ParseException, SqlParserException {
0144: Token tk;
0145: Token ascDesc = null;
0146: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0147: case SYM_SELECT_ITEM:
0148: tk = jj_consume_token(SYM_SELECT_ITEM);
0149: break;
0150: case INTEGER:
0151: tk = jj_consume_token(INTEGER);
0152: break;
0153: default:
0154: jj_la1[7] = jj_gen;
0155: jj_consume_token(-1);
0156: throw new ParseException();
0157: }
0158: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0159: case ASC_DESC:
0160: ascDesc = jj_consume_token(ASC_DESC);
0161: break;
0162: default:
0163: jj_la1[8] = jj_gen;
0164: ;
0165: }
0166: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0167: case LIST_SEPERATOR:
0168: jj_consume_token(LIST_SEPERATOR);
0169: symItemListOrder(PI);
0170: break;
0171: default:
0172: jj_la1[9] = jj_gen;
0173: ;
0174: }
0175: String _sAsc = (ascDesc == null) ? null : ascDesc.image
0176: .toUpperCase();
0177: final boolean asc = (_sAsc == null || _sAsc.indexOf("ASC") != -1) ? true
0178: : false;
0179: PI.addOrderByValue(new OrderByValue(tk.image, asc));
0180: }
0181:
0182: /**
0183: * Sym item list.
0184: * For example "<alias.column>, <alias.column>, ..."
0185: */
0186: final public String symItemList(final FxStatement PI)
0187: throws ParseException {
0188: Token tk;
0189: Token sep = null;
0190: String list = "";
0191: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0192: case SYM_SELECT_ITEM:
0193: tk = jj_consume_token(SYM_SELECT_ITEM);
0194: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0195: case LIST_SEPERATOR:
0196: sep = jj_consume_token(LIST_SEPERATOR);
0197: list = symItemList(PI);
0198: break;
0199: default:
0200: jj_la1[10] = jj_gen;
0201: ;
0202: }
0203: {
0204: if (true)
0205: return tk.image + ((sep != null) ? sep.image : "")
0206: + list;
0207: }
0208: break;
0209: case INTEGER:
0210: tk = jj_consume_token(INTEGER);
0211: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0212: case LIST_SEPERATOR:
0213: sep = jj_consume_token(LIST_SEPERATOR);
0214: list = symItemList(PI);
0215: break;
0216: default:
0217: jj_la1[11] = jj_gen;
0218: ;
0219: }
0220: {
0221: if (true)
0222: return tk.image + ((sep != null) ? sep.image : "")
0223: + list;
0224: }
0225: break;
0226: default:
0227: jj_la1[12] = jj_gen;
0228: jj_consume_token(-1);
0229: throw new ParseException();
0230: }
0231: throw new Error("Missing return statement in function");
0232: }
0233:
0234: /**
0235: * Select list.
0236: * <value>, <value>, ...
0237: */
0238: final public void selectedValues(final FxStatement PI)
0239: throws ParseException, SqlParserException {
0240: Value vi;
0241: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0242: case WILDCARD:
0243: jj_consume_token(WILDCARD);
0244: {
0245: if (true)
0246: throw new SqlParserException(
0247: "ex.sqlSearch.selectAllNotSupported");
0248: }
0249: break;
0250: case BRACE_OPEN:
0251: case NULL:
0252: case FUNCTION:
0253: case INTEGER:
0254: case FLOAT:
0255: case FXPK:
0256: case STRING:
0257: case BOOLEAN:
0258: case SYM_SELECT_ITEM:
0259: vi = selectedValue(PI);
0260: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0261: case LIST_SEPERATOR:
0262: jj_consume_token(LIST_SEPERATOR);
0263: selectedValues(PI);
0264: break;
0265: default:
0266: jj_la1[13] = jj_gen;
0267: ;
0268: }
0269: break;
0270: default:
0271: jj_la1[14] = jj_gen;
0272: jj_consume_token(-1);
0273: throw new ParseException();
0274: }
0275: }
0276:
0277: /**
0278: * Value may be a property, number, or string with our without enclosing functions
0279: */
0280: final public Value selectedValue(final FxStatement PI)
0281: throws ParseException, SqlParserException {
0282: Value vi;
0283: Token t1;
0284: Token alias = null;
0285: Constant con;
0286: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0287: case FUNCTION:
0288: t1 = jj_consume_token(FUNCTION);
0289: vi = selectedValue(PI);
0290: jj_consume_token(BRACE_CLOSE);
0291: {
0292: if (true)
0293: return vi.addFunction(t1.image);
0294: }
0295: break;
0296: case SYM_SELECT_ITEM:
0297: t1 = jj_consume_token(SYM_SELECT_ITEM);
0298: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0299: case IDENTIFIER:
0300: alias = jj_consume_token(IDENTIFIER);
0301: break;
0302: default:
0303: jj_la1[15] = jj_gen;
0304: ;
0305: }
0306: // A property with table alias is referenced
0307: java.util.StringTokenizer st = new java.util.StringTokenizer(
0308: t1.image, ".", false);
0309: String table = st.nextToken();
0310: String property = st.nextToken();
0311: String field = null;
0312: if (st.hasMoreTokens()) {
0313: field = st.nextToken();
0314: }
0315: Property p = new Property(table, property, field);
0316: PI.addSelectedValue(p, alias == null ? null : alias.image);
0317: {
0318: if (true)
0319: return p;
0320: }
0321: break;
0322: case BRACE_OPEN:
0323: case NULL:
0324: case INTEGER:
0325: case FLOAT:
0326: case FXPK:
0327: case STRING:
0328: case BOOLEAN:
0329: con = constantValue();
0330: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0331: case IDENTIFIER:
0332: alias = jj_consume_token(IDENTIFIER);
0333: break;
0334: default:
0335: jj_la1[16] = jj_gen;
0336: ;
0337: }
0338: PI
0339: .addSelectedValue(con, alias == null ? null
0340: : alias.image);
0341: {
0342: if (true)
0343: return con;
0344: }
0345: break;
0346: default:
0347: jj_la1[17] = jj_gen;
0348: jj_consume_token(-1);
0349: throw new ParseException();
0350: }
0351: throw new Error("Missing return statement in function");
0352: }
0353:
0354: /**
0355: * List of all tables to select from.
0356: * Every table must be specified with an alias.
0357: */
0358: final public void from_clause(final FxStatement PI)
0359: throws ParseException, SqlParserException {
0360: jj_consume_token(FROM);
0361: table_list(PI);
0362: }
0363:
0364: /**
0365: * List of tables.
0366: * Every table must specify an alias. The list is comma seperated
0367: */
0368: final public void table_list(final FxStatement PI)
0369: throws ParseException, SqlParserException {
0370: String list = "";
0371: Token table;
0372: Token alias = null;
0373: Token sep = null;
0374: table = jj_consume_token(IDENTIFIER);
0375: if (jj_2_1(2)) {
0376: alias = jj_consume_token(IDENTIFIER);
0377: } else {
0378: ;
0379: }
0380: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0381: case LIST_SEPERATOR:
0382: sep = jj_consume_token(LIST_SEPERATOR);
0383: table_list(PI);
0384: break;
0385: default:
0386: jj_la1[18] = jj_gen;
0387: ;
0388: }
0389: PI.addTable(new Table(table.image, alias.image));
0390: }
0391:
0392: /**
0393: * FleXive FILTER clause.
0394: */
0395: final public void filterList(final FxStatement PI)
0396: throws ParseException, SqlParserException {
0397: Token itemId;
0398: String itemValue;
0399: if (jj_2_2(3)) {
0400: itemId = jj_consume_token(SYM_SELECT_ITEM);
0401: jj_consume_token(EQUALS);
0402: itemValue = filterItem();
0403: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0404: case LIST_SEPERATOR:
0405: jj_consume_token(LIST_SEPERATOR);
0406: filterList(PI);
0407: break;
0408: default:
0409: jj_la1[19] = jj_gen;
0410: ;
0411: }
0412: new Filter(PI, itemId.image, itemValue);
0413: } else {
0414: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0415: case IDENTIFIER:
0416: itemId = jj_consume_token(IDENTIFIER);
0417: jj_consume_token(EQUALS);
0418: itemValue = filterItem();
0419: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0420: case LIST_SEPERATOR:
0421: jj_consume_token(LIST_SEPERATOR);
0422: filterList(PI);
0423: break;
0424: default:
0425: jj_la1[20] = jj_gen;
0426: ;
0427: }
0428: new Filter(PI, itemId.image, itemValue);
0429: break;
0430: default:
0431: jj_la1[21] = jj_gen;
0432: jj_consume_token(-1);
0433: throw new ParseException();
0434: }
0435: }
0436: }
0437:
0438: /**
0439: * Item within the filter
0440: */
0441: final public String filterItem() throws ParseException {
0442: Token item;
0443: String val = null;
0444: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0445: case STRING:
0446: item = jj_consume_token(STRING);
0447: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0448: case 60:
0449: jj_consume_token(60);
0450: val = filterItem();
0451: break;
0452: default:
0453: jj_la1[22] = jj_gen;
0454: ;
0455: }
0456: // Discard starting and ending "'"
0457: {
0458: if (true)
0459: return item.image.substring(1,
0460: item.image.length() - 1)
0461: + ((val != null) ? "|" + val : "");
0462: }
0463: break;
0464: case IDENTIFIER:
0465: item = jj_consume_token(IDENTIFIER);
0466: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0467: case 60:
0468: jj_consume_token(60);
0469: val = filterItem();
0470: break;
0471: default:
0472: jj_la1[23] = jj_gen;
0473: ;
0474: }
0475: {
0476: if (true)
0477: return item.image
0478: + ((val != null) ? "|" + val : "");
0479: }
0480: break;
0481: case INTEGER:
0482: item = jj_consume_token(INTEGER);
0483: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0484: case 60:
0485: jj_consume_token(60);
0486: val = filterItem();
0487: break;
0488: default:
0489: jj_la1[24] = jj_gen;
0490: ;
0491: }
0492: {
0493: if (true)
0494: return item.image
0495: + ((val != null) ? "|" + val : "");
0496: }
0497: break;
0498: case BOOLEAN:
0499: item = jj_consume_token(BOOLEAN);
0500: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0501: case 60:
0502: jj_consume_token(60);
0503: val = filterItem();
0504: break;
0505: default:
0506: jj_la1[25] = jj_gen;
0507: ;
0508: }
0509: {
0510: if (true)
0511: return item.image
0512: + ((val != null) ? "|" + val : "");
0513: }
0514: break;
0515: default:
0516: jj_la1[26] = jj_gen;
0517: jj_consume_token(-1);
0518: throw new ParseException();
0519: }
0520: throw new Error("Missing return statement in function");
0521: }
0522:
0523: /**
0524: * Where clause.
0525: */
0526: final public void where(final FxStatement PI)
0527: throws ParseException, SqlParserException {
0528: String searchc;
0529: Token braceC = null;
0530: Token braceO = null;
0531: Token comOrInt = null;
0532: FxStatement combine = null;
0533: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0534: case BRACE_CI_O:
0535: braceO = jj_consume_token(BRACE_CI_O);
0536: break;
0537: default:
0538: jj_la1[27] = jj_gen;
0539: ;
0540: }
0541: search_condition(PI);
0542: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0543: case BRACE_CI_C:
0544: braceC = jj_consume_token(BRACE_CI_C);
0545: break;
0546: default:
0547: jj_la1[28] = jj_gen;
0548: ;
0549: }
0550:
0551: }
0552:
0553: /**
0554: * Search condition
0555: */
0556: final public void search_condition(final FxStatement PI)
0557: throws ParseException, SqlParserException {
0558: String pred = null;
0559: String sc = "";
0560: Token andOr = null;
0561: String ret = null;
0562: String sAndOr = null;
0563: Token braceO1 = null;
0564: Token braceO2 = null;
0565: Token braceC = null;
0566: Condition cond;
0567: if (jj_2_3(2)) {
0568: jj_consume_token(BRACE_OPEN);
0569: PI.startSubBrace();
0570: search_condition(PI);
0571: jj_consume_token(BRACE_CLOSE);
0572: PI.endSubBrace();
0573: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0574: case AND_OR:
0575: andOr = jj_consume_token(AND_OR);
0576: Brace br = PI.getCurrentBrace();
0577: if (insideforcedBrace) {
0578: Brace parent = br.getParent();
0579: if (parent.getType() == null
0580: || parent.getType().equals(andOr.image)) {
0581: parent.setType(andOr.image);
0582: insideforcedBrace = false;
0583: PI.endSubBrace();
0584: } else {
0585: //
0586: }
0587:
0588: } else {
0589: insideforcedBrace = br.processAndOr(andOr.image,
0590: insideforcedBrace);
0591: }
0592: PI.getCurrentBrace().setType(andOr.image);
0593: search_condition(PI);
0594: break;
0595: default:
0596: jj_la1[29] = jj_gen;
0597: ;
0598: }
0599: } else {
0600: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0601: case BRACE_OPEN:
0602: case IS_CHILD_OF:
0603: case IS_DIRECT_CHILD_OF:
0604: case NULL:
0605: case SUBSTRING:
0606: case FUNCTION:
0607: case INTEGER:
0608: case FLOAT:
0609: case FXPK:
0610: case STRING:
0611: case BOOLEAN:
0612: case IDENTIFIER:
0613: case SYM_SELECT_ITEM:
0614: cond = condition(PI);
0615: Brace br = PI.getCurrentBrace();
0616: br.addElement(cond);
0617: //System.out.println(cond+": type="+br.getType()+" fi="+insideforcedBrace);
0618:
0619: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0620: case AND_OR:
0621: andOr = jj_consume_token(AND_OR);
0622: insideforcedBrace = br.processAndOr(andOr.image,
0623: insideforcedBrace);
0624: search_condition(PI);
0625: break;
0626: default:
0627: jj_la1[30] = jj_gen;
0628: ;
0629: }
0630: break;
0631: default:
0632: jj_la1[31] = jj_gen;
0633: jj_consume_token(-1);
0634: throw new ParseException();
0635: }
0636: }
0637: }
0638:
0639: /**
0640: * Eg. a=b,ct.ID=1,fct(a=b),fct(fct(a))=b,...
0641: */
0642: final public Condition condition(final FxStatement PI)
0643: throws ParseException, SqlParserException {
0644: ConstantArray arr = null;
0645: Value vi1 = null;
0646: Value vi2 = null;
0647: Condition.Comparator fct = null;
0648: Token inNotIn = null;
0649: Token symSel = null;
0650: Token nullToken = null;
0651: Token varFctName = null;
0652: String params = null;
0653: String relationNames = null;
0654: String relationFroms = null;
0655: if (jj_2_4(3)) {
0656: vi1 = value();
0657: fct = comperator(PI);
0658: vi2 = valueOrSubselect(PI);
0659: {
0660: if (true)
0661: return new Condition(PI, vi1, fct, vi2);
0662: }
0663: } else {
0664: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0665: case IS_CHILD_OF:
0666: jj_consume_token(IS_CHILD_OF);
0667: vi1 = valueOrSubselect(PI);
0668: {
0669: if (true)
0670: return new Condition(PI, vi1,
0671: Condition.Comparator.IS_CHILD_OF, null);
0672: }
0673: break;
0674: case IS_DIRECT_CHILD_OF:
0675: jj_consume_token(IS_DIRECT_CHILD_OF);
0676: vi1 = valueOrSubselect(PI);
0677: {
0678: if (true)
0679: return new Condition(
0680: PI,
0681: vi1,
0682: Condition.Comparator.IS_DIRECT_CHILD_OF,
0683: null);
0684: }
0685: break;
0686: case BRACE_OPEN:
0687: case NULL:
0688: case SUBSTRING:
0689: case FUNCTION:
0690: case INTEGER:
0691: case FLOAT:
0692: case FXPK:
0693: case STRING:
0694: case BOOLEAN:
0695: case IDENTIFIER:
0696: case SYM_SELECT_ITEM:
0697: vi1 = value();
0698: inNotIn = jj_consume_token(IN_OR_NOTIN);
0699: jj_consume_token(BRACE_OPEN);
0700: arr = constantArray();
0701: jj_consume_token(BRACE_CLOSE);
0702: {
0703: if (true)
0704: return new Condition(
0705: PI,
0706: vi1,
0707: inNotIn.image.equalsIgnoreCase("IN") ? Condition.Comparator.IN
0708: : Condition.Comparator.NOT_IN,
0709: arr);
0710: }
0711: break;
0712: default:
0713: jj_la1[32] = jj_gen;
0714: jj_consume_token(-1);
0715: throw new ParseException();
0716: }
0717: }
0718: throw new Error("Missing return statement in function");
0719: }
0720:
0721: final public Condition.Comparator comperator(final FxStatement PI)
0722: throws ParseException, SqlParserException {
0723: String id;
0724: String id2 = null;
0725: Token sep = null;
0726: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0727: case LIKE:
0728: jj_consume_token(LIKE);
0729: {
0730: if (true)
0731: return Condition.Comparator.LIKE;
0732: }
0733: break;
0734: case NOT:
0735: jj_consume_token(NOT);
0736: jj_consume_token(LIKE);
0737: {
0738: if (true)
0739: return Condition.Comparator.NOT_LIKE;
0740: }
0741: break;
0742: case EQUALS:
0743: jj_consume_token(EQUALS);
0744: {
0745: if (true)
0746: return Condition.Comparator.EQUAL;
0747: }
0748: break;
0749: case MORE_THAN:
0750: jj_consume_token(MORE_THAN);
0751: {
0752: if (true)
0753: return Condition.Comparator.GREATER;
0754: }
0755: break;
0756: case LESS_THAN:
0757: jj_consume_token(LESS_THAN);
0758: {
0759: if (true)
0760: return Condition.Comparator.LESS;
0761: }
0762: break;
0763: case GEQ:
0764: jj_consume_token(GEQ);
0765: {
0766: if (true)
0767: return Condition.Comparator.GREATER_OR_EQUAL;
0768: }
0769: break;
0770: case LEQ:
0771: jj_consume_token(LEQ);
0772: {
0773: if (true)
0774: return Condition.Comparator.LESS_OR_EQUAL;
0775: }
0776: break;
0777: case NOT_GTR:
0778: jj_consume_token(NOT_GTR);
0779: {
0780: if (true)
0781: return Condition.Comparator.NOT_GREATER;
0782: }
0783: break;
0784: case NOT_LSS:
0785: jj_consume_token(NOT_LSS);
0786: {
0787: if (true)
0788: return Condition.Comparator.NOT_LESS;
0789: }
0790: break;
0791: case NEQ:
0792: jj_consume_token(NEQ);
0793: {
0794: if (true)
0795: return Condition.Comparator.NOT_EQUAL;
0796: }
0797: break;
0798: case NEQ2:
0799: jj_consume_token(NEQ2);
0800: {
0801: if (true)
0802: return Condition.Comparator.NOT_EQUAL;
0803: }
0804: break;
0805: case NEAR:
0806: jj_consume_token(NEAR);
0807: {
0808: if (true)
0809: return Condition.Comparator.NEAR;
0810: }
0811: break;
0812: case IS:
0813: jj_consume_token(IS);
0814: {
0815: if (true)
0816: return Condition.Comparator.IS;
0817: }
0818: break;
0819: case IS_NOT:
0820: jj_consume_token(IS_NOT);
0821: {
0822: if (true)
0823: return Condition.Comparator.IS_NOT;
0824: }
0825: break;
0826: default:
0827: jj_la1[33] = jj_gen;
0828: jj_consume_token(-1);
0829: throw new ParseException();
0830: }
0831: throw new Error("Missing return statement in function");
0832: }
0833:
0834: final public Value valueOrSubselect(final FxStatement PI)
0835: throws ParseException, SqlParserException {
0836: Value vi;
0837: vi = value();
0838: {
0839: if (true)
0840: return vi;
0841: }
0842: throw new Error("Missing return statement in function");
0843: }
0844:
0845: /**
0846: * Value may be a property, number, or string with our without enclosing functions
0847: */
0848: final public Value value() throws ParseException,
0849: SqlParserException {
0850: Value vi;
0851: Token t1, nr1, nr2;
0852: String sel;
0853: Constant con;
0854: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0855: case FUNCTION:
0856: t1 = jj_consume_token(FUNCTION);
0857: vi = value();
0858: jj_consume_token(BRACE_CLOSE);
0859: {
0860: if (true)
0861: return vi.addFunction(t1.image);
0862: }
0863: break;
0864: case SUBSTRING:
0865: jj_consume_token(SUBSTRING);
0866: jj_consume_token(BRACE_OPEN);
0867: vi = value();
0868: jj_consume_token(LIST_SEPERATOR);
0869: nr1 = jj_consume_token(INTEGER);
0870: jj_consume_token(LIST_SEPERATOR);
0871: nr2 = jj_consume_token(INTEGER);
0872: jj_consume_token(BRACE_CLOSE);
0873: {
0874: if (true)
0875: throw new SqlParserException(
0876: "ex.sqlSearch.substringNotSupported");
0877: }
0878: break;
0879: case IDENTIFIER:
0880: t1 = jj_consume_token(IDENTIFIER);
0881: // A property with NO table alias is referenced
0882: {
0883: if (true)
0884: throw new SqlParserException(
0885: "ex.sqlSearch.identifierIsNotAllowedHere",
0886: t1.image);
0887: }
0888: break;
0889: case SYM_SELECT_ITEM:
0890: t1 = jj_consume_token(SYM_SELECT_ITEM);
0891: // A property with table alias is referenced
0892: java.util.StringTokenizer st = new java.util.StringTokenizer(
0893: t1.image, ".", false);
0894: String table = st.nextToken();
0895: String property = st.nextToken();
0896: String field = null;
0897: if (st.hasMoreTokens()) {
0898: field = st.nextToken();
0899: }
0900: {
0901: if (true)
0902: return new Property(table, property, field);
0903: }
0904: break;
0905: default:
0906: jj_la1[34] = jj_gen;
0907: if (jj_2_5(3)) {
0908: jj_consume_token(BRACE_OPEN);
0909: con = constantArray();
0910: jj_consume_token(BRACE_CLOSE);
0911: {
0912: if (true)
0913: return con;
0914: }
0915: } else if (jj_2_6(3)) {
0916: con = constantValue();
0917: {
0918: if (true)
0919: return con;
0920: }
0921: } else {
0922: jj_consume_token(-1);
0923: throw new ParseException();
0924: }
0925: }
0926: throw new Error("Missing return statement in function");
0927: }
0928:
0929: /**
0930: * Constant value: number string or null
0931: */
0932: final public Constant constantValue() throws ParseException {
0933: Token t1 = null;
0934: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
0935: case BRACE_OPEN:
0936: jj_consume_token(BRACE_OPEN);
0937: constantValue();
0938: jj_consume_token(BRACE_CLOSE);
0939: break;
0940: case STRING:
0941: t1 = jj_consume_token(STRING);
0942: // Remove quotes: return new Constant(t1.image.substring(1,t1.image.length()-1));
0943: {
0944: if (true)
0945: return new Constant(t1.image);
0946: }
0947: break;
0948: case INTEGER:
0949: t1 = jj_consume_token(INTEGER);
0950: {
0951: if (true)
0952: return new Constant(t1.image);
0953: }
0954: break;
0955: case FLOAT:
0956: t1 = jj_consume_token(FLOAT);
0957: {
0958: if (true)
0959: return new Constant(t1.image);
0960: }
0961: break;
0962: case BOOLEAN:
0963: t1 = jj_consume_token(BOOLEAN);
0964: {
0965: if (true)
0966: return new Constant(t1.image);
0967: }
0968: break;
0969: case FXPK:
0970: t1 = jj_consume_token(FXPK);
0971: {
0972: if (true)
0973: return new Constant(t1.image);
0974: }
0975: break;
0976: case NULL:
0977: jj_consume_token(NULL);
0978: {
0979: if (true)
0980: return new Constant(null);
0981: }
0982: break;
0983: default:
0984: jj_la1[35] = jj_gen;
0985: jj_consume_token(-1);
0986: throw new ParseException();
0987: }
0988: throw new Error("Missing return statement in function");
0989: }
0990:
0991: /**
0992: * Returns a value list as array
0993: */
0994: final public ConstantArray constantArray() throws ParseException,
0995: SqlParserException {
0996: Constant con;
0997: ConstantArray arr = null;
0998: con = constantValue();
0999: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
1000: case LIST_SEPERATOR:
1001: jj_consume_token(LIST_SEPERATOR);
1002: arr = constantArray();
1003: break;
1004: default:
1005: jj_la1[36] = jj_gen;
1006: ;
1007: }
1008: if (arr != null) {
1009: {
1010: if (true)
1011: return arr.add(con);
1012: }
1013: } else {
1014: {
1015: if (true)
1016: return new ConstantArray(new Constant[] { con });
1017: }
1018: }
1019: throw new Error("Missing return statement in function");
1020: }
1021:
1022: final private boolean jj_2_1(int xla) {
1023: jj_la = xla;
1024: jj_lastpos = jj_scanpos = token;
1025: try {
1026: return !jj_3_1();
1027: } catch (LookaheadSuccess ls) {
1028: return true;
1029: } finally {
1030: jj_save(0, xla);
1031: }
1032: }
1033:
1034: final private boolean jj_2_2(int xla) {
1035: jj_la = xla;
1036: jj_lastpos = jj_scanpos = token;
1037: try {
1038: return !jj_3_2();
1039: } catch (LookaheadSuccess ls) {
1040: return true;
1041: } finally {
1042: jj_save(1, xla);
1043: }
1044: }
1045:
1046: final private boolean jj_2_3(int xla) {
1047: jj_la = xla;
1048: jj_lastpos = jj_scanpos = token;
1049: try {
1050: return !jj_3_3();
1051: } catch (LookaheadSuccess ls) {
1052: return true;
1053: } finally {
1054: jj_save(2, xla);
1055: }
1056: }
1057:
1058: final private boolean jj_2_4(int xla) {
1059: jj_la = xla;
1060: jj_lastpos = jj_scanpos = token;
1061: try {
1062: return !jj_3_4();
1063: } catch (LookaheadSuccess ls) {
1064: return true;
1065: } finally {
1066: jj_save(3, xla);
1067: }
1068: }
1069:
1070: final private boolean jj_2_5(int xla) {
1071: jj_la = xla;
1072: jj_lastpos = jj_scanpos = token;
1073: try {
1074: return !jj_3_5();
1075: } catch (LookaheadSuccess ls) {
1076: return true;
1077: } finally {
1078: jj_save(4, xla);
1079: }
1080: }
1081:
1082: final private boolean jj_2_6(int xla) {
1083: jj_la = xla;
1084: jj_lastpos = jj_scanpos = token;
1085: try {
1086: return !jj_3_6();
1087: } catch (LookaheadSuccess ls) {
1088: return true;
1089: } finally {
1090: jj_save(5, xla);
1091: }
1092: }
1093:
1094: final private boolean jj_3R_14() {
1095: if (jj_scan_token(SUBSTRING))
1096: return true;
1097: if (jj_scan_token(BRACE_OPEN))
1098: return true;
1099: if (jj_3R_3())
1100: return true;
1101: return false;
1102: }
1103:
1104: final private boolean jj_3R_3() {
1105: Token xsp;
1106: xsp = jj_scanpos;
1107: if (jj_3R_13()) {
1108: jj_scanpos = xsp;
1109: if (jj_3R_14()) {
1110: jj_scanpos = xsp;
1111: if (jj_3R_15()) {
1112: jj_scanpos = xsp;
1113: if (jj_3R_16()) {
1114: jj_scanpos = xsp;
1115: if (jj_3_5()) {
1116: jj_scanpos = xsp;
1117: if (jj_3_6())
1118: return true;
1119: }
1120: }
1121: }
1122: }
1123: }
1124: return false;
1125: }
1126:
1127: final private boolean jj_3R_13() {
1128: if (jj_scan_token(FUNCTION))
1129: return true;
1130: if (jj_3R_3())
1131: return true;
1132: if (jj_scan_token(BRACE_CLOSE))
1133: return true;
1134: return false;
1135: }
1136:
1137: final private boolean jj_3R_11() {
1138: if (jj_scan_token(BOOLEAN))
1139: return true;
1140: return false;
1141: }
1142:
1143: final private boolean jj_3R_10() {
1144: if (jj_scan_token(INTEGER))
1145: return true;
1146: return false;
1147: }
1148:
1149: final private boolean jj_3R_6() {
1150: if (jj_3R_7())
1151: return true;
1152: Token xsp;
1153: xsp = jj_scanpos;
1154: if (jj_3R_31())
1155: jj_scanpos = xsp;
1156: return false;
1157: }
1158:
1159: final private boolean jj_3R_9() {
1160: if (jj_scan_token(IDENTIFIER))
1161: return true;
1162: return false;
1163: }
1164:
1165: final private boolean jj_3R_8() {
1166: if (jj_scan_token(STRING))
1167: return true;
1168: return false;
1169: }
1170:
1171: final private boolean jj_3R_1() {
1172: Token xsp;
1173: xsp = jj_scanpos;
1174: if (jj_3R_8()) {
1175: jj_scanpos = xsp;
1176: if (jj_3R_9()) {
1177: jj_scanpos = xsp;
1178: if (jj_3R_10()) {
1179: jj_scanpos = xsp;
1180: if (jj_3R_11())
1181: return true;
1182: }
1183: }
1184: }
1185: return false;
1186: }
1187:
1188: final private boolean jj_3R_5() {
1189: if (jj_3R_3())
1190: return true;
1191: return false;
1192: }
1193:
1194: final private boolean jj_3R_38() {
1195: if (jj_scan_token(NULL))
1196: return true;
1197: return false;
1198: }
1199:
1200: final private boolean jj_3R_12() {
1201: if (jj_3R_39())
1202: return true;
1203: return false;
1204: }
1205:
1206: final private boolean jj_3_1() {
1207: if (jj_scan_token(IDENTIFIER))
1208: return true;
1209: return false;
1210: }
1211:
1212: final private boolean jj_3R_37() {
1213: if (jj_scan_token(FXPK))
1214: return true;
1215: return false;
1216: }
1217:
1218: final private boolean jj_3R_36() {
1219: if (jj_scan_token(BOOLEAN))
1220: return true;
1221: return false;
1222: }
1223:
1224: final private boolean jj_3_2() {
1225: if (jj_scan_token(SYM_SELECT_ITEM))
1226: return true;
1227: if (jj_scan_token(EQUALS))
1228: return true;
1229: if (jj_3R_1())
1230: return true;
1231: return false;
1232: }
1233:
1234: final private boolean jj_3R_30() {
1235: if (jj_scan_token(IS_NOT))
1236: return true;
1237: return false;
1238: }
1239:
1240: final private boolean jj_3R_35() {
1241: if (jj_scan_token(FLOAT))
1242: return true;
1243: return false;
1244: }
1245:
1246: final private boolean jj_3R_29() {
1247: if (jj_scan_token(IS))
1248: return true;
1249: return false;
1250: }
1251:
1252: final private boolean jj_3R_28() {
1253: if (jj_scan_token(NEAR))
1254: return true;
1255: return false;
1256: }
1257:
1258: final private boolean jj_3R_27() {
1259: if (jj_scan_token(NEQ2))
1260: return true;
1261: return false;
1262: }
1263:
1264: final private boolean jj_3R_34() {
1265: if (jj_scan_token(INTEGER))
1266: return true;
1267: return false;
1268: }
1269:
1270: final private boolean jj_3R_26() {
1271: if (jj_scan_token(NEQ))
1272: return true;
1273: return false;
1274: }
1275:
1276: final private boolean jj_3R_25() {
1277: if (jj_scan_token(NOT_LSS))
1278: return true;
1279: return false;
1280: }
1281:
1282: final private boolean jj_3R_24() {
1283: if (jj_scan_token(NOT_GTR))
1284: return true;
1285: return false;
1286: }
1287:
1288: final private boolean jj_3R_33() {
1289: if (jj_scan_token(STRING))
1290: return true;
1291: return false;
1292: }
1293:
1294: final private boolean jj_3R_23() {
1295: if (jj_scan_token(LEQ))
1296: return true;
1297: return false;
1298: }
1299:
1300: final private boolean jj_3R_22() {
1301: if (jj_scan_token(GEQ))
1302: return true;
1303: return false;
1304: }
1305:
1306: final private boolean jj_3R_21() {
1307: if (jj_scan_token(LESS_THAN))
1308: return true;
1309: return false;
1310: }
1311:
1312: final private boolean jj_3R_32() {
1313: if (jj_scan_token(BRACE_OPEN))
1314: return true;
1315: if (jj_3R_7())
1316: return true;
1317: if (jj_scan_token(BRACE_CLOSE))
1318: return true;
1319: return false;
1320: }
1321:
1322: final private boolean jj_3R_7() {
1323: Token xsp;
1324: xsp = jj_scanpos;
1325: if (jj_3R_32()) {
1326: jj_scanpos = xsp;
1327: if (jj_3R_33()) {
1328: jj_scanpos = xsp;
1329: if (jj_3R_34()) {
1330: jj_scanpos = xsp;
1331: if (jj_3R_35()) {
1332: jj_scanpos = xsp;
1333: if (jj_3R_36()) {
1334: jj_scanpos = xsp;
1335: if (jj_3R_37()) {
1336: jj_scanpos = xsp;
1337: if (jj_3R_38())
1338: return true;
1339: }
1340: }
1341: }
1342: }
1343: }
1344: }
1345: return false;
1346: }
1347:
1348: final private boolean jj_3R_20() {
1349: if (jj_scan_token(MORE_THAN))
1350: return true;
1351: return false;
1352: }
1353:
1354: final private boolean jj_3_3() {
1355: if (jj_scan_token(BRACE_OPEN))
1356: return true;
1357: if (jj_3R_2())
1358: return true;
1359: return false;
1360: }
1361:
1362: final private boolean jj_3R_2() {
1363: Token xsp;
1364: xsp = jj_scanpos;
1365: if (jj_3_3()) {
1366: jj_scanpos = xsp;
1367: if (jj_3R_12())
1368: return true;
1369: }
1370: return false;
1371: }
1372:
1373: final private boolean jj_3R_19() {
1374: if (jj_scan_token(EQUALS))
1375: return true;
1376: return false;
1377: }
1378:
1379: final private boolean jj_3R_18() {
1380: if (jj_scan_token(NOT))
1381: return true;
1382: if (jj_scan_token(LIKE))
1383: return true;
1384: return false;
1385: }
1386:
1387: final private boolean jj_3_6() {
1388: if (jj_3R_7())
1389: return true;
1390: return false;
1391: }
1392:
1393: final private boolean jj_3R_4() {
1394: Token xsp;
1395: xsp = jj_scanpos;
1396: if (jj_3R_17()) {
1397: jj_scanpos = xsp;
1398: if (jj_3R_18()) {
1399: jj_scanpos = xsp;
1400: if (jj_3R_19()) {
1401: jj_scanpos = xsp;
1402: if (jj_3R_20()) {
1403: jj_scanpos = xsp;
1404: if (jj_3R_21()) {
1405: jj_scanpos = xsp;
1406: if (jj_3R_22()) {
1407: jj_scanpos = xsp;
1408: if (jj_3R_23()) {
1409: jj_scanpos = xsp;
1410: if (jj_3R_24()) {
1411: jj_scanpos = xsp;
1412: if (jj_3R_25()) {
1413: jj_scanpos = xsp;
1414: if (jj_3R_26()) {
1415: jj_scanpos = xsp;
1416: if (jj_3R_27()) {
1417: jj_scanpos = xsp;
1418: if (jj_3R_28()) {
1419: jj_scanpos = xsp;
1420: if (jj_3R_29()) {
1421: jj_scanpos = xsp;
1422: if (jj_3R_30())
1423: return true;
1424: }
1425: }
1426: }
1427: }
1428: }
1429: }
1430: }
1431: }
1432: }
1433: }
1434: }
1435: }
1436: }
1437: return false;
1438: }
1439:
1440: final private boolean jj_3R_17() {
1441: if (jj_scan_token(LIKE))
1442: return true;
1443: return false;
1444: }
1445:
1446: final private boolean jj_3_5() {
1447: if (jj_scan_token(BRACE_OPEN))
1448: return true;
1449: if (jj_3R_6())
1450: return true;
1451: if (jj_scan_token(BRACE_CLOSE))
1452: return true;
1453: return false;
1454: }
1455:
1456: final private boolean jj_3R_42() {
1457: if (jj_3R_3())
1458: return true;
1459: return false;
1460: }
1461:
1462: final private boolean jj_3R_41() {
1463: if (jj_scan_token(IS_DIRECT_CHILD_OF))
1464: return true;
1465: return false;
1466: }
1467:
1468: final private boolean jj_3R_16() {
1469: if (jj_scan_token(SYM_SELECT_ITEM))
1470: return true;
1471: return false;
1472: }
1473:
1474: final private boolean jj_3R_40() {
1475: if (jj_scan_token(IS_CHILD_OF))
1476: return true;
1477: return false;
1478: }
1479:
1480: final private boolean jj_3R_31() {
1481: if (jj_scan_token(LIST_SEPERATOR))
1482: return true;
1483: return false;
1484: }
1485:
1486: final private boolean jj_3R_15() {
1487: if (jj_scan_token(IDENTIFIER))
1488: return true;
1489: return false;
1490: }
1491:
1492: final private boolean jj_3R_39() {
1493: Token xsp;
1494: xsp = jj_scanpos;
1495: if (jj_3_4()) {
1496: jj_scanpos = xsp;
1497: if (jj_3R_40()) {
1498: jj_scanpos = xsp;
1499: if (jj_3R_41()) {
1500: jj_scanpos = xsp;
1501: if (jj_3R_42())
1502: return true;
1503: }
1504: }
1505: }
1506: return false;
1507: }
1508:
1509: final private boolean jj_3_4() {
1510: if (jj_3R_3())
1511: return true;
1512: if (jj_3R_4())
1513: return true;
1514: if (jj_3R_5())
1515: return true;
1516: return false;
1517: }
1518:
1519: public SQLTokenManager token_source;
1520: SimpleCharStream jj_input_stream;
1521: public Token token, jj_nt;
1522: private int jj_ntk;
1523: private Token jj_scanpos, jj_lastpos;
1524: private int jj_la;
1525: public boolean lookingAhead = false;
1526: private boolean jj_semLA;
1527: private int jj_gen;
1528: final private int[] jj_la1 = new int[37];
1529: static private int[] jj_la1_0;
1530: static private int[] jj_la1_1;
1531: static {
1532: jj_la1_0();
1533: jj_la1_1();
1534: }
1535:
1536: private static void jj_la1_0() {
1537: jj_la1_0 = new int[] { 0x0, 0x0, 0x100000, 0x80000, 0x0,
1538: 0x400000, 0x8000, 0x0, 0x20000, 0x0, 0x0, 0x0, 0x0,
1539: 0x0, 0x2000, 0x0, 0x0, 0x2000, 0x0, 0x0, 0x0, 0x0, 0x0,
1540: 0x0, 0x0, 0x0, 0x0, 0x800, 0x1000, 0x10000, 0x10000,
1541: 0xc0002000, 0xc0002000, 0x3fa00000, 0x0, 0x2000, 0x0, };
1542: }
1543:
1544: private static void jj_la1_1() {
1545: jj_la1_1 = new int[] { 0x20000, 0x4000, 0x0, 0x0, 0x800, 0x0,
1546: 0x0, 0x8100000, 0x0, 0x2000000, 0x2000000, 0x2000000,
1547: 0x8100000, 0x2000000, 0x9fc0020, 0x4000000, 0x4000000,
1548: 0x9f40020, 0x2000000, 0x2000000, 0x2000000, 0x4000000,
1549: 0x10000000, 0x10000000, 0x10000000, 0x10000000,
1550: 0x5900000, 0x0, 0x0, 0x0, 0x0, 0xdf400a0, 0xdf400a0,
1551: 0x5f, 0xc040080, 0x1f00020, 0x2000000, };
1552: }
1553:
1554: final private JJCalls[] jj_2_rtns = new JJCalls[6];
1555: private boolean jj_rescan = false;
1556: private int jj_gc = 0;
1557:
1558: public SQL(java.io.InputStream stream) {
1559: this (stream, null);
1560: }
1561:
1562: public SQL(java.io.InputStream stream, String encoding) {
1563: try {
1564: jj_input_stream = new SimpleCharStream(stream, encoding, 1,
1565: 1);
1566: } catch (java.io.UnsupportedEncodingException e) {
1567: throw new RuntimeException(e);
1568: }
1569: token_source = new SQLTokenManager(jj_input_stream);
1570: token = new Token();
1571: jj_ntk = -1;
1572: jj_gen = 0;
1573: for (int i = 0; i < 37; i++)
1574: jj_la1[i] = -1;
1575: for (int i = 0; i < jj_2_rtns.length; i++)
1576: jj_2_rtns[i] = new JJCalls();
1577: }
1578:
1579: public void ReInit(java.io.InputStream stream) {
1580: ReInit(stream, null);
1581: }
1582:
1583: public void ReInit(java.io.InputStream stream, String encoding) {
1584: try {
1585: jj_input_stream.ReInit(stream, encoding, 1, 1);
1586: } catch (java.io.UnsupportedEncodingException e) {
1587: throw new RuntimeException(e);
1588: }
1589: token_source.ReInit(jj_input_stream);
1590: token = new Token();
1591: jj_ntk = -1;
1592: jj_gen = 0;
1593: for (int i = 0; i < 37; i++)
1594: jj_la1[i] = -1;
1595: for (int i = 0; i < jj_2_rtns.length; i++)
1596: jj_2_rtns[i] = new JJCalls();
1597: }
1598:
1599: public SQL(java.io.Reader stream) {
1600: jj_input_stream = new SimpleCharStream(stream, 1, 1);
1601: token_source = new SQLTokenManager(jj_input_stream);
1602: token = new Token();
1603: jj_ntk = -1;
1604: jj_gen = 0;
1605: for (int i = 0; i < 37; i++)
1606: jj_la1[i] = -1;
1607: for (int i = 0; i < jj_2_rtns.length; i++)
1608: jj_2_rtns[i] = new JJCalls();
1609: }
1610:
1611: public void ReInit(java.io.Reader stream) {
1612: jj_input_stream.ReInit(stream, 1, 1);
1613: token_source.ReInit(jj_input_stream);
1614: token = new Token();
1615: jj_ntk = -1;
1616: jj_gen = 0;
1617: for (int i = 0; i < 37; i++)
1618: jj_la1[i] = -1;
1619: for (int i = 0; i < jj_2_rtns.length; i++)
1620: jj_2_rtns[i] = new JJCalls();
1621: }
1622:
1623: public SQL(SQLTokenManager tm) {
1624: token_source = tm;
1625: token = new Token();
1626: jj_ntk = -1;
1627: jj_gen = 0;
1628: for (int i = 0; i < 37; i++)
1629: jj_la1[i] = -1;
1630: for (int i = 0; i < jj_2_rtns.length; i++)
1631: jj_2_rtns[i] = new JJCalls();
1632: }
1633:
1634: public void ReInit(SQLTokenManager tm) {
1635: token_source = tm;
1636: token = new Token();
1637: jj_ntk = -1;
1638: jj_gen = 0;
1639: for (int i = 0; i < 37; i++)
1640: jj_la1[i] = -1;
1641: for (int i = 0; i < jj_2_rtns.length; i++)
1642: jj_2_rtns[i] = new JJCalls();
1643: }
1644:
1645: final private Token jj_consume_token(int kind)
1646: throws ParseException {
1647: Token oldToken;
1648: if ((oldToken = token).next != null)
1649: token = token.next;
1650: else
1651: token = token.next = token_source.getNextToken();
1652: jj_ntk = -1;
1653: if (token.kind == kind) {
1654: jj_gen++;
1655: if (++jj_gc > 100) {
1656: jj_gc = 0;
1657: for (int i = 0; i < jj_2_rtns.length; i++) {
1658: JJCalls c = jj_2_rtns[i];
1659: while (c != null) {
1660: if (c.gen < jj_gen)
1661: c.first = null;
1662: c = c.next;
1663: }
1664: }
1665: }
1666: return token;
1667: }
1668: token = oldToken;
1669: jj_kind = kind;
1670: throw generateParseException();
1671: }
1672:
1673: static private final class LookaheadSuccess extends java.lang.Error {
1674: }
1675:
1676: final private LookaheadSuccess jj_ls = new LookaheadSuccess();
1677:
1678: final private boolean jj_scan_token(int kind) {
1679: if (jj_scanpos == jj_lastpos) {
1680: jj_la--;
1681: if (jj_scanpos.next == null) {
1682: jj_lastpos = jj_scanpos = jj_scanpos.next = token_source
1683: .getNextToken();
1684: } else {
1685: jj_lastpos = jj_scanpos = jj_scanpos.next;
1686: }
1687: } else {
1688: jj_scanpos = jj_scanpos.next;
1689: }
1690: if (jj_rescan) {
1691: int i = 0;
1692: Token tok = token;
1693: while (tok != null && tok != jj_scanpos) {
1694: i++;
1695: tok = tok.next;
1696: }
1697: if (tok != null)
1698: jj_add_error_token(kind, i);
1699: }
1700: if (jj_scanpos.kind != kind)
1701: return true;
1702: if (jj_la == 0 && jj_scanpos == jj_lastpos)
1703: throw jj_ls;
1704: return false;
1705: }
1706:
1707: final public Token getNextToken() {
1708: if (token.next != null)
1709: token = token.next;
1710: else
1711: token = token.next = token_source.getNextToken();
1712: jj_ntk = -1;
1713: jj_gen++;
1714: return token;
1715: }
1716:
1717: final public Token getToken(int index) {
1718: Token t = lookingAhead ? jj_scanpos : token;
1719: for (int i = 0; i < index; i++) {
1720: if (t.next != null)
1721: t = t.next;
1722: else
1723: t = t.next = token_source.getNextToken();
1724: }
1725: return t;
1726: }
1727:
1728: final private int jj_ntk() {
1729: if ((jj_nt = token.next) == null)
1730: return (jj_ntk = (token.next = token_source.getNextToken()).kind);
1731: else
1732: return (jj_ntk = jj_nt.kind);
1733: }
1734:
1735: private java.util.Vector jj_expentries = new java.util.Vector();
1736: private int[] jj_expentry;
1737: private int jj_kind = -1;
1738: private int[] jj_lasttokens = new int[100];
1739: private int jj_endpos;
1740:
1741: private void jj_add_error_token(int kind, int pos) {
1742: if (pos >= 100)
1743: return;
1744: if (pos == jj_endpos + 1) {
1745: jj_lasttokens[jj_endpos++] = kind;
1746: } else if (jj_endpos != 0) {
1747: jj_expentry = new int[jj_endpos];
1748: for (int i = 0; i < jj_endpos; i++) {
1749: jj_expentry[i] = jj_lasttokens[i];
1750: }
1751: boolean exists = false;
1752: for (java.util.Enumeration e = jj_expentries.elements(); e
1753: .hasMoreElements();) {
1754: int[] oldentry = (int[]) (e.nextElement());
1755: if (oldentry.length == jj_expentry.length) {
1756: exists = true;
1757: for (int i = 0; i < jj_expentry.length; i++) {
1758: if (oldentry[i] != jj_expentry[i]) {
1759: exists = false;
1760: break;
1761: }
1762: }
1763: if (exists)
1764: break;
1765: }
1766: }
1767: if (!exists)
1768: jj_expentries.addElement(jj_expentry);
1769: if (pos != 0)
1770: jj_lasttokens[(jj_endpos = pos) - 1] = kind;
1771: }
1772: }
1773:
1774: public ParseException generateParseException() {
1775: jj_expentries.removeAllElements();
1776: boolean[] la1tokens = new boolean[61];
1777: for (int i = 0; i < 61; i++) {
1778: la1tokens[i] = false;
1779: }
1780: if (jj_kind >= 0) {
1781: la1tokens[jj_kind] = true;
1782: jj_kind = -1;
1783: }
1784: for (int i = 0; i < 37; i++) {
1785: if (jj_la1[i] == jj_gen) {
1786: for (int j = 0; j < 32; j++) {
1787: if ((jj_la1_0[i] & (1 << j)) != 0) {
1788: la1tokens[j] = true;
1789: }
1790: if ((jj_la1_1[i] & (1 << j)) != 0) {
1791: la1tokens[32 + j] = true;
1792: }
1793: }
1794: }
1795: }
1796: for (int i = 0; i < 61; i++) {
1797: if (la1tokens[i]) {
1798: jj_expentry = new int[1];
1799: jj_expentry[0] = i;
1800: jj_expentries.addElement(jj_expentry);
1801: }
1802: }
1803: jj_endpos = 0;
1804: jj_rescan_token();
1805: jj_add_error_token(0, 0);
1806: int[][] exptokseq = new int[jj_expentries.size()][];
1807: for (int i = 0; i < jj_expentries.size(); i++) {
1808: exptokseq[i] = (int[]) jj_expentries.elementAt(i);
1809: }
1810: return new ParseException(token, exptokseq, tokenImage);
1811: }
1812:
1813: final public void enable_tracing() {
1814: }
1815:
1816: final public void disable_tracing() {
1817: }
1818:
1819: final private void jj_rescan_token() {
1820: jj_rescan = true;
1821: for (int i = 0; i < 6; i++) {
1822: try {
1823: JJCalls p = jj_2_rtns[i];
1824: do {
1825: if (p.gen > jj_gen) {
1826: jj_la = p.arg;
1827: jj_lastpos = jj_scanpos = p.first;
1828: switch (i) {
1829: case 0:
1830: jj_3_1();
1831: break;
1832: case 1:
1833: jj_3_2();
1834: break;
1835: case 2:
1836: jj_3_3();
1837: break;
1838: case 3:
1839: jj_3_4();
1840: break;
1841: case 4:
1842: jj_3_5();
1843: break;
1844: case 5:
1845: jj_3_6();
1846: break;
1847: }
1848: }
1849: p = p.next;
1850: } while (p != null);
1851: } catch (LookaheadSuccess ls) {
1852: }
1853: }
1854: jj_rescan = false;
1855: }
1856:
1857: final private void jj_save(int index, int xla) {
1858: JJCalls p = jj_2_rtns[index];
1859: while (p.gen > jj_gen) {
1860: if (p.next == null) {
1861: p = p.next = new JJCalls();
1862: break;
1863: }
1864: p = p.next;
1865: }
1866: p.gen = jj_gen + xla - jj_la;
1867: p.first = token;
1868: p.arg = xla;
1869: }
1870:
1871: static final class JJCalls {
1872: int gen;
1873: Token first;
1874: int arg;
1875: JJCalls next;
1876: }
1877:
1878: }
|