JDOQL.java :  » Database-ORM » XORM » org » xorm » query » jdoql » Java Open Source

Java Open Source » Database ORM » XORM 
XORM » org » xorm » query » jdoql » JDOQL.java
/* Generated By:JavaCC: Do not edit this line. JDOQL.java */
package org.xorm.query.jdoql;

import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

import org.xorm.query.*;

/**
  This class, generated by JavaCC, contains the grammar described in
  the Java Data Objects specification, transformed from LALR to LL by
  unrolling any instances of left recursion.

  For the sake of clarity, I have removed the production name(),
  which is listed in the JDO spec.  At the raw grammar level,
  we don't have enough contextual information to determine which
  IDs are fields, parameters, or variables.  The symbolic names
  fieldAccess() and methodInvocation() are dealt with inline in
  the _primary() production, rather than having top-level names.

  The output of this parser is an instance of org.xorm.query.Expression
  that represents the Expression parse tree.  Because Expression trees
  can be created from other sources for use in XORM (for example,
  the CodeQuery class converts JVM bytecode to Expressions) I felt it
  was best NOT to use JJTree.

  @author Wes Biggs
*/
public class JDOQL extends AbstractQueryLanguage implements JDOQLConstants {
    /**
     * Test bootstrap.  Allows you to enter JDOQL expressions using
     * STDIN and see the results.  For the purposes of testing,
     * variables var, var2 and var3 and parameters param, param2,
     * and param3 are declared.
     */
    public static void main(String args[]) throws ParseException,
                                                  IOException {
        JDOQL parser = new JDOQL(System.in);

        parser.declareVariable("var", String.class);
        parser.declareVariable("var2", String.class);
        parser.declareVariable("var3", String.class);

        parser.declareParameter("param", String.class);
        parser.declareParameter("param1", String.class);
        parser.declareParameter("param2", String.class);

        while (true) {
            try {
                parser.compile();
                System.out.println("PARSED: " + parser.getExpression());
            } catch (QuerySyntaxException e) {
                if (!e.getCause().getMessage().startsWith("Encountered \"<EOF>\"")) {
                    System.out.println("Error: " + e.getMessage());
                }
                System.exit(1);
            }
            parser.expressions = new Stack();
        }
    }

    private Stack expressions = new Stack();
    private boolean working;
    private boolean compiled;

    public void compile() throws QuerySyntaxException {
        if (expressions.isEmpty()) {
            try {
                expression();
            } catch (ParseException e) {
                throw new QuerySyntaxException(e);
            }
        }
    }

    public JDOQL() {
        this(new StringReader("true"));
    }

    public void setFilter(Object filter) {
        StringReader sr = new StringReader(filter.toString());
        jj_input_stream = new SimpleCharStream(sr, 1, 1);
        token_source = new JDOQLTokenManager(jj_input_stream);
        ReInit(sr);
    }

    public Expression getExpression() {
        return (Expression) expressions.peek();
    }

    private void doMember(Expression here) {
        if (working) {
            if (!expressions.isEmpty() && (expressions.peek() instanceof Expression.Member)) {
                Expression sub = (Expression) expressions.pop();
                // Climb to the top
                Expression.Member top = (Expression.Member) sub;
                if (top != Expression.FieldAccess.THIS) {
                    while (top.getOwner() != Expression.FieldAccess.THIS) {
                        top = (Expression.Member) top.getOwner();
                    }
                }
                ((Expression.Member) top).setOwner(here);
                expressions.push(sub);
            } else {
                expressions.push(here);
            }
        } else {
            expressions.push(here);
            working = true;
        }
    }

    private static final Character SLASH_B = new Character('\b');
    private static final Character SLASH_F = new Character('\f');
    private static final Character SLASH_N = new Character('\n');
    private static final Character SLASH_R = new Character('\r');
    private static final Character SLASH_T = new Character('\t');
    private static final Character SLASH = new Character('\\');
    private static final Character DOUBLE_QUOTE = new Character('\"');
    private static final Character SINGLE_QUOTE = new Character('\'');

