xpathparser.java

来自「JXPath」· Java 代码 · 共 2,233 行 · 第 1/5 页

JAVA
2,233
字号
      jj_consume_token(AND);
      r = EqualityExpr();
                if (list == null){
                    list = new ArrayList();
                    list.add(ex);
                }
                list.add(r);
    }
        if (list != null){
            ex = compiler.and(list.toArray());
        }
        {if (true) return ex;}
    throw new Error("Missing return statement in function");
  }

/* [23] EqualityExpr    ::=    RelationalExpr | EqualityExpr '=' RelationalExpr | EqualityExpr '!=' RelationalExpr */
  final public Object EqualityExpr() throws ParseException {
 Object ex, r;
    ex = RelationalExpr();
    label_10:
    while (true) {
      switch (jj_nt.kind) {
      case EQ:
      case NEQ:
        ;
        break;
      default:
        jj_la1[26] = jj_gen;
        break label_10;
      }
      switch (jj_nt.kind) {
      case EQ:
        jj_consume_token(EQ);
        r = RelationalExpr();
                                          ex = compiler.equal(ex, r);
        break;
      case NEQ:
        jj_consume_token(NEQ);
        r = RelationalExpr();
                                          ex = compiler.notEqual(ex, r);
        break;
      default:
        jj_la1[27] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
        {if (true) return ex;}
    throw new Error("Missing return statement in function");
  }

/* [24] RelationalExpr    ::=    AdditiveExpr | RelationalExpr '<' AdditiveExpr | RelationalExpr '>' AdditiveExpr
                       | RelationalExpr '<=' AdditiveExpr  | RelationalExpr '>=' AdditiveExpr */
  final public Object RelationalExpr() throws ParseException {
 Object ex, r;
    ex = AdditiveExpr();
    label_11:
    while (true) {
      switch (jj_nt.kind) {
      case LT:
      case LTE:
      case GT:
      case GTE:
        ;
        break;
      default:
        jj_la1[28] = jj_gen;
        break label_11;
      }
      switch (jj_nt.kind) {
      case LT:
        jj_consume_token(LT);
        r = AdditiveExpr();
                                        ex = compiler.lessThan(ex, r);
        break;
      case GT:
        jj_consume_token(GT);
        r = AdditiveExpr();
                                        ex = compiler.greaterThan(ex, r);
        break;
      case LTE:
        jj_consume_token(LTE);
        r = AdditiveExpr();
                                        ex = compiler.lessThanOrEqual(ex, r);
        break;
      case GTE:
        jj_consume_token(GTE);
        r = AdditiveExpr();
                                        ex = compiler.greaterThanOrEqual(ex, r);
        break;
      default:
        jj_la1[29] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
        {if (true) return ex;}
    throw new Error("Missing return statement in function");
  }

/*-------------*/
/* 3.5 Numbers */
/*-------------*/

/* [25] AdditiveExpr ::= MultiplicativeExpr  | AdditiveExpr '+' MultiplicativeExpr  | AdditiveExpr '-' MultiplicativeExpr  */
  final public Object AdditiveExpr() throws ParseException {
    Object ex, r;
    ArrayList list = null;
    ex = SubtractiveExpr();
    label_12:
    while (true) {
      switch (jj_nt.kind) {
      case PLUS:
        ;
        break;
      default:
        jj_la1[30] = jj_gen;
        break label_12;
      }
      jj_consume_token(PLUS);
      r = SubtractiveExpr();
                if (list == null){
                    list = new ArrayList();
                    list.add(ex);
                }
                list.add(r);
    }
        if (list != null){
            ex = compiler.sum(list.toArray());
        }
        {if (true) return ex;}
    throw new Error("Missing return statement in function");
  }

  final public Object SubtractiveExpr() throws ParseException {
    Object ex, r = null;
    ex = MultiplicativeExpr();
    label_13:
    while (true) {
      switch (jj_nt.kind) {
      case MINUS:
        ;
        break;
      default:
        jj_la1[31] = jj_gen;
        break label_13;
      }
      jj_consume_token(MINUS);
      r = MultiplicativeExpr();
                                               ex = compiler.minus(ex, r);
    }
        {if (true) return ex;}
    throw new Error("Missing return statement in function");
  }

/* [26] MultiplicativeExpr ::= UnaryExpr | MultiplicativeExpr MultiplyOperator UnaryExpr
            | MultiplicativeExpr 'div' UnaryExpr | MultiplicativeExpr 'mod' UnaryExpr  */
  final public Object MultiplicativeExpr() throws ParseException {
    Object ex, r;
    ex = UnaryExpr();
    label_14:
    while (true) {
      switch (jj_nt.kind) {
      case MOD:
      case DIV:
      case 88:
        ;
        break;
      default:
        jj_la1[32] = jj_gen;
        break label_14;
      }
      switch (jj_nt.kind) {
      case 88:
        jj_consume_token(88);
        r = UnaryExpr();
                                    ex = compiler.multiply(ex, r);
        break;
      case DIV:
        jj_consume_token(DIV);
        r = UnaryExpr();
                                    ex = compiler.divide(ex, r);
        break;
      case MOD:
        jj_consume_token(MOD);
        r = UnaryExpr();
                                    ex = compiler.mod(ex, r);
        break;
      default:
        jj_la1[33] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
        {if (true) return ex;}
    throw new Error("Missing return statement in function");
  }

/* [27]    UnaryExpr    ::=    UnionExpr  | '-' UnaryExpr  */
  final public Object UnaryExpr() throws ParseException {
    Object ex;
    switch (jj_nt.kind) {
    case SLASH:
    case SLASHSLASH:
    case VARIABLE:
    case Literal:
    case Number:
    case OR:
    case AND:
    case MOD:
    case DIV:
    case NODE:
    case TEXT:
    case COMMENT:
    case PI:
    case AXIS_SELF:
    case AXIS_CHILD:
    case AXIS_PARENT:
    case AXIS_ANCESTOR:
    case AXIS_ATTRIBUTE:
    case AXIS_NAMESPACE:
    case AXIS_PRECEDING:
    case AXIS_FOLLOWING:
    case AXIS_DESCENDANT:
    case AXIS_ANCESTOR_OR_SELF:
    case AXIS_FOLLOWING_SIBLING:
    case AXIS_PRECEDING_SIBLING:
    case AXIS_DESCENDANT_OR_SELF:
    case FUNCTION_LAST:
    case FUNCTION_POSITION:
    case FUNCTION_COUNT:
    case FUNCTION_ID:
    case FUNCTION_KEY:
    case FUNCTION_LOCAL_NAME:
    case FUNCTION_NAMESPACE_URI:
    case FUNCTION_NAME:
    case FUNCTION_STRING:
    case FUNCTION_CONCAT:
    case FUNCTION_STARTS_WITH:
    case FUNCTION_CONTAINS:
    case FUNCTION_SUBSTRING_BEFORE:
    case FUNCTION_SUBSTRING_AFTER:
    case FUNCTION_SUBSTRING:
    case FUNCTION_STRING_LENGTH:
    case FUNCTION_NORMALIZE_SPACE:
    case FUNCTION_TRANSLATE:
    case FUNCTION_BOOLEAN:
    case FUNCTION_NOT:
    case FUNCTION_TRUE:
    case FUNCTION_FALSE:
    case FUNCTION_NULL:
    case FUNCTION_LANG:
    case FUNCTION_NUMBER:
    case FUNCTION_SUM:
    case FUNCTION_FLOOR:
    case FUNCTION_CEILING:
    case FUNCTION_ROUND:
    case FUNCTION_FORMAT_NUMBER:
    case NCName:
    case 80:
    case 82:
    case 83:
    case 86:
    case 88:
      ex = UnionExpr();
      break;
    case MINUS:
      jj_consume_token(MINUS);
      ex = UnaryExpr();
                                    ex = compiler.minus(ex);
      break;
    default:
      jj_la1[34] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
        {if (true) return ex;}
    throw new Error("Missing return statement in function");
  }

/*-------------*/
/* 3.6 Strings */
/*-------------*/

/*----------------------------------*/
/* 3.7 Expression Lexical Structure */
/*----------------------------------*/
/*
The following special tokenization rules must be applied in the order
specified to disambiguate the grammar:

1. If there is a preceding token and the preceding token is not one of
   @, ::, (, [, , or an Operator,
   then a * must be recognized as a MultiplyOperator and an NCName must
   be recognized as an OperatorName.

2. If the character following an NCName (possibly after intervening ExprWhitespace)
   is (, then the token must be recognized as a NodeType or a FunctionName.

3. If the two characters following an NCName (possibly after intervening ExprWhitespace)
   are ::, then the token must be recognized as an AxisName.

4. Otherwise, the token must not be recognized as a MultiplyOperator, an OperatorName,
   a NodeType, a FunctionName, or an AxisName.
*/

/*
[28]    ExprToken    ::=    '(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'
   | WildcardName  | NodeType  | Operator  | FunctionName  | AxisName  | Literal
   | Number  | VariableReference
*/
/* [34]    MultiplyOperator    ::=    '*'  */

/* [35]    FunctionName    ::=    QName - NodeType   */
  final public Object FunctionName() throws ParseException {
    Object qname;
    qname = QName_Without_CoreFunctions();
        {if (true) return qname;}
    throw new Error("Missing return statement in function");
  }

/* [36]    VariableReference    ::=    '$' QName  */
  final public Object VariableReference() throws ParseException {
    Object ex;
    jj_consume_token(VARIABLE);
    ex = QName();
        {if (true) return compiler.variableReference(ex);}
    throw new Error("Missing return statement in function");
  }

/* [37]    WildcardName    ::=    '*'     | NCName ':' '*'     | QName  */
  final public Object WildcardName() throws ParseException {
    Object qn;
    String nc1, nc2 = null;
    switch (jj_nt.kind) {
    case 88:
      jj_consume_token(88);
      break;
    case OR:
    case AND:
    case MOD:
    case DIV:
    case NODE:
    case TEXT:
    case COMMENT:
    case PI:
    case FUNCTION_LAST:
    case FUNCTION_POSITION:
    case FUNCTION_COUNT:
    case FUNCTION_ID:
    case FUNCTION_KEY:
    case FUNCTION_LOCAL_NAME:
    case FUNCTION_NAMESPACE_URI:
    case FUNCTION_NAME:
    case FUNCTION_STRING:
    case FUNCTION_CONCAT:
    case FUNCTION_STARTS_WITH:
    case FUNCTION_CONTAINS:
    case FUNCTION_SUBSTRING_BEFORE:
    case FUNCTION_SUBSTRING_AFTER:
    case FUNCTION_SUBSTRING:
    case FUNCTION_STRING_LENGTH:
    case FUNCTION_NORMALIZE_SPACE:
    case FUNCTION_TRANSLATE:
    case FUNCTION_BOOLEAN:
    case FUNCTION_NOT:
    case FUNCTION_TRUE:
    case FUNCTION_FALSE:
    case FUNCTION_NULL:
    case FUNCTION_LANG:
    case FUNCTION_NUMBER:
    case FUNCTION_SUM:
    case FUNCTION_FLOOR:
    case FUNCTION_CEILING:
    case FUNCTION_ROUND:
    case FUNCTION_FORMAT_NUMBER:
    case NCName:
      NCName();
      break;
    default:
      jj_la1[35] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
                           nc1 = token.image;
    switch (jj_nt.kind) {
    case 79:
      jj_consume_token(79);
      switch (jj_nt.kind) {
      case 88:
        jj_consume_token(88);
        break;
      case OR:
      case AND:
      case MOD:
      case DIV:
      case NODE:
      case TEXT:
      case COMMENT:
      case PI:
      case FUNCTION_LAST:
      case FUNCTION_POSITION:
      case FUNCTION_COUNT:
      case FUNCTION_ID:
      case FUNCTION_KEY:
      case FUNCTION_LOCAL_NAME:
      case FUNCTION_NAMESPACE_URI:
      case FUNCTION_NAME:
      case FUNCTION_STRING:
      case FUNCTION_CONCAT:
      case FUNCTION_STARTS_WITH:
      case FUNCTION_CONTAINS:
      case FUNCTION_SUBSTRING_BEFORE:
      case FUNCTION_SUBSTRING_AFTER:
      case FUNCTION_SUBSTRING:
      case FUNCTION_STRING_LENGTH:
      case FUNCTION_NORMALIZE_SPACE:
      case FUNCTION_TRANSLATE:
      case FUNCTION_BOOLEAN:
      case FUNCTION_NOT:
      case FUNCTION_TRUE:
      case FUNCTION_FALSE:
      case FUNCTION_NULL:
      case FUNCTION_LANG:
      case FUNCTION_NUMBER:
      case FUNCTION_SUM:
      case FUNCTION_FLOOR:
      case FUNCTION_CEILING:
      case FUNCTION_ROUND:
      case FUNCTION_FORMAT_NUMBER:
      case NCName:
        NCName();
        break;
      default:
        jj_la1[36] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                               nc2 = token.image;
      break;
    default:
      jj_la1[37] = jj_gen;
      ;
    }
        if (nc2 != null){
            qn = compiler.qname(nc1, nc2);
        }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?