0001: // $ANTLR 2.7.5 (20050128): "jdoql-ojb-treeparser.g" -> "JDOQLTreeParser.java"$
0002:
0003: package org.apache.ojb.jdo.jdoql;
0004:
0005: /* Copyright 2003-2005 The Apache Software Foundation
0006: *
0007: * Licensed under the Apache License, Version 2.0 (the "License");
0008: * you may not use this file except in compliance with the License.
0009: * You may obtain a copy of the License at
0010: *
0011: * http://www.apache.org/licenses/LICENSE-2.0
0012: *
0013: * Unless required by applicable law or agreed to in writing, software
0014: * distributed under the License is distributed on an "AS IS" BASIS,
0015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016: * See the License for the specific language governing permissions and
0017: * limitations under the License.
0018: */
0019:
0020: import java.util.ArrayList;
0021: import java.util.HashMap;
0022: import java.util.List;
0023: import java.util.Map;
0024:
0025: import antlr.NoViableAltException;
0026: import antlr.RecognitionException;
0027: import antlr.collections.AST;
0028: import antlr.collections.impl.BitSet;
0029:
0030: public class JDOQLTreeParser extends antlr.TreeParser implements
0031: JDOQLTreeParserTokenTypes {
0032: public JDOQLTreeParser() {
0033: tokenNames = _tokenNames;
0034: }
0035:
0036: public final Map declareParameters(AST _t)
0037: throws RecognitionException {
0038: Map result;
0039:
0040: AST declareParameters_AST_in = (_t == ASTNULL) ? null
0041: : (AST) _t;
0042:
0043: LocalVariable varDecl;
0044:
0045: result = new HashMap();
0046:
0047: AST __t2 = _t;
0048: AST tmp1_AST_in = _t;
0049: match(_t, PARAMETERS);
0050: _t = _t.getFirstChild();
0051: {
0052: _loop4: do {
0053: if (_t == null)
0054: _t = ASTNULL;
0055: if ((_t.getType() == PARAMETER)) {
0056: varDecl = parameter(_t);
0057: _t = _retTree;
0058:
0059: result.put(varDecl.getName(), varDecl);
0060:
0061: } else {
0062: break _loop4;
0063: }
0064:
0065: } while (true);
0066: }
0067: _t = __t2;
0068: _t = _t.getNextSibling();
0069: _retTree = _t;
0070: return result;
0071: }
0072:
0073: public final LocalVariable parameter(AST _t)
0074: throws RecognitionException {
0075: LocalVariable varDecl;
0076:
0077: AST parameter_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0078: AST name = null;
0079:
0080: Type varType = null;
0081:
0082: AST __t6 = _t;
0083: AST tmp2_AST_in = _t;
0084: match(_t, PARAMETER);
0085: _t = _t.getFirstChild();
0086: varType = type(_t);
0087: _t = _retTree;
0088: name = _t;
0089: match(_t, IDENTIFIER);
0090: _t = _t.getNextSibling();
0091: _t = __t6;
0092: _t = _t.getNextSibling();
0093:
0094: varDecl = new LocalVariable(varType, name.getText());
0095: varDecl.setPosition(varType.getLine(), varType.getColumn());
0096:
0097: _retTree = _t;
0098: return varDecl;
0099: }
0100:
0101: public final Type type(AST _t) throws RecognitionException {
0102: Type result;
0103:
0104: AST type_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0105: AST primitiveTypeName = null;
0106: AST typeName = null;
0107:
0108: {
0109: if (_t == null)
0110: _t = ASTNULL;
0111: switch (_t.getType()) {
0112: case PRIMITIVE_TYPE: {
0113: primitiveTypeName = _t;
0114: match(_t, PRIMITIVE_TYPE);
0115: _t = _t.getNextSibling();
0116:
0117: result = new Type(primitiveTypeName.getText(), true);
0118: result.setPosition(primitiveTypeName.getLine(),
0119: primitiveTypeName.getColumn());
0120:
0121: break;
0122: }
0123: case NAME: {
0124: typeName = _t;
0125: match(_t, NAME);
0126: _t = _t.getNextSibling();
0127:
0128: result = new Type(typeName.getText(), false);
0129: result.setPosition(typeName.getLine(), typeName
0130: .getColumn());
0131:
0132: break;
0133: }
0134: default: {
0135: throw new NoViableAltException(_t);
0136: }
0137: }
0138: }
0139: _retTree = _t;
0140: return result;
0141: }
0142:
0143: public final Map declareVariables(AST _t)
0144: throws RecognitionException {
0145: Map result;
0146:
0147: AST declareVariables_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0148:
0149: LocalVariable varDecl;
0150:
0151: result = new HashMap();
0152:
0153: AST __t8 = _t;
0154: AST tmp3_AST_in = _t;
0155: match(_t, VARIABLES);
0156: _t = _t.getFirstChild();
0157: {
0158: _loop10: do {
0159: if (_t == null)
0160: _t = ASTNULL;
0161: if ((_t.getType() == VARIABLE)) {
0162: varDecl = variable(_t);
0163: _t = _retTree;
0164:
0165: result.put(varDecl.getName(), varDecl);
0166:
0167: } else {
0168: break _loop10;
0169: }
0170:
0171: } while (true);
0172: }
0173: _t = __t8;
0174: _t = _t.getNextSibling();
0175: _retTree = _t;
0176: return result;
0177: }
0178:
0179: public final LocalVariable variable(AST _t)
0180: throws RecognitionException {
0181: LocalVariable varDecl;
0182:
0183: AST variable_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0184: AST name = null;
0185:
0186: Type varType = null;
0187:
0188: AST __t12 = _t;
0189: AST tmp4_AST_in = _t;
0190: match(_t, VARIABLE);
0191: _t = _t.getFirstChild();
0192: varType = type(_t);
0193: _t = _retTree;
0194: name = _t;
0195: match(_t, IDENTIFIER);
0196: _t = _t.getNextSibling();
0197: _t = __t12;
0198: _t = _t.getNextSibling();
0199:
0200: varDecl = new LocalVariable(varType, name.getText());
0201: varDecl.setPosition(varType.getLine(), varType.getColumn());
0202:
0203: _retTree = _t;
0204: return varDecl;
0205: }
0206:
0207: public final List declareImports(AST _t)
0208: throws RecognitionException {
0209: List result;
0210:
0211: AST declareImports_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0212:
0213: Import importDecl;
0214:
0215: result = new ArrayList();
0216:
0217: AST __t14 = _t;
0218: AST tmp5_AST_in = _t;
0219: match(_t, IMPORTS);
0220: _t = _t.getFirstChild();
0221: {
0222: _loop16: do {
0223: if (_t == null)
0224: _t = ASTNULL;
0225: if ((_t.getType() == IMPORT || _t.getType() == ON_DEMAND_IMPORT)) {
0226: importDecl = importDeclaration(_t);
0227: _t = _retTree;
0228:
0229: result.add(importDecl);
0230:
0231: } else {
0232: break _loop16;
0233: }
0234:
0235: } while (true);
0236: }
0237: _t = __t14;
0238: _t = _t.getNextSibling();
0239: _retTree = _t;
0240: return result;
0241: }
0242:
0243: public final Import importDeclaration(AST _t)
0244: throws RecognitionException {
0245: Import importDecl;
0246:
0247: AST importDeclaration_AST_in = (_t == ASTNULL) ? null
0248: : (AST) _t;
0249: AST i1 = null;
0250: AST name1 = null;
0251: AST i2 = null;
0252: AST name2 = null;
0253:
0254: {
0255: if (_t == null)
0256: _t = ASTNULL;
0257: switch (_t.getType()) {
0258: case IMPORT: {
0259: AST __t19 = _t;
0260: i1 = _t == ASTNULL ? null : (AST) _t;
0261: match(_t, IMPORT);
0262: _t = _t.getFirstChild();
0263: name1 = _t;
0264: match(_t, NAME);
0265: _t = _t.getNextSibling();
0266: _t = __t19;
0267: _t = _t.getNextSibling();
0268:
0269: importDecl = new Import(name1.getText(), false);
0270: importDecl.setPosition(i1.getLine(), i1.getColumn());
0271:
0272: break;
0273: }
0274: case ON_DEMAND_IMPORT: {
0275: AST __t20 = _t;
0276: i2 = _t == ASTNULL ? null : (AST) _t;
0277: match(_t, ON_DEMAND_IMPORT);
0278: _t = _t.getFirstChild();
0279: name2 = _t;
0280: match(_t, NAME);
0281: _t = _t.getNextSibling();
0282: _t = __t20;
0283: _t = _t.getNextSibling();
0284:
0285: importDecl = new Import(name2.getText(), true);
0286: importDecl.setPosition(i2.getLine(), i2.getColumn());
0287:
0288: break;
0289: }
0290: default: {
0291: throw new NoViableAltException(_t);
0292: }
0293: }
0294: }
0295: _retTree = _t;
0296: return importDecl;
0297: }
0298:
0299: public final List setOrdering(AST _t) throws RecognitionException {
0300: List result;
0301:
0302: AST setOrdering_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0303:
0304: Ordering orderingDecl;
0305:
0306: result = new ArrayList();
0307:
0308: AST __t22 = _t;
0309: AST tmp6_AST_in = _t;
0310: match(_t, ORDERSPECS);
0311: _t = _t.getFirstChild();
0312: {
0313: _loop24: do {
0314: if (_t == null)
0315: _t = ASTNULL;
0316: if ((_t.getType() == ORDERSPEC)) {
0317: orderingDecl = orderSpecification(_t);
0318: _t = _retTree;
0319:
0320: result.add(orderingDecl);
0321:
0322: } else {
0323: break _loop24;
0324: }
0325:
0326: } while (true);
0327: }
0328: _t = __t22;
0329: _t = _t.getNextSibling();
0330: _retTree = _t;
0331: return result;
0332: }
0333:
0334: public final Ordering orderSpecification(AST _t)
0335: throws RecognitionException {
0336: Ordering orderingDecl;
0337:
0338: AST orderSpecification_AST_in = (_t == ASTNULL) ? null
0339: : (AST) _t;
0340: AST o = null;
0341:
0342: Expression expr = null;
0343: boolean isAscending;
0344:
0345: AST __t26 = _t;
0346: o = _t == ASTNULL ? null : (AST) _t;
0347: match(_t, ORDERSPEC);
0348: _t = _t.getFirstChild();
0349: expr = expression(_t);
0350: _t = _retTree;
0351: {
0352: if (_t == null)
0353: _t = ASTNULL;
0354: switch (_t.getType()) {
0355: case LITERAL_ASCENDING: {
0356: AST tmp7_AST_in = _t;
0357: match(_t, LITERAL_ASCENDING);
0358: _t = _t.getNextSibling();
0359:
0360: isAscending = true;
0361:
0362: break;
0363: }
0364: case LITERAL_DESCENDING: {
0365: AST tmp8_AST_in = _t;
0366: match(_t, LITERAL_DESCENDING);
0367: _t = _t.getNextSibling();
0368:
0369: isAscending = false;
0370:
0371: break;
0372: }
0373: default: {
0374: throw new NoViableAltException(_t);
0375: }
0376: }
0377: }
0378: _t = __t26;
0379: _t = _t.getNextSibling();
0380:
0381: orderingDecl = new Ordering(expr, isAscending);
0382: orderingDecl.setPosition(o.getLine(), o.getColumn());
0383:
0384: _retTree = _t;
0385: return orderingDecl;
0386: }
0387:
0388: public final Expression expression(AST _t)
0389: throws RecognitionException {
0390: Expression expr;
0391:
0392: AST expression_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0393:
0394: {
0395: if (_t == null)
0396: _t = ASTNULL;
0397: switch (_t.getType()) {
0398: case LITERAL_TRUE:
0399: case LITERAL_FALSE:
0400: case FLOATING_POINT_LITERAL:
0401: case INTEGER_LITERAL:
0402: case CHARACTER_LITERAL:
0403: case STRING_LITERAL: {
0404: expr = literal(_t);
0405: _t = _retTree;
0406: break;
0407: }
0408: case LITERAL_NULL: {
0409: expr = nullLiteral(_t);
0410: _t = _retTree;
0411: break;
0412: }
0413: case LITERAL_THIS: {
0414: expr = this Expression(_t);
0415: _t = _retTree;
0416: break;
0417: }
0418: case OP_GREATER_OR_EQUAL:
0419: case OP_LOWER_OR_EQUAL:
0420: case OP_NOT_EQUAL:
0421: case OP_AND:
0422: case OP_OR:
0423: case OP_EQUAL:
0424: case OP_GREATER:
0425: case OP_LOWER:
0426: case OP_BITWISE_AND:
0427: case OP_BITWISE_OR:
0428: case OP_BITWISE_XOR:
0429: case OP_BINARY_PLUS:
0430: case OP_BINARY_MINUS:
0431: case OP_MULTIPLY:
0432: case OP_DIVIDE: {
0433: expr = binaryExpression(_t);
0434: _t = _retTree;
0435: break;
0436: }
0437: case CAST:
0438: case OP_UNARY_MINUS:
0439: case OP_UNARY_PLUS:
0440: case OP_NOT:
0441: case OP_BITWISE_COMPLEMENT: {
0442: expr = unaryExpression(_t);
0443: _t = _retTree;
0444: break;
0445: }
0446: case METHOD_INVOCATION: {
0447: expr = methodInvocation(_t);
0448: _t = _retTree;
0449: break;
0450: }
0451: case NAME_EXPRESSION: {
0452: expr = nameExpression(_t);
0453: _t = _retTree;
0454: break;
0455: }
0456: case SEP_DOT: {
0457: expr = postfixExpression(_t);
0458: _t = _retTree;
0459: break;
0460: }
0461: default: {
0462: throw new NoViableAltException(_t);
0463: }
0464: }
0465: }
0466: _retTree = _t;
0467: return expr;
0468: }
0469:
0470: public final Literal literal(AST _t) throws RecognitionException {
0471: Literal literal;
0472:
0473: AST literal_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0474: AST l1 = null;
0475: AST l2 = null;
0476: AST l3 = null;
0477: AST l4 = null;
0478: AST l5 = null;
0479: AST l6 = null;
0480:
0481: {
0482: if (_t == null)
0483: _t = ASTNULL;
0484: switch (_t.getType()) {
0485: case LITERAL_TRUE: {
0486: l1 = _t;
0487: match(_t, LITERAL_TRUE);
0488: _t = _t.getNextSibling();
0489:
0490: literal = new Literal(boolean.class, l1.getText());
0491: literal.setPosition(l1.getLine(), l2.getColumn());
0492:
0493: break;
0494: }
0495: case LITERAL_FALSE: {
0496: l2 = _t;
0497: match(_t, LITERAL_FALSE);
0498: _t = _t.getNextSibling();
0499:
0500: literal = new Literal(boolean.class, l2.getText());
0501: literal.setPosition(l2.getLine(), l2.getColumn());
0502:
0503: break;
0504: }
0505: case INTEGER_LITERAL: {
0506: l3 = _t;
0507: match(_t, INTEGER_LITERAL);
0508: _t = _t.getNextSibling();
0509:
0510: literal = new Literal(long.class, l3.getText());
0511: literal.setPosition(l3.getLine(), l3.getColumn());
0512:
0513: break;
0514: }
0515: case FLOATING_POINT_LITERAL: {
0516: l4 = _t;
0517: match(_t, FLOATING_POINT_LITERAL);
0518: _t = _t.getNextSibling();
0519:
0520: literal = new Literal(double.class, l4.getText());
0521: literal.setPosition(l4.getLine(), l4.getColumn());
0522:
0523: break;
0524: }
0525: case CHARACTER_LITERAL: {
0526: l5 = _t;
0527: match(_t, CHARACTER_LITERAL);
0528: _t = _t.getNextSibling();
0529:
0530: literal = new Literal(char.class, l5.getText());
0531: literal.setPosition(l5.getLine(), l5.getColumn());
0532:
0533: break;
0534: }
0535: case STRING_LITERAL: {
0536: l6 = _t;
0537: match(_t, STRING_LITERAL);
0538: _t = _t.getNextSibling();
0539:
0540: literal = new Literal(String.class, l6.getText());
0541: literal.setPosition(l6.getLine(), l6.getColumn());
0542:
0543: break;
0544: }
0545: default: {
0546: throw new NoViableAltException(_t);
0547: }
0548: }
0549: }
0550: _retTree = _t;
0551: return literal;
0552: }
0553:
0554: public final NullLiteral nullLiteral(AST _t)
0555: throws RecognitionException {
0556: NullLiteral literal;
0557:
0558: AST nullLiteral_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0559: AST l = null;
0560:
0561: l = _t;
0562: match(_t, LITERAL_NULL);
0563: _t = _t.getNextSibling();
0564:
0565: literal = new NullLiteral();
0566: literal.setPosition(l.getLine(), l.getColumn());
0567:
0568: _retTree = _t;
0569: return literal;
0570: }
0571:
0572: public final ThisExpression this Expression(AST _t)
0573: throws RecognitionException {
0574: ThisExpression expr;
0575:
0576: AST this Expression_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0577: AST l = null;
0578:
0579: l = _t;
0580: match(_t, LITERAL_THIS);
0581: _t = _t.getNextSibling();
0582:
0583: expr = new ThisExpression();
0584: expr.setPosition(l.getLine(), l.getColumn());
0585:
0586: _retTree = _t;
0587: return expr;
0588: }
0589:
0590: public final BinaryExpression binaryExpression(AST _t)
0591: throws RecognitionException {
0592: BinaryExpression expr;
0593:
0594: AST binaryExpression_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0595: AST o1 = null;
0596: AST o2 = null;
0597: AST o3 = null;
0598: AST o4 = null;
0599: AST o5 = null;
0600: AST o6 = null;
0601: AST o7 = null;
0602: AST o8 = null;
0603: AST o9 = null;
0604: AST o10 = null;
0605: AST o11 = null;
0606: AST o12 = null;
0607: AST o13 = null;
0608: AST o14 = null;
0609: AST o15 = null;
0610:
0611: Expression left = null;
0612: Expression right = null;
0613:
0614: {
0615: if (_t == null)
0616: _t = ASTNULL;
0617: switch (_t.getType()) {
0618: case OP_MULTIPLY: {
0619: AST __t53 = _t;
0620: o1 = _t == ASTNULL ? null : (AST) _t;
0621: match(_t, OP_MULTIPLY);
0622: _t = _t.getFirstChild();
0623: left = expression(_t);
0624: _t = _retTree;
0625: right = expression(_t);
0626: _t = _retTree;
0627: _t = __t53;
0628: _t = _t.getNextSibling();
0629:
0630: expr = new BinaryExpression(left,
0631: BinaryExpression.OPERATOR_MULTIPLY, right);
0632: expr.setPosition(o1.getLine(), o1.getColumn());
0633:
0634: break;
0635: }
0636: case OP_DIVIDE: {
0637: AST __t54 = _t;
0638: o2 = _t == ASTNULL ? null : (AST) _t;
0639: match(_t, OP_DIVIDE);
0640: _t = _t.getFirstChild();
0641: left = expression(_t);
0642: _t = _retTree;
0643: right = expression(_t);
0644: _t = _retTree;
0645: _t = __t54;
0646: _t = _t.getNextSibling();
0647:
0648: expr = new BinaryExpression(left,
0649: BinaryExpression.OPERATOR_DIVIDE, right);
0650: expr.setPosition(o2.getLine(), o2.getColumn());
0651:
0652: break;
0653: }
0654: case OP_BINARY_PLUS: {
0655: AST __t55 = _t;
0656: o3 = _t == ASTNULL ? null : (AST) _t;
0657: match(_t, OP_BINARY_PLUS);
0658: _t = _t.getFirstChild();
0659: left = expression(_t);
0660: _t = _retTree;
0661: right = expression(_t);
0662: _t = _retTree;
0663: _t = __t55;
0664: _t = _t.getNextSibling();
0665:
0666: expr = new BinaryExpression(left,
0667: BinaryExpression.OPERATOR_PLUS, right);
0668: expr.setPosition(o3.getLine(), o3.getColumn());
0669:
0670: break;
0671: }
0672: case OP_BINARY_MINUS: {
0673: AST __t56 = _t;
0674: o4 = _t == ASTNULL ? null : (AST) _t;
0675: match(_t, OP_BINARY_MINUS);
0676: _t = _t.getFirstChild();
0677: left = expression(_t);
0678: _t = _retTree;
0679: right = expression(_t);
0680: _t = _retTree;
0681: _t = __t56;
0682: _t = _t.getNextSibling();
0683:
0684: expr = new BinaryExpression(left,
0685: BinaryExpression.OPERATOR_MINUS, right);
0686: expr.setPosition(o4.getLine(), o4.getColumn());
0687:
0688: break;
0689: }
0690: case OP_LOWER: {
0691: AST __t57 = _t;
0692: o5 = _t == ASTNULL ? null : (AST) _t;
0693: match(_t, OP_LOWER);
0694: _t = _t.getFirstChild();
0695: left = expression(_t);
0696: _t = _retTree;
0697: right = expression(_t);
0698: _t = _retTree;
0699: _t = __t57;
0700: _t = _t.getNextSibling();
0701:
0702: expr = new BinaryExpression(left,
0703: BinaryExpression.OPERATOR_LOWER, right);
0704: expr.setPosition(o5.getLine(), o5.getColumn());
0705:
0706: break;
0707: }
0708: case OP_GREATER: {
0709: AST __t58 = _t;
0710: o6 = _t == ASTNULL ? null : (AST) _t;
0711: match(_t, OP_GREATER);
0712: _t = _t.getFirstChild();
0713: left = expression(_t);
0714: _t = _retTree;
0715: right = expression(_t);
0716: _t = _retTree;
0717: _t = __t58;
0718: _t = _t.getNextSibling();
0719:
0720: expr = new BinaryExpression(left,
0721: BinaryExpression.OPERATOR_GREATER, right);
0722: expr.setPosition(o6.getLine(), o6.getColumn());
0723:
0724: break;
0725: }
0726: case OP_LOWER_OR_EQUAL: {
0727: AST __t59 = _t;
0728: o7 = _t == ASTNULL ? null : (AST) _t;
0729: match(_t, OP_LOWER_OR_EQUAL);
0730: _t = _t.getFirstChild();
0731: left = expression(_t);
0732: _t = _retTree;
0733: right = expression(_t);
0734: _t = _retTree;
0735: _t = __t59;
0736: _t = _t.getNextSibling();
0737:
0738: expr = new BinaryExpression(left,
0739: BinaryExpression.OPERATOR_LOWER_OR_EQUAL, right);
0740: expr.setPosition(o7.getLine(), o7.getColumn());
0741:
0742: break;
0743: }
0744: case OP_GREATER_OR_EQUAL: {
0745: AST __t60 = _t;
0746: o8 = _t == ASTNULL ? null : (AST) _t;
0747: match(_t, OP_GREATER_OR_EQUAL);
0748: _t = _t.getFirstChild();
0749: left = expression(_t);
0750: _t = _retTree;
0751: right = expression(_t);
0752: _t = _retTree;
0753: _t = __t60;
0754: _t = _t.getNextSibling();
0755:
0756: expr = new BinaryExpression(left,
0757: BinaryExpression.OPERATOR_GREATER_OR_EQUAL,
0758: right);
0759: expr.setPosition(o8.getLine(), o8.getColumn());
0760:
0761: break;
0762: }
0763: case OP_EQUAL: {
0764: AST __t61 = _t;
0765: o9 = _t == ASTNULL ? null : (AST) _t;
0766: match(_t, OP_EQUAL);
0767: _t = _t.getFirstChild();
0768: left = expression(_t);
0769: _t = _retTree;
0770: right = expression(_t);
0771: _t = _retTree;
0772: _t = __t61;
0773: _t = _t.getNextSibling();
0774:
0775: expr = new BinaryExpression(left,
0776: BinaryExpression.OPERATOR_EQUAL, right);
0777: expr.setPosition(o9.getLine(), o9.getColumn());
0778:
0779: break;
0780: }
0781: case OP_NOT_EQUAL: {
0782: AST __t62 = _t;
0783: o10 = _t == ASTNULL ? null : (AST) _t;
0784: match(_t, OP_NOT_EQUAL);
0785: _t = _t.getFirstChild();
0786: left = expression(_t);
0787: _t = _retTree;
0788: right = expression(_t);
0789: _t = _retTree;
0790: _t = __t62;
0791: _t = _t.getNextSibling();
0792:
0793: expr = new BinaryExpression(left,
0794: BinaryExpression.OPERATOR_NOT_EQUAL, right);
0795: expr.setPosition(o10.getLine(), o10.getColumn());
0796:
0797: break;
0798: }
0799: case OP_BITWISE_AND: {
0800: AST __t63 = _t;
0801: o11 = _t == ASTNULL ? null : (AST) _t;
0802: match(_t, OP_BITWISE_AND);
0803: _t = _t.getFirstChild();
0804: left = expression(_t);
0805: _t = _retTree;
0806: right = expression(_t);
0807: _t = _retTree;
0808: _t = __t63;
0809: _t = _t.getNextSibling();
0810:
0811: expr = new BinaryExpression(left,
0812: BinaryExpression.OPERATOR_BITWISE_AND, right);
0813: expr.setPosition(o11.getLine(), o11.getColumn());
0814:
0815: break;
0816: }
0817: case OP_BITWISE_XOR: {
0818: AST __t64 = _t;
0819: o12 = _t == ASTNULL ? null : (AST) _t;
0820: match(_t, OP_BITWISE_XOR);
0821: _t = _t.getFirstChild();
0822: left = expression(_t);
0823: _t = _retTree;
0824: right = expression(_t);
0825: _t = _retTree;
0826: _t = __t64;
0827: _t = _t.getNextSibling();
0828:
0829: expr = new BinaryExpression(left,
0830: BinaryExpression.OPERATOR_BITWISE_XOR, right);
0831: expr.setPosition(o12.getLine(), o12.getColumn());
0832:
0833: break;
0834: }
0835: case OP_BITWISE_OR: {
0836: AST __t65 = _t;
0837: o13 = _t == ASTNULL ? null : (AST) _t;
0838: match(_t, OP_BITWISE_OR);
0839: _t = _t.getFirstChild();
0840: left = expression(_t);
0841: _t = _retTree;
0842: right = expression(_t);
0843: _t = _retTree;
0844: _t = __t65;
0845: _t = _t.getNextSibling();
0846:
0847: expr = new BinaryExpression(left,
0848: BinaryExpression.OPERATOR_BITWISE_OR, right);
0849: expr.setPosition(o13.getLine(), o13.getColumn());
0850:
0851: break;
0852: }
0853: case OP_AND: {
0854: AST __t66 = _t;
0855: o14 = _t == ASTNULL ? null : (AST) _t;
0856: match(_t, OP_AND);
0857: _t = _t.getFirstChild();
0858: left = expression(_t);
0859: _t = _retTree;
0860: right = expression(_t);
0861: _t = _retTree;
0862: _t = __t66;
0863: _t = _t.getNextSibling();
0864:
0865: expr = new BinaryExpression(left,
0866: BinaryExpression.OPERATOR_AND, right);
0867: expr.setPosition(o14.getLine(), o14.getColumn());
0868:
0869: break;
0870: }
0871: case OP_OR: {
0872: AST __t67 = _t;
0873: o15 = _t == ASTNULL ? null : (AST) _t;
0874: match(_t, OP_OR);
0875: _t = _t.getFirstChild();
0876: left = expression(_t);
0877: _t = _retTree;
0878: right = expression(_t);
0879: _t = _retTree;
0880: _t = __t67;
0881: _t = _t.getNextSibling();
0882:
0883: expr = new BinaryExpression(left,
0884: BinaryExpression.OPERATOR_OR, right);
0885: expr.setPosition(o15.getLine(), o15.getColumn());
0886:
0887: break;
0888: }
0889: default: {
0890: throw new NoViableAltException(_t);
0891: }
0892: }
0893: }
0894: _retTree = _t;
0895: return expr;
0896: }
0897:
0898: public final UnaryExpression unaryExpression(AST _t)
0899: throws RecognitionException {
0900: UnaryExpression expr;
0901:
0902: AST unaryExpression_AST_in = (_t == ASTNULL) ? null : (AST) _t;
0903: AST o1 = null;
0904: AST o2 = null;
0905: AST o3 = null;
0906: AST o4 = null;
0907: AST o5 = null;
0908:
0909: Expression inner = null;
0910: Type castType = null;
0911:
0912: {
0913: if (_t == null)
0914: _t = ASTNULL;
0915: switch (_t.getType()) {
0916: case OP_UNARY_MINUS: {
0917: AST __t46 = _t;
0918: o1 = _t == ASTNULL ? null : (AST) _t;
0919: match(_t, OP_UNARY_MINUS);
0920: _t = _t.getFirstChild();
0921: inner = expression(_t);
0922: _t = _retTree;
0923: _t = __t46;
0924: _t = _t.getNextSibling();
0925:
0926: expr = new UnaryExpression(
0927: UnaryExpression.OPERATOR_MINUS, inner);
0928: expr.setPosition(o1.getLine(), o1.getColumn());
0929:
0930: break;
0931: }
0932: case OP_UNARY_PLUS: {
0933: AST __t47 = _t;
0934: o2 = _t == ASTNULL ? null : (AST) _t;
0935: match(_t, OP_UNARY_PLUS);
0936: _t = _t.getFirstChild();
0937: inner = expression(_t);
0938: _t = _retTree;
0939: _t = __t47;
0940: _t = _t.getNextSibling();
0941:
0942: expr = new UnaryExpression(
0943: UnaryExpression.OPERATOR_PLUS, inner);
0944: expr.setPosition(o2.getLine(), o2.getColumn());
0945:
0946: break;
0947: }
0948: case OP_BITWISE_COMPLEMENT: {
0949: AST __t48 = _t;
0950: o3 = _t == ASTNULL ? null : (AST) _t;
0951: match(_t, OP_BITWISE_COMPLEMENT);
0952: _t = _t.getFirstChild();
0953: inner = expression(_t);
0954: _t = _retTree;
0955: _t = __t48;
0956: _t = _t.getNextSibling();
0957:
0958: expr = new UnaryExpression(
0959: UnaryExpression.OPERATOR_BITWISE_COMPLEMENT,
0960: inner);
0961: expr.setPosition(o3.getLine(), o3.getColumn());
0962:
0963: break;
0964: }
0965: case OP_NOT: {
0966: AST __t49 = _t;
0967: o4 = _t == ASTNULL ? null : (AST) _t;
0968: match(_t, OP_NOT);
0969: _t = _t.getFirstChild();
0970: inner = expression(_t);
0971: _t = _retTree;
0972: _t = __t49;
0973: _t = _t.getNextSibling();
0974:
0975: expr = new UnaryExpression(
0976: UnaryExpression.OPERATOR_NOT, inner);
0977: expr.setPosition(o4.getLine(), o4.getColumn());
0978:
0979: break;
0980: }
0981: case CAST: {
0982: AST __t50 = _t;
0983: o5 = _t == ASTNULL ? null : (AST) _t;
0984: match(_t, CAST);
0985: _t = _t.getFirstChild();
0986: castType = type(_t);
0987: _t = _retTree;
0988: inner = expression(_t);
0989: _t = _retTree;
0990: _t = __t50;
0991: _t = _t.getNextSibling();
0992:
0993: expr = new UnaryExpression(castType, inner);
0994: expr.setPosition(o5.getLine(), o5.getColumn());
0995:
0996: break;
0997: }
0998: default: {
0999: throw new NoViableAltException(_t);
1000: }
1001: }
1002: }
1003: _retTree = _t;
1004: return expr;
1005: }
1006:
1007: public final MethodInvocation methodInvocation(AST _t)
1008: throws RecognitionException {
1009: MethodInvocation methodInvoc;
1010:
1011: AST methodInvocation_AST_in = (_t == ASTNULL) ? null : (AST) _t;
1012: AST m = null;
1013:
1014: List args = null;
1015:
1016: AST __t35 = _t;
1017: m = _t == ASTNULL ? null : (AST) _t;
1018: match(_t, METHOD_INVOCATION);
1019: _t = _t.getFirstChild();
1020: args = argList(_t);
1021: _t = _retTree;
1022: _t = __t35;
1023: _t = _t.getNextSibling();
1024:
1025: methodInvoc = new MethodInvocation(null, m.getText(), args);
1026: methodInvoc.setPosition(m.getLine(), m.getColumn());
1027:
1028: _retTree = _t;
1029: return methodInvoc;
1030: }
1031:
1032: public final NameExpression nameExpression(AST _t)
1033: throws RecognitionException {
1034: NameExpression nameExpr;
1035:
1036: AST nameExpression_AST_in = (_t == ASTNULL) ? null : (AST) _t;
1037: AST expr = null;
1038:
1039: expr = _t;
1040: match(_t, NAME_EXPRESSION);
1041: _t = _t.getNextSibling();
1042:
1043: nameExpr = new NameExpression(null, expr.getText());
1044: nameExpr.setPosition(expr.getLine(), expr.getColumn());
1045:
1046: _retTree = _t;
1047: return nameExpr;
1048: }
1049:
1050: public final PostfixExpression postfixExpression(AST _t)
1051: throws RecognitionException {
1052: PostfixExpression expr;
1053:
1054: AST postfixExpression_AST_in = (_t == ASTNULL) ? null
1055: : (AST) _t;
1056:
1057: Expression baseExpr = null;
1058: PostfixExpression trailingExpr = null;
1059:
1060: AST __t42 = _t;
1061: AST tmp9_AST_in = _t;
1062: match(_t, SEP_DOT);
1063: _t = _t.getFirstChild();
1064: baseExpr = expression(_t);
1065: _t = _retTree;
1066: {
1067: if (_t == null)
1068: _t = ASTNULL;
1069: switch (_t.getType()) {
1070: case NAME_EXPRESSION: {
1071: trailingExpr = nameExpression(_t);
1072: _t = _retTree;
1073: break;
1074: }
1075: case METHOD_INVOCATION: {
1076: trailingExpr = methodInvocation(_t);
1077: _t = _retTree;
1078: break;
1079: }
1080: default: {
1081: throw new NoViableAltException(_t);
1082: }
1083: }
1084: }
1085: _t = __t42;
1086: _t = _t.getNextSibling();
1087:
1088: expr = trailingExpr;
1089: expr.setBaseExpression(baseExpr);
1090:
1091: _retTree = _t;
1092: return expr;
1093: }
1094:
1095: public final List argList(AST _t) throws RecognitionException {
1096: List args;
1097:
1098: AST argList_AST_in = (_t == ASTNULL) ? null : (AST) _t;
1099:
1100: Expression argExpr = null;
1101:
1102: args = new ArrayList();
1103:
1104: AST __t37 = _t;
1105: AST tmp10_AST_in = _t;
1106: match(_t, ARG_LIST);
1107: _t = _t.getFirstChild();
1108: {
1109: _loop39: do {
1110: if (_t == null)
1111: _t = ASTNULL;
1112: if ((_tokenSet_0.member(_t.getType()))) {
1113: argExpr = expression(_t);
1114: _t = _retTree;
1115:
1116: args.add(argExpr);
1117:
1118: } else {
1119: break _loop39;
1120: }
1121:
1122: } while (true);
1123: }
1124: _t = __t37;
1125: _t = _t.getNextSibling();
1126: _retTree = _t;
1127: return args;
1128: }
1129:
1130: public static final String[] _tokenNames = { "<0>", "EOF", "<2>",
1131: "NULL_TREE_LOOKAHEAD", "PARAMETERS", "PARAMETER",
1132: "VARIABLES", "VARIABLE", "IMPORTS", "IMPORT",
1133: "ON_DEMAND_IMPORT", "ORDERSPECS", "ORDERSPEC", "EXPR",
1134: "CAST", "METHOD_INVOCATION", "ARG_LIST", "NAME_EXPRESSION",
1135: "PRIMITIVE_TYPE", "NAME", "\"import\"", "\"ascending\"",
1136: "\"descending\"", "\"true\"", "\"false\"", "\"null\"",
1137: "\"this\"", "\"boolean\"", "\"byte\"", "\"short\"",
1138: "\"int\"", "\"long\"", "\"char\"", "\"float\"",
1139: "\"double\"", "OP_GREATER_OR_EQUAL", "OP_LOWER_OR_EQUAL",
1140: "OP_NOT_EQUAL", "OP_AND", "OP_OR", "OP_UNARY_MINUS",
1141: "OP_UNARY_PLUS", "SEP_DOT", "FLOATING_POINT_LITERAL",
1142: "INTEGER_LITERAL", "SEP_OPENING_PARENTHESIS",
1143: "SEP_CLOSING_PARENTHESIS", "SEP_SEMICOLON", "SEP_COMMA",
1144: "OP_EQUAL", "OP_GREATER", "OP_LOWER", "OP_NOT",
1145: "OP_BITWISE_COMPLEMENT", "OP_BITWISE_AND", "OP_BITWISE_OR",
1146: "OP_BITWISE_XOR", "OP_BINARY_PLUS", "OP_BINARY_MINUS",
1147: "OP_MULTIPLY", "OP_DIVIDE", "WHITESPACE", "IDENTIFIER",
1148: "CHARACTER_LITERAL", "STRING_LITERAL",
1149: "INT_OR_FLOAT_LITERAL_OR_DOT", "LINE_TERMINATOR",
1150: "ESCAPE_SEQUENCE", "UNICODE_ESCAPE", "OCTAL_ESCAPE",
1151: "OCTAL_DIGIT", "DIGIT", "HEX_DIGIT", "EXPONENT_PART",
1152: "INTEGER_TYPE_SUFFIX", "FLOAT_TYPE_SUFFIX",
1153: "IDENTIFIER_START", "IDENTIFIER_PART" };
1154:
1155: private static final long[] mk_tokenSet_0() {
1156: long[] data = { -6918056827456143360L, 1L, 0L, 0L };
1157: return data;
1158: }
1159:
1160: public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
1161: }
|