    /**
     * Returns the character read after escaping, or null if
     * at the end of the input.
     */
    public static Character readChar(StringReader reader) {
        int i = -1;
        try { i = reader.read(); } catch (IOException ignore) { }
        if (i == -1) return null;
        char ch = (char) i;
        if (ch == '\\') {
            char c2;
            try { c2 = (char) reader.read(); } catch (IOException e) {
                return null;
            }
            switch (c2) {
            case 'b':
                return SLASH_B;
            case 'f':
                return SLASH_F;
            case 'n':
                return SLASH_N;
            case 'r':
                return SLASH_R;
            case 't':
                return SLASH_T;
            case '\'':
                return SINGLE_QUOTE;
            case '\"':
                return DOUBLE_QUOTE;
            case '\\':
                return SLASH;
            }
        }
        return new Character(ch);
    }

  final public void literal() throws ParseException {
  String x; Object o = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case FLOATING_POINT_LITERAL:
      jj_consume_token(FLOATING_POINT_LITERAL);
        x = token.image;
        if (x.endsWith("d") || x.endsWith("D")) {
            o = new Double(x.substring(0, x.length() - 1));
        } else if (x.endsWith("f") || x.endsWith("F")) {
            o = new Float(x.substring(0, x.length() - 1));
        } else {
            o = new Float(x);
        }
        expressions.push(new Expression.Constant(o));
      break;
    case INTEGER_LITERAL:
      jj_consume_token(INTEGER_LITERAL);
        x = token.image;
        if (x.endsWith("l") || x.endsWith("L")) {
            o = new Long(x.substring(0, x.length() - 1));
        } else {
            try {
                o = new Integer(x);
            } catch (NumberFormatException e) {
                // If it's out of the range of an int, make it a long
                o = new Long(x);
            }
        }
        expressions.push(new Expression.Constant(o));
      break;
    case STRING_LITERAL:
      jj_consume_token(STRING_LITERAL);
        StringReader sr = new StringReader(token.image.substring(1, token.image.length() - 1));
        Character ch;
        StringBuffer sb = new StringBuffer();
        while ((ch = readChar(sr)) != null) {
            sb.append(ch.charValue());
        }
        expressions.push(new Expression.Constant(sb.toString()));
      break;
    case CHARACTER_LITERAL:
      jj_consume_token(CHARACTER_LITERAL);
        ch = readChar(new StringReader(token.image.substring(1)));
        expressions.push(new Expression.Constant(ch));
      break;
    case NULL:
      jj_consume_token(NULL);
        expressions.push(Expression.Constant.NULL);
      break;
    case TRUE:
      jj_consume_token(TRUE);
        expressions.push(Expression.Constant.TRUE);
      break;
    case FALSE:
      jj_consume_token(FALSE);
        expressions.push(Expression.Constant.FALSE);
      break;
    default:
      jj_la1[0] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

/**
 * This is an empty-grammar pattern that gives the expression
 * generator a hint that it's now working on a new expression.
 */
  final public void clear() throws ParseException {

        working = false;
  }

/**
 * This is the top-level method that gets called to parse the JDOQL
 * filter expression. 
 */
  final public void expression() throws ParseException {
    conditionalOr();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case EOL:
      jj_consume_token(EOL);
      break;
    default:
      jj_la1[1] = jj_gen;
      ;
    }
  }

  final public void conditionalOr() throws ParseException {
    conditionalAnd();
    _conditionalOr();
  }

  final public void _conditionalOr() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case ORC:
      jj_consume_token(ORC);
      clear();
      conditionalOr();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = (Expression) expressions.pop();
        expressions.push(new Expression.ConditionalOr(lhs, rhs));
      break;
    default:
      jj_la1[2] = jj_gen;

    }
  }

  final public void conditionalAnd() throws ParseException {
    inclusiveOr();
    _conditionalAnd();
  }

  final public void _conditionalAnd() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case ANDC:
      jj_consume_token(ANDC);
      clear();
      conditionalAnd();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = (Expression) expressions.pop();
        expressions.push(new Expression.ConditionalAnd(lhs, rhs));
      break;
    default:
      jj_la1[3] = jj_gen;

    }
  }

  final public void inclusiveOr() throws ParseException {
    exclusiveOr();
    _inclusiveOr();
  }

  final public void _inclusiveOr() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case ORL:
      jj_consume_token(ORL);
      clear();
      inclusiveOr();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = (Expression) expressions.pop();
        expressions.push(new Expression.InclusiveOr(lhs, rhs));
      break;
    default:
      jj_la1[4] = jj_gen;

    }
  }

  final public void exclusiveOr() throws ParseException {
    and();
    _exclusiveOr();
  }

  final public void _exclusiveOr() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case XOR:
      jj_consume_token(XOR);
      clear();
      exclusiveOr();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = (Expression) expressions.pop();
        expressions.push(new Expression.ExclusiveOr(lhs, rhs));
      break;
    default:
      jj_la1[5] = jj_gen;

    }
  }

  final public void and() throws ParseException {
    equality();
    _and();
  }

  final public void _and() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case ANDL:
      jj_consume_token(ANDL);
      clear();
      and();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = (Expression) expressions.pop();
        expressions.push(new Expression.And(lhs, rhs));
      break;
    default:
      jj_la1[6] = jj_gen;

    }
  }

  final public void equality() throws ParseException {
    relational();
    _equality();
  }

  final public void _equality() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case EQ:
      jj_consume_token(EQ);
      clear();
      equality();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = expressions.isEmpty() ?
          Expression.FieldAccess.THIS : (Expression) expressions.pop();
        expressions.push(new Expression.Equal(lhs, rhs));
      break;
    case NE:
      jj_consume_token(NE);
      clear();
      equality();
        rhs = (Expression) expressions.pop();
        lhs = expressions.isEmpty() ?
          Expression.FieldAccess.THIS : (Expression) expressions.pop();
        expressions.push(new Expression.NotEqual(lhs, rhs));
      break;
    default:
      jj_la1[7] = jj_gen;

    }
  }

  final public void relational() throws ParseException {
    additive();
    _relational();
  }

  final public void _relational() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case LT:
      jj_consume_token(LT);
      clear();
      relational();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = (Expression) expressions.pop();
        expressions.push(new Expression.LessThan(lhs, rhs));
      break;
    case LTE:
      jj_consume_token(LTE);
      clear();
      relational();
         rhs = (Expression) expressions.pop();
         lhs = (Expression) expressions.pop();
        expressions.push(new Expression.LessThanEqual(lhs, rhs));
      break;
    case GT:
      jj_consume_token(GT);
      clear();
      relational();
         rhs = (Expression) expressions.pop();
         lhs = (Expression) expressions.pop();
        expressions.push(new Expression.GreaterThan(lhs, rhs));
      break;
    case GTE:
      jj_consume_token(GTE);
      clear();
      relational();
         rhs = (Expression) expressions.pop();
         lhs = (Expression) expressions.pop();
        expressions.push(new Expression.GreaterThanEqual(lhs, rhs));
      break;
    default:
      jj_la1[8] = jj_gen;

    }
  }

  final public void additive() throws ParseException {
    multiplicative();
    _additive();
  }

  final public void _additive() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case PLUS:
      jj_consume_token(PLUS);
      clear();
      additive();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = (Expression) expressions.pop();
        expressions.push(new Expression.Add(lhs, rhs));
      break;
    case MINUS:
      jj_consume_token(MINUS);
      clear();
      additive();
         rhs = (Expression) expressions.pop();
         lhs = (Expression) expressions.pop();
        expressions.push(new Expression.Subtract(lhs, rhs));
      break;
    default:
      jj_la1[9] = jj_gen;

    }
  }

  final public void multiplicative() throws ParseException {
    unary();
    _multiplicative();
  }

  final public void _multiplicative() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case TIMES:
      jj_consume_token(TIMES);
      clear();
      multiplicative();
        Expression rhs = (Expression) expressions.pop();
        Expression lhs = (Expression) expressions.pop();
        expressions.push(new Expression.Multiply(lhs, rhs));
      break;
    case DIVIDE:
      jj_consume_token(DIVIDE);
      clear();
      additive();
         rhs = (Expression) expressions.pop();
         lhs = (Expression) expressions.pop();
        expressions.push(new Expression.Divide(lhs, rhs));
      break;
    default:
      jj_la1[10] = jj_gen;

    }
  }

  final public void unary() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case PLUS:
      jj_consume_token(PLUS);
      unary();

      break;
    case MINUS:
      jj_consume_token(MINUS);
      unary();
        Expression operand = (Expression) expressions.pop();
        expressions.push(new Expression.UnaryMinus(operand));
      break;
    case COMP:
    case NOT:
    case NULL:
    case TRUE:
    case FALSE:
    case THIS:
    case ID:
    case LPAREN:
    case INTEGER_LITERAL:
    case FLOATING_POINT_LITERAL:
    case CHARACTER_LITERAL:
    case STRING_LITERAL:
      unaryNotPlusMinus();
      break;
    default:
      jj_la1[11] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void unaryNotPlusMinus() throws ParseException {
    if (jj_2_1(3)) {
      primary();

    } else {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case COMP:
        jj_consume_token(COMP);
        unary();
        Expression operand = (Expression) expressions.pop();
        expressions.push(new Expression.BitwiseComplement(operand));
        break;
      case NOT:
        jj_consume_token(NOT);
        unary();
        operand = (Expression) expressions.pop();
        expressions.push(new Expression.Not(operand));
        break;
      case LPAREN:
        cast();

        break;
      default:
        jj_la1[12] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
  }

  final public void cast() throws ParseException {
    jj_consume_token(LPAREN);
    type();
    jj_consume_token(RPAREN);
    unary();

  }

  final public void type() throws ParseException {
                Token t;
    t = jj_consume_token(ID);
        System.out.println("type == " + t.image);
  }

  final public void primary() throws ParseException {
                   Token t;
    if (jj_2_2(2)) {
      literal();
      _primary();

    } else if (jj_2_3(2)) {
      jj_consume_token(THIS);
      _primary();

    } else {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ID:
        t = jj_consume_token(ID);
        _primary();
        // We need to determine if this is a field, parameter,
        // or variable.
        Expression here = null;

        // It might be a variable or parameter
        Class clazz;
        if ((clazz = getVariableType(t.image)) != null) {
            here = new Expression.Variable(t.image, clazz);
        } else if ((clazz = getParameterType(t.image)) != null) {
            here = new Expression.Parameter(t.image, clazz);
        } else {
            // It's a field
            // TODO resolve class type from mapping info
            here = new Expression.FieldAccess(Expression.FieldAccess.THIS, t.image, null);
        }
        doMember(here);
        break;
      default:
        jj_la1[13] = jj_gen;
        if (jj_2_4(3)) {
          jj_consume_token(LPAREN);
          expression();
          jj_consume_token(RPAREN);
          _primary();

        } else {
          jj_consume_token(-1);
          throw new ParseException();
        }
      }
    }
  }

  final public void _primary() throws ParseException {
                    Token t;
    if (jj_2_5(3)) {
      jj_consume_token(DOT);
      t = jj_consume_token(ID);
      jj_consume_token(LPAREN);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case COMP:
      case NOT:
      case NULL:
      case TRUE:
      case FALSE:
      case THIS:
      case ID:
      case LPAREN:
      case MINUS:
      case PLUS:
      case INTEGER_LITERAL:
      case FLOATING_POINT_LITERAL:
      case CHARACTER_LITERAL:
      case STRING_LITERAL:
        argumentList();
        break;
      default:
        jj_la1[14] = jj_gen;
        ;
      }
      jj_consume_token(RPAREN);
      _primary();
        Expression[] params;
        if ("startsWith".equals(t.image)
            || "endsWith".equals(t.image)
            || "contains".equals(t.image)
            || "strstr".equals(t.image)
            || "indexOf".equals(t.image)) {
            params = new Expression[] { (Expression) expressions.pop() };
        } else {
            params = new Expression[0];
        }

        Expression here = new Expression.MethodCall(Expression.FieldAccess.THIS, t.image, params, Boolean.class);
        expressions.push(here);
        working = true;
    } else if (jj_2_6(3)) {
      jj_consume_token(DOT);
      t = jj_consume_token(ID);
      _primary();
        Expression here = new Expression.FieldAccess(Expression.FieldAccess.THIS, t.image, null);
        doMember(here);
    } else {

    }
  }

  final public void argumentList() throws ParseException {
    expression();
    _argumentList();
  }

  final public void _argumentList() throws ParseException {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case COMMA:
      jj_consume_token(COMMA);
      clear();
      argumentList();
      break;
    default:
      jj_la1[15] = jj_gen;

    }
  }

  final private boolean jj_2_1(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    boolean retval = !jj_3_1();
    jj_save(0, xla);
    return retval;
  }

  final private boolean jj_2_2(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    boolean retval = !jj_3_2();
    jj_save(1, xla);
    return retval;
  }

  final private boolean jj_2_3(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    boolean retval = !jj_3_3();
    jj_save(2, xla);
    return retval;
  }

  final private boolean jj_2_4(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    boolean retval = !jj_3_4();
    jj_save(3, xla);
    return retval;
  }

  final private boolean jj_2_5(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    boolean retval = !jj_3_5();
    jj_save(4, xla);
    return retval;
  }

  final private boolean jj_2_6(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    boolean retval = !jj_3_6();
    jj_save(5, xla);
    return retval;
  }

  final private boolean jj_3R_24() {
    if (jj_scan_token(ANDC)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_19() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_24()) {
    jj_scanpos = xsp;
    if (jj_3R_25()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_15() {
    if (jj_scan_token(EOL)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_21() {
    return false;
  }

  final private boolean jj_3R_16() {
    if (jj_3R_18()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_19()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3_5() {
    if (jj_scan_token(DOT)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_scan_token(ID)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_scan_token(LPAREN)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_3() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3_5()) {
    jj_scanpos = xsp;
    if (jj_3_6()) {
    jj_scanpos = xsp;
    if (jj_3R_13()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_20() {
    if (jj_scan_token(ORC)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_17() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_20()) {
    jj_scanpos = xsp;
    if (jj_3R_21()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3_4() {
    if (jj_scan_token(LPAREN)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_4()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_scan_token(RPAREN)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_14() {
    if (jj_3R_16()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_17()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_4() {
    if (jj_3R_14()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_15()) jj_scanpos = xsp;
    else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_5() {
    if (jj_scan_token(ID)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_3()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3_3() {
    if (jj_scan_token(THIS)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_3()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_12() {
    if (jj_scan_token(FALSE)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_11() {
    if (jj_scan_token(TRUE)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_1() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3_2()) {
    jj_scanpos = xsp;
    if (jj_3_3()) {
    jj_scanpos = xsp;
    if (jj_3R_5()) {
    jj_scanpos = xsp;
    if (jj_3_4()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3_2() {
    if (jj_3R_2()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_3()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_10() {
    if (jj_scan_token(NULL)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_9() {
    if (jj_scan_token(CHARACTER_LITERAL)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_66() {
    if (jj_scan_token(ID)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_8() {
    if (jj_scan_token(STRING_LITERAL)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_65() {
    if (jj_scan_token(LPAREN)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_66()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_64() {
    if (jj_3R_65()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_63() {
    if (jj_scan_token(NOT)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_50()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_62() {
    if (jj_scan_token(COMP)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_50()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_7() {
    if (jj_scan_token(INTEGER_LITERAL)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3_1() {
    if (jj_3R_1()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_57() {
    if (jj_3R_61()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_61() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3_1()) {
    jj_scanpos = xsp;
    if (jj_3R_62()) {
    jj_scanpos = xsp;
    if (jj_3R_63()) {
    jj_scanpos = xsp;
    if (jj_3R_64()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_56() {
    if (jj_scan_token(MINUS)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_50()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_50() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_55()) {
    jj_scanpos = xsp;
    if (jj_3R_56()) {
    jj_scanpos = xsp;
    if (jj_3R_57()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_55() {
    if (jj_scan_token(PLUS)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_50()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_60() {
    return false;
  }

  final private boolean jj_3R_59() {
    if (jj_scan_token(DIVIDE)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_2() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_6()) {
    jj_scanpos = xsp;
    if (jj_3R_7()) {
    jj_scanpos = xsp;
    if (jj_3R_8()) {
    jj_scanpos = xsp;
    if (jj_3R_9()) {
    jj_scanpos = xsp;
    if (jj_3R_10()) {
    jj_scanpos = xsp;
    if (jj_3R_11()) {
    jj_scanpos = xsp;
    if (jj_3R_12()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_6() {
    if (jj_scan_token(FLOATING_POINT_LITERAL)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_51() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_58()) {
    jj_scanpos = xsp;
    if (jj_3R_59()) {
    jj_scanpos = xsp;
    if (jj_3R_60()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_58() {
    if (jj_scan_token(TIMES)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_43() {
    if (jj_3R_50()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_51()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_54() {
    return false;
  }

  final private boolean jj_3R_53() {
    if (jj_scan_token(MINUS)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_44() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_52()) {
    jj_scanpos = xsp;
    if (jj_3R_53()) {
    jj_scanpos = xsp;
    if (jj_3R_54()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_52() {
    if (jj_scan_token(PLUS)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_38() {
    if (jj_3R_43()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_44()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_49() {
    return false;
  }

  final private boolean jj_3R_48() {
    if (jj_scan_token(GTE)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_47() {
    if (jj_scan_token(GT)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_46() {
    if (jj_scan_token(LTE)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_39() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_45()) {
    jj_scanpos = xsp;
    if (jj_3R_46()) {
    jj_scanpos = xsp;
    if (jj_3R_47()) {
    jj_scanpos = xsp;
    if (jj_3R_48()) {
    jj_scanpos = xsp;
    if (jj_3R_49()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_45() {
    if (jj_scan_token(LT)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_34() {
    if (jj_3R_38()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_39()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_42() {
    return false;
  }

  final private boolean jj_3R_41() {
    if (jj_scan_token(NE)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_35() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_40()) {
    jj_scanpos = xsp;
    if (jj_3R_41()) {
    jj_scanpos = xsp;
    if (jj_3R_42()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_40() {
    if (jj_scan_token(EQ)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_30() {
    if (jj_3R_34()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_35()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_37() {
    return false;
  }

  final private boolean jj_3R_31() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_36()) {
    jj_scanpos = xsp;
    if (jj_3R_37()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_36() {
    if (jj_scan_token(ANDL)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_26() {
    if (jj_3R_30()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_31()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_33() {
    return false;
  }

  final private boolean jj_3R_27() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_32()) {
    jj_scanpos = xsp;
    if (jj_3R_33()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_32() {
    if (jj_scan_token(XOR)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_29() {
    return false;
  }

  final private boolean jj_3R_22() {
    if (jj_3R_26()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_27()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_28() {
    if (jj_scan_token(ORL)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_23() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_28()) {
    jj_scanpos = xsp;
    if (jj_3R_29()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3R_13() {
    return false;
  }

  final private boolean jj_3R_25() {
    return false;
  }

  final private boolean jj_3R_18() {
    if (jj_3R_22()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_23()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  final private boolean jj_3_6() {
    if (jj_scan_token(DOT)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_scan_token(ID)) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    if (jj_3R_3()) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
    return false;
  }

  public JDOQLTokenManager token_source;
  SimpleCharStream jj_input_stream;
  public Token token, jj_nt;
  private int jj_ntk;
  private Token jj_scanpos, jj_lastpos;
  private int jj_la;
  public boolean lookingAhead = false;
  private boolean jj_semLA;
  private int jj_gen;
  final private int[] jj_la1 = new int[16];
  final private int[] jj_la1_0 = {0xe0000,0x0,0x1000,0x400,0x2000,0x4000,0x800,0x30,0x3c0,0x30000000,0xc0000000,0x323f8000,0x2018000,0x200000,0x323f8000,0x0,};
  final private int[] jj_la1_1 = {0x6a0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6a0,0x0,0x0,0x6a0,0x2,};
  final private JJCalls[] jj_2_rtns = new JJCalls[6];
  private boolean jj_rescan = false;
  private int jj_gc = 0;

  public JDOQL(java.io.InputStream stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new JDOQLTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 16; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public void ReInit(java.io.InputStream 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 < 16; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public JDOQL(java.io.Reader stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new JDOQLTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 16; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  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 < 16; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public JDOQL(JDOQLTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 16; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public void ReInit(JDOQLTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 16; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  final 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++;
      if (++jj_gc > 100) {
        jj_gc = 0;
        for (int i = 0; i < jj_2_rtns.length; i++) {
          JJCalls c = jj_2_rtns[i];
          while (c != null) {
            if (c.gen < jj_gen) c.first = null;
            c = c.next;
          }
        }
      }
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  final private boolean jj_scan_token(int kind) {
    if (jj_scanpos == jj_lastpos) {
      jj_la--;
      if (jj_scanpos.next == null) {
        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
      } else {
        jj_lastpos = jj_scanpos = jj_scanpos.next;
      }
    } else {
      jj_scanpos = jj_scanpos.next;
    }
    if (jj_rescan) {
      int i = 0; Token tok = token;
      while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
      if (tok != null) jj_add_error_token(kind, i);
    }
    return (jj_scanpos.kind != kind);
  }

  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;
  }

  final public Token getToken(int index) {
    Token t = lookingAhead ? jj_scanpos : token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  final 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.Vector jj_expentries = new java.util.Vector();
  private int[] jj_expentry;
  private int jj_kind = -1;
  private int[] jj_lasttokens = new int[100];
  private int jj_endpos;

  private void jj_add_error_token(int kind, int pos) {
    if (pos >= 100) return;
    if (pos == jj_endpos + 1) {
      jj_lasttokens[jj_endpos++] = kind;
    } else if (jj_endpos != 0) {
      jj_expentry = new int[jj_endpos];
      for (int i = 0; i < jj_endpos; i++) {
        jj_expentry[i] = jj_lasttokens[i];
      }
      boolean exists = false;
      for (java.util.Enumeration enum = jj_expentries.elements(); enum.hasMoreElements();) {
        int[] oldentry = (int[])(enum.nextElement());
        if (oldentry.length == jj_expentry.length) {
          exists = true;
          for (int i = 0; i < jj_expentry.length; i++) {
            if (oldentry[i] != jj_expentry[i]) {
              exists = false;
              break;
            }
          }
          if (exists) break;
        }
      }
      if (!exists) jj_expentries.addElement(jj_expentry);
      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
    }
  }

  final public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[43];
    for (int i = 0; i < 43; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 16; 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 < 43; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    jj_endpos = 0;
    jj_rescan_token();
    jj_add_error_token(0, 0);
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  final public void enable_tracing() {
  }

  final public void disable_tracing() {
  }

  final private void jj_rescan_token() {
    jj_rescan = true;
    for (int i = 0; i < 6; i++) {
      JJCalls p = jj_2_rtns[i];
      do {
        if (p.gen > jj_gen) {
          jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
          switch (i) {
            case 0: jj_3_1(); break;
            case 1: jj_3_2(); break;
            case 2: jj_3_3(); break;
            case 3: jj_3_4(); break;
            case 4: jj_3_5(); break;
            case 5: jj_3_6(); break;
          }
        }
        p = p.next;
      } while (p != null);
    }
    jj_rescan = false;
  }

  final private void jj_save(int index, int xla) {
    JJCalls p = jj_2_rtns[index];
    while (p.gen > jj_gen) {
      if (p.next == null) { p = p.next = new JJCalls(); break; }
      p = p.next;
    }
    p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
  }

  static final class JJCalls {
    int gen;
    Token first;
    int arg;
    JJCalls next;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.