/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* Generated By:JavaCC: Do not edit this line. XPathParser.java */

package org.apache.commons.jxpath.ri.parser;

import java.util.ArrayList;

import org.apache.commons.jxpath.ri.Compiler;

public class XPathParser implements XPathParserConstants {

    static final class JJCalls {

        int gen;
        Token first;
        int arg;
        JJCalls next;
    }

    static private final class LookaheadSuccess extends Error {

        /**
         *
         */
        private static final long serialVersionUID = 1L;
    }

    static private int[] jj_la1_0;
    static private int[] jj_la1_1;
    static private int[] jj_la1_2;
    static {
        jj_la1_0();
        jj_la1_1();
        jj_la1_2();
    }

    private static void jj_la1_0() {
        jj_la1_0 = new int[] { 0xf8000000, 0x78000000, 0x0, 0x0, 0x78000000, 0xf80000c0, 0xc0, 0x40, 0xc0, 0xc0, 0xf8000000, 0xf8000000, 0x0, 0x0, 0x0, 0x0,
                0x160000, 0xf8000000, 0x0, 0xf81604c0, 0x100, 0xf80000c0, 0x0, 0xc0, 0x8000000, 0x10000000, 0x1800, 0x1800, 0x1e000, 0x1e000, 0x200, 0x400,
                0x60000000, 0x60000000, 0xf81604c0, 0xf8000000, 0xf8000000, 0x0, 0x80000000, };
    }

    private static void jj_la1_1() {
        jj_la1_1 = new int[] { 0xffff0007, 0x0, 0xffff0000, 0x0, 0x0, 0xffffffff, 0x0, 0x0, 0x0, 0x0, 0xffff0007, 0xffffffff, 0x0, 0xfff8, 0xfff8, 0x0, 0x0,
                0xffff0007, 0x0, 0xffffffff, 0x0, 0xffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xffffffff, 0xffff0007, 0xffff0007,
                0x0, 0x7, };
    }

    private static void jj_la1_2() {
        jj_la1_2 = new int[] { 0xffff, 0x8000, 0x7fff, 0x10000, 0x8000, 0x298ffff, 0x0, 0x0, 0x0, 0x0, 0x200ffff, 0x298ffff, 0x200000, 0x0, 0x0, 0x800000,
                0x20000, 0xffff, 0x1000000, 0x29affff, 0x0, 0x298ffff, 0x200000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2000000, 0x2000000, 0x29affff,
                0x200ffff, 0x200ffff, 0x10000, 0x0, };
    }
    /* ################################################################################### */
    /* XSLT Patterns (http://www.w3.org/1999/08/WD-xslt-19990813) */
    /* ################################################################################### */
    /* [XSLT1] Pattern ::= LocationPathPattern | Pattern '|' LocationPathPattern */
//void Pattern() :
//{}
//{
//        LocationPathPattern() ( <UNION> LocationPathPattern() )* <EOF>
//}
//
//
// /* [XSLT2] LocationPathPattern ::=
//   '/' RelativePathPattern? | IdKeyPattern (('/' | '//' RelativePathPattern)? | '//'? RelativePathPattern
//*/
//
//void LocationPathPattern() :
//{}
//{
//        <SLASH> ( RelativePathPattern() )?
//    |    (
//        LOOKAHEAD(IdKeyPattern())
//            IdKeyPattern() ( ( <SLASH> | <SLASHSLASH>) RelativePathPattern() )?
//        |    ( <SLASHSLASH> )? RelativePathPattern()
//        )
//}
//
//
//
// /* [XSLT3] IdKeyPattern    ::=    'id' '(' Literal ')' | 'key' '(' Literal ',' Literal ')'  */
//
//void IdKeyPattern() :
//{}
//{
//        <ID> "(" <Literal> ")"
//    |    <KEY>  "(" <Literal> "," <Literal> ")"
//}
//
//
// /* [XSLT4] RelativePathPattern    ::=    StepPattern | RelativePathPattern '/' StepPattern
//                           | RelativePathPattern '//' StepPattern
//*/
//void RelativePathPattern() :
//{}
//{
//        StepPattern() ( ( <SLASH>| <SLASHSLASH> ) StepPattern()    )*
//}
//
//
// /* [XSLT5]    StepPattern    ::=    AbbreviatedAxisSpecifier NodeTest Predicate*   */
//void StepPattern() :
//{}
//{
//        AbbreviatedAxisSpecifier() NodeTest() (Predicate())*
//}
// See XPath Syntax (http://www.w3.org/TR/xpath )
//void XPath() :
//{}
//{
//    LocationPath()
//    <EOF>
//}

    private Compiler compiler;
    public XPathParserTokenManager token_source;
    SimpleCharStream jj_input_stream;
    /* [3] RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | AbbreviatedRelativeLocationPath */
    /* [11] AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step */
    /*--------------------*/
    /* 2.1 Location Steps */
    /*--------------------*/
    public Token token, jj_nt;
    private Token jj_scanpos, jj_lastpos;
    private int jj_la;
    /*----------*/
    /* 2.2 Axes */
    /*----------*/
    public boolean lookingAhead = false;
    /*----------------*/
    /* 2.3 Node Tests */
    /*----------------*/
    /*----------------*/
    /* 2.4 Predicates */
    /*----------------*/
    private boolean jj_semLA;
    /* [12] AbbreviatedStep ::= '.' | '..' */
    private int jj_gen;
    /*---------------*/
    /* 3 Expressions */
    /*---------------*/
    /*------------*/
    /* 3.1 Basics */
    /*------------*/
    /*
     * The effect of the grammar is that the order of precedence is (lowest precedence first): or and =, != <=, <, >=, > and all operators are left associative.
     * For example, 3 > 2 > 1 is equivalent to (3 > 2) > 1, which evaluates to false.
     */
    final private int[] jj_la1 = new int[39];
    final private JJCalls[] jj_2_rtns = new JJCalls[6];
    /*--------------------*/
    /* 3.2 Function Calls */
    /*--------------------*/
    private boolean jj_rescan = false;
    private int jj_gc = 0;
    final private LookaheadSuccess jj_ls = new LookaheadSuccess();
    private final java.util.Vector jj_expentries = new java.util.Vector();
    /*---------------*/
    /* 3.3 Node-sets */
    /*---------------*/
    private int[] jj_expentry;
    private int jj_kind = -1;
    private final int[] jj_lasttokens = new int[100];
    /*--------------*/
    /* 3.4 Booleans */
    /*--------------*/
    private int jj_endpos;

    public XPathParser(final java.io.InputStream stream) {
        jj_input_stream = new SimpleCharStream(stream, 1, 1);
        token_source = new XPathParserTokenManager(jj_input_stream);
        token = new Token();
        token.next = jj_nt = token_source.getNextToken();
        jj_gen = 0;
        for (int i = 0; i < 39; i++) {
            jj_la1[i] = -1;
        }
        for (int i = 0; i < jj_2_rtns.length; i++) {
            jj_2_rtns[i] = new JJCalls();
        }
    }

    public XPathParser(final java.io.Reader stream) {
        jj_input_stream = new SimpleCharStream(stream, 1, 1);
        token_source = new XPathParserTokenManager(jj_input_stream);
        token = new Token();
        token.next = jj_nt = token_source.getNextToken();
        jj_gen = 0;
        for (int i = 0; i < 39; i++) {
            jj_la1[i] = -1;
        }
        for (int i = 0; i < jj_2_rtns.length; i++) {
            jj_2_rtns[i] = new JJCalls();
        }
    }

    public XPathParser(final XPathParserTokenManager tm) {
        token_source = tm;
        token = new Token();
        token.next = jj_nt = token_source.getNextToken();
        jj_gen = 0;
        for (int i = 0; i < 39; i++) {
            jj_la1[i] = -1;
        }
        for (int i = 0; i < jj_2_rtns.length; i++) {
            jj_2_rtns[i] = new JJCalls();
        }
    }
    /*-------------*/
    /* 3.5 Numbers */
    /*-------------*/

    /* [13] AbbreviatedAxisSpecifier ::= '@'? */
    final public int AbbreviatedAxisSpecifier() throws ParseException {
        int axis = Compiler.AXIS_CHILD;
        switch (jj_nt.kind) {
        case 87:
            jj_consume_token(87);
            axis = Compiler.AXIS_ATTRIBUTE;
            break;
        default:
            jj_la1[15] = jj_gen;
            ;
        }
        {
            if (true) {
                return axis;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [2] AbsoluteLocationPath ::= '/' RelativeLocationPath? | AbbreviatedAbsoluteLocationPath */
    /* [10] AbbreviatedAbsoluteLocationPath ::= '//' RelativeLocationPath */
    final public Object AbsoluteLocationPath() throws ParseException {
        final ArrayList steps = new ArrayList();
        if (jj_2_2(2147483647)) {
            LocationStep(steps);
            label_1: while (true) {
                switch (jj_nt.kind) {
                case SLASH:
                case SLASHSLASH:
                    ;
                    break;
                default:
                    jj_la1[6] = jj_gen;
                    break label_1;
                }
                LocationStep(steps);
            }
        } else {
            switch (jj_nt.kind) {
            case SLASH:
                jj_consume_token(SLASH);
                break;
            default:
                jj_la1[7] = jj_gen;
                jj_consume_token(-1);
                throw new ParseException();
            }
        }
        {
            if (true) {
                return compiler.locationPath(true, steps.toArray());
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [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");
    }

    /* [22] AndExpr ::= EqualityExpr | AndExpr 'and' EqualityExpr */
    final public Object AndExpr() throws ParseException {
        Object ex, r;
        ArrayList list = null;
        ex = EqualityExpr();
        label_9: while (true) {
            switch (jj_nt.kind) {
            case AND:
                ;
                break;
            default:
                jj_la1[25] = jj_gen;
                break label_9;
            }
            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");
    }
    /*-------------*/
    /* 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 ::= '*' */

    /* [17] Argument ::= Expr */
    final public Object Argument() throws ParseException {
        Object ex;
        ex = Expression();
        {
            if (true) {
                return ex;
            }
        }
        throw new Error("Missing return statement in function");
    }

    final public ArrayList ArgumentList() throws ParseException {
        ArrayList args = null;
        Object arg;
        jj_consume_token(81);
        switch (jj_nt.kind) {
        case SLASH:
        case SLASHSLASH:
        case MINUS:
        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_ENDS_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 81:
        case 83:
        case 84:
        case 87:
        case 89:
            arg = Argument();
            args = new ArrayList();
            args.add(arg);
            label_4: while (true) {
                switch (jj_nt.kind) {
                case 88:
                    ;
                    break;
                default:
                    jj_la1[18] = jj_gen;
                    break label_4;
                }
                jj_consume_token(88);
                arg = Argument();
                args.add(arg);
            }
            break;
        default:
            jj_la1[19] = jj_gen;
            ;
        }
        jj_consume_token(82);
        {
            if (true) {
                return args;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /*
     * [6] AxisName ::= 'ancestor' | 'ancestor-or-self' | 'attribute' | 'child' | 'descendant' | 'descendant-or-self' | 'following' | 'following-sibling' |
     * 'namespace' | 'parent' | 'preceding' | 'preceding-sibling' | 'self'
     */
    final public int AxisName() throws ParseException {
        int axis = 0;
        switch (jj_nt.kind) {
        case AXIS_SELF:
            jj_consume_token(AXIS_SELF);
            axis = Compiler.AXIS_SELF;
            break;
        case AXIS_CHILD:
            jj_consume_token(AXIS_CHILD);
            axis = Compiler.AXIS_CHILD;
            break;
        case AXIS_PARENT:
            jj_consume_token(AXIS_PARENT);
            axis = Compiler.AXIS_PARENT;
            break;
        case AXIS_ANCESTOR:
            jj_consume_token(AXIS_ANCESTOR);
            axis = Compiler.AXIS_ANCESTOR;
            break;
        case AXIS_ATTRIBUTE:
            jj_consume_token(AXIS_ATTRIBUTE);
            axis = Compiler.AXIS_ATTRIBUTE;
            break;
        case AXIS_NAMESPACE:
            jj_consume_token(AXIS_NAMESPACE);
            axis = Compiler.AXIS_NAMESPACE;
            break;
        case AXIS_PRECEDING:
            jj_consume_token(AXIS_PRECEDING);
            axis = Compiler.AXIS_PRECEDING;
            break;
        case AXIS_FOLLOWING:
            jj_consume_token(AXIS_FOLLOWING);
            axis = Compiler.AXIS_FOLLOWING;
            break;
        case AXIS_DESCENDANT:
            jj_consume_token(AXIS_DESCENDANT);
            axis = Compiler.AXIS_DESCENDANT;
            break;
        case AXIS_ANCESTOR_OR_SELF:
            jj_consume_token(AXIS_ANCESTOR_OR_SELF);
            axis = Compiler.AXIS_ANCESTOR_OR_SELF;
            break;
        case AXIS_FOLLOWING_SIBLING:
            jj_consume_token(AXIS_FOLLOWING_SIBLING);
            axis = Compiler.AXIS_FOLLOWING_SIBLING;
            break;
        case AXIS_PRECEDING_SIBLING:
            jj_consume_token(AXIS_PRECEDING_SIBLING);
            axis = Compiler.AXIS_PRECEDING_SIBLING;
            break;
        case AXIS_DESCENDANT_OR_SELF:
            jj_consume_token(AXIS_DESCENDANT_OR_SELF);
            axis = Compiler.AXIS_DESCENDANT_OR_SELF;
            break;
        default:
            jj_la1[14] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
        }
        {
            if (true) {
                return axis;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [5] AxisSpecifier ::= AxisName '::' | AbbreviatedAxisSpecifier */
    final public int AxisSpecifier() throws ParseException {
        int axis;
        switch (jj_nt.kind) {
        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:
            axis = AxisName();
            break;
        default:
            jj_la1[13] = jj_gen;
            axis = AbbreviatedAxisSpecifier();
        }
        {
            if (true) {
                return axis;
            }
        }
        throw new Error("Missing return statement in function");
    }

    final public Object CoreFunctionCall() throws ParseException {
        int code = 0;
        ArrayList args;
        code = CoreFunctionName();
        args = ArgumentList();
        if (args == null) {
            {
                if (true) {
                    return compiler.function(code, null);
                }
            }
        } else {
            {
                if (true) {
                    return compiler.function(code, args.toArray());
                }
            }
        }
        throw new Error("Missing return statement in function");
    }

    final public int CoreFunctionName() throws ParseException {
        int code;
        switch (jj_nt.kind) {
        case FUNCTION_LAST:
            jj_consume_token(FUNCTION_LAST);
            code = Compiler.FUNCTION_LAST;
            break;
        case FUNCTION_POSITION:
            jj_consume_token(FUNCTION_POSITION);
            code = Compiler.FUNCTION_POSITION;
            break;
        case FUNCTION_COUNT:
            jj_consume_token(FUNCTION_COUNT);
            code = Compiler.FUNCTION_COUNT;
            break;
        case FUNCTION_ID:
            jj_consume_token(FUNCTION_ID);
            code = Compiler.FUNCTION_ID;
            break;
        case FUNCTION_LOCAL_NAME:
            jj_consume_token(FUNCTION_LOCAL_NAME);
            code = Compiler.FUNCTION_LOCAL_NAME;
            break;
        case FUNCTION_NAMESPACE_URI:
            jj_consume_token(FUNCTION_NAMESPACE_URI);
            code = Compiler.FUNCTION_NAMESPACE_URI;
            break;
        case FUNCTION_NAME:
            jj_consume_token(FUNCTION_NAME);
            code = Compiler.FUNCTION_NAME;
            break;
        case FUNCTION_STRING:
            jj_consume_token(FUNCTION_STRING);
            code = Compiler.FUNCTION_STRING;
            break;
        case FUNCTION_CONCAT:
            jj_consume_token(FUNCTION_CONCAT);
            code = Compiler.FUNCTION_CONCAT;
            break;
        case FUNCTION_STARTS_WITH:
            jj_consume_token(FUNCTION_STARTS_WITH);
            code = Compiler.FUNCTION_STARTS_WITH;
            break;
        case FUNCTION_ENDS_WITH:
            jj_consume_token(FUNCTION_ENDS_WITH);
            code = Compiler.FUNCTION_ENDS_WITH;
            break;
        case FUNCTION_CONTAINS:
            jj_consume_token(FUNCTION_CONTAINS);
            code = Compiler.FUNCTION_CONTAINS;
            break;
        case FUNCTION_SUBSTRING_BEFORE:
            jj_consume_token(FUNCTION_SUBSTRING_BEFORE);
            code = Compiler.FUNCTION_SUBSTRING_BEFORE;
            break;
        case FUNCTION_SUBSTRING_AFTER:
            jj_consume_token(FUNCTION_SUBSTRING_AFTER);
            code = Compiler.FUNCTION_SUBSTRING_AFTER;
            break;
        case FUNCTION_SUBSTRING:
            jj_consume_token(FUNCTION_SUBSTRING);
            code = Compiler.FUNCTION_SUBSTRING;
            break;
        case FUNCTION_STRING_LENGTH:
            jj_consume_token(FUNCTION_STRING_LENGTH);
            code = Compiler.FUNCTION_STRING_LENGTH;
            break;
        case FUNCTION_NORMALIZE_SPACE:
            jj_consume_token(FUNCTION_NORMALIZE_SPACE);
            code = Compiler.FUNCTION_NORMALIZE_SPACE;
            break;
        case FUNCTION_TRANSLATE:
            jj_consume_token(FUNCTION_TRANSLATE);
            code = Compiler.FUNCTION_TRANSLATE;
            break;
        case FUNCTION_BOOLEAN:
            jj_consume_token(FUNCTION_BOOLEAN);
            code = Compiler.FUNCTION_BOOLEAN;
            break;
        case FUNCTION_NOT:
            jj_consume_token(FUNCTION_NOT);
            code = Compiler.FUNCTION_NOT;
            break;
        case FUNCTION_TRUE:
            jj_consume_token(FUNCTION_TRUE);
            code = Compiler.FUNCTION_TRUE;
            break;
        case FUNCTION_FALSE:
            jj_consume_token(FUNCTION_FALSE);
            code = Compiler.FUNCTION_FALSE;
            break;
        case FUNCTION_NULL:
            jj_consume_token(FUNCTION_NULL);
            code = Compiler.FUNCTION_NULL;
            break;
        case FUNCTION_LANG:
            jj_consume_token(FUNCTION_LANG);
            code = Compiler.FUNCTION_LANG;
            break;
        case FUNCTION_NUMBER:
            jj_consume_token(FUNCTION_NUMBER);
            code = Compiler.FUNCTION_NUMBER;
            break;
        case FUNCTION_SUM:
            jj_consume_token(FUNCTION_SUM);
            code = Compiler.FUNCTION_SUM;
            break;
        case FUNCTION_FLOOR:
            jj_consume_token(FUNCTION_FLOOR);
            code = Compiler.FUNCTION_FLOOR;
            break;
        case FUNCTION_CEILING:
            jj_consume_token(FUNCTION_CEILING);
            code = Compiler.FUNCTION_CEILING;
            break;
        case FUNCTION_ROUND:
            jj_consume_token(FUNCTION_ROUND);
            code = Compiler.FUNCTION_ROUND;
            break;
        case FUNCTION_KEY:
            jj_consume_token(FUNCTION_KEY);
            code = Compiler.FUNCTION_KEY;
            break;
        case FUNCTION_FORMAT_NUMBER:
            jj_consume_token(FUNCTION_FORMAT_NUMBER);
            code = Compiler.FUNCTION_FORMAT_NUMBER;
            break;
        default:
            jj_la1[2] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
        }
        {
            if (true) {
                return code;
            }
        }
        throw new Error("Missing return statement in function");
    }

    final public void disable_tracing() {
    }

    final public void enable_tracing() {
    }

    /* [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");
    }

    /* [14] Expr ::= OrExpr */
    final public Object Expression() throws ParseException {
        Object ex;
        ex = OrExpr();
        {
            if (true) {
                return ex;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [20] FilterExpr ::= PrimaryExpr | FilterExpr Predicate */
    final public Object FilterExpr() throws ParseException {
        Object ex, p;
        final ArrayList ps = new ArrayList();
        boolean path = false;
        final ArrayList steps = new ArrayList();
        ex = PrimaryExpr();
        label_6: while (true) {
            switch (jj_nt.kind) {
            case 85:
                ;
                break;
            default:
                jj_la1[22] = jj_gen;
                break label_6;
            }
            p = Predicate();
            path = true;
            ps.add(p);
        }
        label_7: while (true) {
            switch (jj_nt.kind) {
            case SLASH:
            case SLASHSLASH:
                ;
                break;
            default:
                jj_la1[23] = jj_gen;
                break label_7;
            }
            LocationStep(steps);
            path = true;
        }
        if (path) {
            {
                if (true) {
                    return compiler.expressionPath(ex, ps.toArray(), steps.toArray());
                }
            }
        } else {
            {
                if (true) {
                    return ex;
                }
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [16] FunctionCall ::= FunctionName '(' ( Argument ( ',' Argument)*)? ')' */
    final public Object FunctionCall() throws ParseException {
        Object name;
        ArrayList args;
        name = FunctionName();
        args = ArgumentList();
        if (args == null) {
            {
                if (true) {
                    return compiler.function(name, null);
                }
            }
        } else {
            {
                if (true) {
                    return compiler.function(name, args.toArray());
                }
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [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");
    }

    public ParseException generateParseException() {
        jj_expentries.removeAllElements();
        final boolean[] la1tokens = new boolean[90];
        for (int i = 0; i < 90; i++) {
            la1tokens[i] = false;
        }
        if (jj_kind >= 0) {
            la1tokens[jj_kind] = true;
            jj_kind = -1;
        }
        for (int i = 0; i < 39; 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;
                    }
                    if ((jj_la1_2[i] & 1 << j) != 0) {
                        la1tokens[64 + j] = true;
                    }
                }
            }
        }
        for (int i = 0; i < 90; 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);
        final 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 Token getNextToken() {
        if ((token = jj_nt).next != null) {
            jj_nt = jj_nt.next;
        } else {
            jj_nt = jj_nt.next = token_source.getNextToken();
        }
        jj_gen++;
        return token;
    }

    final public Token getToken(final 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;
    }

    private boolean jj_2_1(final int xla) {
        jj_la = xla;
        jj_lastpos = jj_scanpos = token;
        try {
            return !jj_3_1();
        } catch (final LookaheadSuccess ls) {
            return true;
        } finally {
            jj_save(0, xla);
        }
    }

    private boolean jj_2_2(final int xla) {
        jj_la = xla;
        jj_lastpos = jj_scanpos = token;
        try {
            return !jj_3_2();
        } catch (final LookaheadSuccess ls) {
            return true;
        } finally {
            jj_save(1, xla);
        }
    }

    private boolean jj_2_3(final int xla) {
        jj_la = xla;
        jj_lastpos = jj_scanpos = token;
        try {
            return !jj_3_3();
        } catch (final LookaheadSuccess ls) {
            return true;
        } finally {
            jj_save(2, xla);
        }
    }

    private boolean jj_2_4(final int xla) {
        jj_la = xla;
        jj_lastpos = jj_scanpos = token;
        try {
            return !jj_3_4();
        } catch (final LookaheadSuccess ls) {
            return true;
        } finally {
            jj_save(3, xla);
        }
    }

    private boolean jj_2_5(final int xla) {
        jj_la = xla;
        jj_lastpos = jj_scanpos = token;
        try {
            return !jj_3_5();
        } catch (final LookaheadSuccess ls) {
            return true;
        } finally {
            jj_save(4, xla);
        }
    }

    private boolean jj_2_6(final int xla) {
        jj_la = xla;
        jj_lastpos = jj_scanpos = token;
        try {
            return !jj_3_6();
        } catch (final LookaheadSuccess ls) {
            return true;
        } finally {
            jj_save(5, xla);
        }
    }

    private boolean jj_3_1() {
        if (jj_3R_15()) {
            return true;
        }
        if (jj_scan_token(80)) {
            return true;
        }
        return false;
    }

    private boolean jj_3_2() {
        if (jj_3R_16()) {
            return true;
        }
        return false;
    }

    private boolean jj_3_3() {
        if (jj_3R_17()) {
            return true;
        }
        if (jj_scan_token(81)) {
            return true;
        }
        if (jj_scan_token(82)) {
            return true;
        }
        return false;
    }

    private boolean jj_3_4() {
        if (jj_scan_token(PI)) {
            return true;
        }
        return false;
    }

    private boolean jj_3_5() {
        if (jj_3R_18()) {
            return true;
        }
        if (jj_scan_token(81)) {
            return true;
        }
        return false;
    }

    private boolean jj_3_6() {
        if (jj_3R_19()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_100() {
        if (jj_scan_token(AXIS_SELF)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_101() {
        if (jj_scan_token(AXIS_CHILD)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_102() {
        if (jj_scan_token(AXIS_PARENT)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_103() {
        if (jj_scan_token(AXIS_ANCESTOR)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_104() {
        if (jj_scan_token(AXIS_ATTRIBUTE)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_105() {
        if (jj_scan_token(AXIS_NAMESPACE)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_106() {
        if (jj_scan_token(AXIS_PRECEDING)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_107() {
        if (jj_scan_token(AXIS_FOLLOWING)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_108() {
        if (jj_scan_token(AXIS_DESCENDANT)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_109() {
        if (jj_scan_token(AXIS_ANCESTOR_OR_SELF)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_110() {
        if (jj_scan_token(AXIS_FOLLOWING_SIBLING)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_111() {
        if (jj_scan_token(AXIS_PRECEDING_SIBLING)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_112() {
        if (jj_scan_token(AXIS_DESCENDANT_OR_SELF)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_113() {
        if (jj_scan_token(87)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_114() {
        if (jj_3R_15()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_115() {
        if (jj_3R_117()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_118()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_116() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_119()) {
            jj_scanpos = xsp;
            if (jj_3R_120()) {
                return true;
            }
        }
        return false;
    }

    private boolean jj_3R_117() {
        if (jj_3R_121()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_122()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_118() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_123()) {
            jj_scanpos = xsp;
            if (jj_3R_124()) {
                jj_scanpos = xsp;
                if (jj_3R_125()) {
                    jj_scanpos = xsp;
                    if (jj_3R_126()) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    private boolean jj_3R_119() {
        if (jj_scan_token(EQ)) {
            return true;
        }
        if (jj_3R_115()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_120() {
        if (jj_scan_token(NEQ)) {
            return true;
        }
        if (jj_3R_115()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_121() {
        if (jj_3R_127()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_128()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_122() {
        if (jj_scan_token(PLUS)) {
            return true;
        }
        if (jj_3R_121()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_123() {
        if (jj_scan_token(LT)) {
            return true;
        }
        if (jj_3R_117()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_124() {
        if (jj_scan_token(GT)) {
            return true;
        }
        if (jj_3R_117()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_125() {
        if (jj_scan_token(LTE)) {
            return true;
        }
        if (jj_3R_117()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_126() {
        if (jj_scan_token(GTE)) {
            return true;
        }
        if (jj_3R_117()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_127() {
        if (jj_3R_129()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_130()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_128() {
        if (jj_scan_token(MINUS)) {
            return true;
        }
        if (jj_3R_127()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_129() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_131()) {
            jj_scanpos = xsp;
            if (jj_3R_132()) {
                return true;
            }
        }
        return false;
    }

    private boolean jj_3R_130() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_133()) {
            jj_scanpos = xsp;
            if (jj_3R_134()) {
                jj_scanpos = xsp;
                if (jj_3R_135()) {
                    return true;
                }
            }
        }
        return false;
    }

    private boolean jj_3R_131() {
        if (jj_3R_136()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_132() {
        if (jj_scan_token(MINUS)) {
            return true;
        }
        if (jj_3R_129()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_133() {
        if (jj_scan_token(89)) {
            return true;
        }
        if (jj_3R_129()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_134() {
        if (jj_scan_token(DIV)) {
            return true;
        }
        if (jj_3R_129()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_135() {
        if (jj_scan_token(MOD)) {
            return true;
        }
        if (jj_3R_129()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_136() {
        if (jj_3R_137()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_138()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_137() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_139()) {
            jj_scanpos = xsp;
            if (jj_3R_140()) {
                return true;
            }
        }
        return false;
    }

    private boolean jj_3R_138() {
        if (jj_scan_token(UNION)) {
            return true;
        }
        if (jj_3R_137()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_139() {
        if (jj_3R_141()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_140() {
        if (jj_3R_142()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_141() {
        if (jj_3R_19()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_143()) {
                jj_scanpos = xsp;
                break;
            }
        }
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_144()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_142() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_145()) {
            jj_scanpos = xsp;
            if (jj_3R_146()) {
                return true;
            }
        }
        return false;
    }

    private boolean jj_3R_143() {
        if (jj_3R_77()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_144() {
        if (jj_3R_16()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_145() {
        if (jj_3R_147()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_146() {
        if (jj_3R_148()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_147() {
        if (jj_3R_22()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_149()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_148() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_150()) {
            jj_scanpos = xsp;
            if (jj_scan_token(6)) {
                return true;
            }
        }
        return false;
    }

    private boolean jj_3R_149() {
        if (jj_3R_16()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_15() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_20()) {
            jj_scanpos = xsp;
            if (jj_scan_token(31)) {
                jj_scanpos = xsp;
                if (jj_scan_token(32)) {
                    jj_scanpos = xsp;
                    if (jj_scan_token(33)) {
                        jj_scanpos = xsp;
                        if (jj_scan_token(34)) {
                            jj_scanpos = xsp;
                            if (jj_scan_token(48)) {
                                jj_scanpos = xsp;
                                if (jj_scan_token(49)) {
                                    jj_scanpos = xsp;
                                    if (jj_scan_token(50)) {
                                        jj_scanpos = xsp;
                                        if (jj_scan_token(51)) {
                                            jj_scanpos = xsp;
                                            if (jj_scan_token(53)) {
                                                jj_scanpos = xsp;
                                                if (jj_scan_token(54)) {
                                                    jj_scanpos = xsp;
                                                    if (jj_scan_token(55)) {
                                                        jj_scanpos = xsp;
                                                        if (jj_scan_token(56)) {
                                                            jj_scanpos = xsp;
                                                            if (jj_scan_token(57)) {
                                                                jj_scanpos = xsp;
                                                                if (jj_scan_token(58)) {
                                                                    jj_scanpos = xsp;
                                                                    if (jj_scan_token(59)) {
                                                                        jj_scanpos = xsp;
                                                                        if (jj_scan_token(60)) {
                                                                            jj_scanpos = xsp;
                                                                            if (jj_scan_token(61)) {
                                                                                jj_scanpos = xsp;
                                                                                if (jj_scan_token(62)) {
                                                                                    jj_scanpos = xsp;
                                                                                    if (jj_scan_token(63)) {
                                                                                        jj_scanpos = xsp;
                                                                                        if (jj_scan_token(64)) {
                                                                                            jj_scanpos = xsp;
                                                                                            if (jj_scan_token(65)) {
                                                                                                jj_scanpos = xsp;
                                                                                                if (jj_scan_token(66)) {
                                                                                                    jj_scanpos = xsp;
                                                                                                    if (jj_scan_token(67)) {
                                                                                                        jj_scanpos = xsp;
                                                                                                        if (jj_scan_token(68)) {
                                                                                                            jj_scanpos = xsp;
                                                                                                            if (jj_scan_token(69)) {
                                                                                                                jj_scanpos = xsp;
                                                                                                                if (jj_scan_token(70)) {
                                                                                                                    jj_scanpos = xsp;
                                                                                                                    if (jj_scan_token(71)) {
                                                                                                                        jj_scanpos = xsp;
                                                                                                                        if (jj_scan_token(72)) {
                                                                                                                            jj_scanpos = xsp;
                                                                                                                            if (jj_scan_token(73)) {
                                                                                                                                jj_scanpos = xsp;
                                                                                                                                if (jj_scan_token(74)) {
                                                                                                                                    jj_scanpos = xsp;
                                                                                                                                    if (jj_scan_token(75)) {
                                                                                                                                        jj_scanpos = xsp;
                                                                                                                                        if (jj_scan_token(76)) {
                                                                                                                                            jj_scanpos = xsp;
                                                                                                                                            if (jj_scan_token(
                                                                                                                                                    77)) {
                                                                                                                                                jj_scanpos = xsp;
                                                                                                                                                if (jj_scan_token(
                                                                                                                                                        52)) {
                                                                                                                                                    jj_scanpos = xsp;
                                                                                                                                                    if (jj_scan_token(
                                                                                                                                                            78)) {
                                                                                                                                                        return true;
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

    private boolean jj_3R_150() {
        if (jj_3R_16()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_151()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_151() {
        if (jj_3R_16()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_16() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_scan_token(6)) {
            jj_scanpos = xsp;
            if (jj_3R_21()) {
                return true;
            }
        }
        if (jj_3R_22()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_17() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_23()) {
            jj_scanpos = xsp;
            if (jj_3R_24()) {
                jj_scanpos = xsp;
                if (jj_3R_25()) {
                    jj_scanpos = xsp;
                    if (jj_3R_26()) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    private boolean jj_3R_18() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_27()) {
            jj_scanpos = xsp;
            if (jj_3R_28()) {
                jj_scanpos = xsp;
                if (jj_3R_29()) {
                    jj_scanpos = xsp;
                    if (jj_3R_30()) {
                        jj_scanpos = xsp;
                        if (jj_3R_31()) {
                            jj_scanpos = xsp;
                            if (jj_3R_32()) {
                                jj_scanpos = xsp;
                                if (jj_3R_33()) {
                                    jj_scanpos = xsp;
                                    if (jj_3R_34()) {
                                        jj_scanpos = xsp;
                                        if (jj_3R_35()) {
                                            jj_scanpos = xsp;
                                            if (jj_3R_36()) {
                                                jj_scanpos = xsp;
                                                if (jj_3R_37()) {
                                                    jj_scanpos = xsp;
                                                    if (jj_3R_38()) {
                                                        jj_scanpos = xsp;
                                                        if (jj_3R_39()) {
                                                            jj_scanpos = xsp;
                                                            if (jj_3R_40()) {
                                                                jj_scanpos = xsp;
                                                                if (jj_3R_41()) {
                                                                    jj_scanpos = xsp;
                                                                    if (jj_3R_42()) {
                                                                        jj_scanpos = xsp;
                                                                        if (jj_3R_43()) {
                                                                            jj_scanpos = xsp;
                                                                            if (jj_3R_44()) {
                                                                                jj_scanpos = xsp;
                                                                                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()) {
                                                                                                    jj_scanpos = xsp;
                                                                                                    if (jj_3R_50()) {
                                                                                                        jj_scanpos = xsp;
                                                                                                        if (jj_3R_51()) {
                                                                                                            jj_scanpos = xsp;
                                                                                                            if (jj_3R_52()) {
                                                                                                                jj_scanpos = xsp;
                                                                                                                if (jj_3R_53()) {
                                                                                                                    jj_scanpos = xsp;
                                                                                                                    if (jj_3R_54()) {
                                                                                                                        jj_scanpos = xsp;
                                                                                                                        if (jj_3R_55()) {
                                                                                                                            jj_scanpos = xsp;
                                                                                                                            if (jj_3R_56()) {
                                                                                                                                jj_scanpos = xsp;
                                                                                                                                if (jj_3R_57()) {
                                                                                                                                    return true;
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

    private boolean jj_3R_19() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_58()) {
            jj_scanpos = xsp;
            if (jj_3R_59()) {
                jj_scanpos = xsp;
                if (jj_3R_60()) {
                    jj_scanpos = xsp;
                    if (jj_3R_61()) {
                        jj_scanpos = xsp;
                        if (jj_3R_62()) {
                            jj_scanpos = xsp;
                            if (jj_3R_63()) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

    private boolean jj_3R_20() {
        if (jj_3R_64()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_21() {
        if (jj_scan_token(SLASHSLASH)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_22() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_65()) {
            jj_scanpos = xsp;
            if (jj_3R_66()) {
                jj_scanpos = xsp;
                if (jj_3R_67()) {
                    return true;
                }
            }
        }
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_68()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_23() {
        if (jj_scan_token(TEXT)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_24() {
        if (jj_scan_token(NODE)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_25() {
        if (jj_scan_token(COMMENT)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_26() {
        if (jj_scan_token(PI)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_27() {
        if (jj_scan_token(FUNCTION_LAST)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_28() {
        if (jj_scan_token(FUNCTION_POSITION)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_29() {
        if (jj_scan_token(FUNCTION_COUNT)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_30() {
        if (jj_scan_token(FUNCTION_ID)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_31() {
        if (jj_scan_token(FUNCTION_LOCAL_NAME)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_32() {
        if (jj_scan_token(FUNCTION_NAMESPACE_URI)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_33() {
        if (jj_scan_token(FUNCTION_NAME)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_34() {
        if (jj_scan_token(FUNCTION_STRING)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_35() {
        if (jj_scan_token(FUNCTION_CONCAT)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_36() {
        if (jj_scan_token(FUNCTION_STARTS_WITH)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_37() {
        if (jj_scan_token(FUNCTION_ENDS_WITH)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_38() {
        if (jj_scan_token(FUNCTION_CONTAINS)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_39() {
        if (jj_scan_token(FUNCTION_SUBSTRING_BEFORE)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_40() {
        if (jj_scan_token(FUNCTION_SUBSTRING_AFTER)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_41() {
        if (jj_scan_token(FUNCTION_SUBSTRING)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_42() {
        if (jj_scan_token(FUNCTION_STRING_LENGTH)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_43() {
        if (jj_scan_token(FUNCTION_NORMALIZE_SPACE)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_44() {
        if (jj_scan_token(FUNCTION_TRANSLATE)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_45() {
        if (jj_scan_token(FUNCTION_BOOLEAN)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_46() {
        if (jj_scan_token(FUNCTION_NOT)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_47() {
        if (jj_scan_token(FUNCTION_TRUE)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_48() {
        if (jj_scan_token(FUNCTION_FALSE)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_49() {
        if (jj_scan_token(FUNCTION_NULL)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_50() {
        if (jj_scan_token(FUNCTION_LANG)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_51() {
        if (jj_scan_token(FUNCTION_NUMBER)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_52() {
        if (jj_scan_token(FUNCTION_SUM)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_53() {
        if (jj_scan_token(FUNCTION_FLOOR)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_54() {
        if (jj_scan_token(FUNCTION_CEILING)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_55() {
        if (jj_scan_token(FUNCTION_ROUND)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_56() {
        if (jj_scan_token(FUNCTION_KEY)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_57() {
        if (jj_scan_token(FUNCTION_FORMAT_NUMBER)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_58() {
        if (jj_3R_69()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_59() {
        if (jj_scan_token(81)) {
            return true;
        }
        if (jj_3R_70()) {
            return true;
        }
        if (jj_scan_token(82)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_60() {
        if (jj_scan_token(Literal)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_61() {
        if (jj_scan_token(Number)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_62() {
        if (jj_3R_71()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_63() {
        if (jj_3R_72()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_64() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_scan_token(79)) {
            jj_scanpos = xsp;
            if (jj_scan_token(27)) {
                jj_scanpos = xsp;
                if (jj_scan_token(28)) {
                    jj_scanpos = xsp;
                    if (jj_scan_token(29)) {
                        jj_scanpos = xsp;
                        if (jj_scan_token(30)) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }

    private boolean jj_3R_65() {
        if (jj_3R_73()) {
            return true;
        }
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_74()) {
            jj_scanpos = xsp;
            if (jj_3R_75()) {
                jj_scanpos = xsp;
                if (jj_3R_76()) {
                    return true;
                }
            }
        }
        return false;
    }

    private boolean jj_3R_66() {
        if (jj_scan_token(83)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_67() {
        if (jj_scan_token(84)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_68() {
        if (jj_3R_77()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_69() {
        if (jj_scan_token(VARIABLE)) {
            return true;
        }
        if (jj_3R_78()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_70() {
        if (jj_3R_79()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_71() {
        if (jj_3R_18()) {
            return true;
        }
        if (jj_3R_80()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_72() {
        if (jj_3R_81()) {
            return true;
        }
        if (jj_3R_80()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_73() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_82()) {
            jj_scanpos = xsp;
            if (jj_3R_83()) {
                return true;
            }
        }
        return false;
    }

    private boolean jj_3R_74() {
        if (jj_3R_17()) {
            return true;
        }
        if (jj_scan_token(81)) {
            return true;
        }
        if (jj_scan_token(82)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_75() {
        if (jj_scan_token(PI)) {
            return true;
        }
        if (jj_scan_token(81)) {
            return true;
        }
        if (jj_scan_token(Literal)) {
            return true;
        }
        if (jj_scan_token(82)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_76() {
        if (jj_3R_84()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_77() {
        if (jj_scan_token(85)) {
            return true;
        }
        if (jj_3R_70()) {
            return true;
        }
        if (jj_scan_token(86)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_78() {
        if (jj_3R_15()) {
            return true;
        }
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_85()) {
            jj_scanpos = xsp;
        }
        return false;
    }

    private boolean jj_3R_79() {
        if (jj_3R_86()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_87()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_80() {
        if (jj_scan_token(81)) {
            return true;
        }
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_88()) {
            jj_scanpos = xsp;
        }
        if (jj_scan_token(82)) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_81() {
        if (jj_3R_89()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_82() {
        if (jj_3R_90()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_83() {
        if (jj_3R_91()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_84() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_scan_token(89)) {
            jj_scanpos = xsp;
            if (jj_3R_92()) {
                return true;
            }
        }
        xsp = jj_scanpos;
        if (jj_3R_93()) {
            jj_scanpos = xsp;
        }
        return false;
    }

    private boolean jj_3R_85() {
        if (jj_scan_token(80)) {
            return true;
        }
        if (jj_3R_15()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_86() {
        if (jj_3R_94()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_95()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_87() {
        if (jj_scan_token(OR)) {
            return true;
        }
        if (jj_3R_86()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_88() {
        if (jj_3R_96()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_97()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_89() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_98()) {
            jj_scanpos = xsp;
            if (jj_3R_99()) {
                return true;
            }
        }
        return false;
    }

    private boolean jj_3R_90() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_100()) {
            jj_scanpos = xsp;
            if (jj_3R_101()) {
                jj_scanpos = xsp;
                if (jj_3R_102()) {
                    jj_scanpos = xsp;
                    if (jj_3R_103()) {
                        jj_scanpos = xsp;
                        if (jj_3R_104()) {
                            jj_scanpos = xsp;
                            if (jj_3R_105()) {
                                jj_scanpos = xsp;
                                if (jj_3R_106()) {
                                    jj_scanpos = xsp;
                                    if (jj_3R_107()) {
                                        jj_scanpos = xsp;
                                        if (jj_3R_108()) {
                                            jj_scanpos = xsp;
                                            if (jj_3R_109()) {
                                                jj_scanpos = xsp;
                                                if (jj_3R_110()) {
                                                    jj_scanpos = xsp;
                                                    if (jj_3R_111()) {
                                                        jj_scanpos = xsp;
                                                        if (jj_3R_112()) {
                                                            return true;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

    private boolean jj_3R_91() {
        Token xsp;
        xsp = jj_scanpos;
        if (jj_3R_113()) {
            jj_scanpos = xsp;
        }
        return false;
    }

    private boolean jj_3R_92() {
        if (jj_3R_15()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_93() {
        if (jj_scan_token(80)) {
            return true;
        }
        Token xsp;
        xsp = jj_scanpos;
        if (jj_scan_token(89)) {
            jj_scanpos = xsp;
            if (jj_3R_114()) {
                return true;
            }
        }
        return false;
    }

    private boolean jj_3R_94() {
        if (jj_3R_115()) {
            return true;
        }
        Token xsp;
        while (true) {
            xsp = jj_scanpos;
            if (jj_3R_116()) {
                jj_scanpos = xsp;
                break;
            }
        }
        return false;
    }

    private boolean jj_3R_95() {
        if (jj_scan_token(AND)) {
            return true;
        }
        if (jj_3R_94()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_96() {
        if (jj_3R_70()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_97() {
        if (jj_scan_token(88)) {
            return true;
        }
        if (jj_3R_96()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_98() {
        if (jj_3R_15()) {
            return true;
        }
        if (jj_scan_token(80)) {
            return true;
        }
        if (jj_3R_15()) {
            return true;
        }
        return false;
    }

    private boolean jj_3R_99() {
        if (jj_3R_64()) {
            return true;
        }
        return false;
    }

    private void jj_add_error_token(final int kind, final 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 (final java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
                final int[] oldentry = (int[]) e.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;
            }
        }
    }

    private Token jj_consume_token(final int kind) throws ParseException {
        final Token oldToken = token;
        if ((token = jj_nt).next != null) {
            jj_nt = jj_nt.next;
        } else {
            jj_nt = jj_nt.next = token_source.getNextToken();
        }
        if (token.kind == kind) {
            jj_gen++;
            if (++jj_gc > 100) {
                jj_gc = 0;
                for (final JJCalls jj_2_rtn : jj_2_rtns) {
                    JJCalls c = jj_2_rtn;
                    while (c != null) {
                        if (c.gen < jj_gen) {
                            c.first = null;
                        }
                        c = c.next;
                    }
                }
            }
            return token;
        }
        jj_nt = token;
        token = oldToken;
        jj_kind = kind;
        throw generateParseException();
    }

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

    private void jj_save(final int index, final 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;
    }

    private boolean jj_scan_token(final 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);
            }
        }
        if (jj_scanpos.kind != kind) {
            return true;
        }
        if (jj_la == 0 && jj_scanpos == jj_lastpos) {
            throw jj_ls;
        }
        return false;
    }

    /* [1] LocationPath ::= RelativeLocationPath | AbsoluteLocationPath */
    final public Object LocationPath() throws ParseException {
        Object ex = null;
        switch (jj_nt.kind) {
        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_ENDS_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 83:
        case 84:
        case 87:
        case 89:
            ex = RelativeLocationPath();
            break;
        case SLASH:
        case SLASHSLASH:
            ex = AbsoluteLocationPath();
            break;
        default:
            jj_la1[5] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
        }
        {
            if (true) {
                return ex;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [4] Step ::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep */
    final public void LocationStep(final ArrayList steps) throws ParseException {
        Object t;
        final Object s;
        switch (jj_nt.kind) {
        case SLASH:
            jj_consume_token(SLASH);
            break;
        case SLASHSLASH:
            jj_consume_token(SLASHSLASH);
            // Abbreviated step: descendant-or-self::node()
            t = compiler.nodeTypeTest(Compiler.NODE_TYPE_NODE);
            steps.add(compiler.step(Compiler.AXIS_DESCENDANT_OR_SELF, t, null));
            break;
        default:
            jj_la1[9] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
        }
        NodeTest(steps);
    }

    /*
     * [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 89:
                ;
                break;
            default:
                jj_la1[32] = jj_gen;
                break label_14;
            }
            switch (jj_nt.kind) {
            case 89:
                jj_consume_token(89);
                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");
    }

    // Note: XPath does not have reserved words, so we have to include all these terminals
    final public String NCName() throws ParseException {
        switch (jj_nt.kind) {
        case OR:
        case AND:
        case MOD:
        case DIV:
        case NCName:
            NCName_Without_CoreFunctions();
            break;
        case NODE:
            jj_consume_token(NODE);
            break;
        case TEXT:
            jj_consume_token(TEXT);
            break;
        case COMMENT:
            jj_consume_token(COMMENT);
            break;
        case PI:
            jj_consume_token(PI);
            break;
        case FUNCTION_LAST:
            jj_consume_token(FUNCTION_LAST);
            break;
        case FUNCTION_POSITION:
            jj_consume_token(FUNCTION_POSITION);
            break;
        case FUNCTION_COUNT:
            jj_consume_token(FUNCTION_COUNT);
            break;
        case FUNCTION_ID:
            jj_consume_token(FUNCTION_ID);
            break;
        case FUNCTION_LOCAL_NAME:
            jj_consume_token(FUNCTION_LOCAL_NAME);
            break;
        case FUNCTION_NAMESPACE_URI:
            jj_consume_token(FUNCTION_NAMESPACE_URI);
            break;
        case FUNCTION_NAME:
            jj_consume_token(FUNCTION_NAME);
            break;
        case FUNCTION_STRING:
            jj_consume_token(FUNCTION_STRING);
            break;
        case FUNCTION_CONCAT:
            jj_consume_token(FUNCTION_CONCAT);
            break;
        case FUNCTION_STARTS_WITH:
            jj_consume_token(FUNCTION_STARTS_WITH);
            break;
        case FUNCTION_ENDS_WITH:
            jj_consume_token(FUNCTION_ENDS_WITH);
            break;
        case FUNCTION_CONTAINS:
            jj_consume_token(FUNCTION_CONTAINS);
            break;
        case FUNCTION_SUBSTRING_BEFORE:
            jj_consume_token(FUNCTION_SUBSTRING_BEFORE);
            break;
        case FUNCTION_SUBSTRING_AFTER:
            jj_consume_token(FUNCTION_SUBSTRING_AFTER);
            break;
        case FUNCTION_SUBSTRING:
            jj_consume_token(FUNCTION_SUBSTRING);
            break;
        case FUNCTION_STRING_LENGTH:
            jj_consume_token(FUNCTION_STRING_LENGTH);
            break;
        case FUNCTION_NORMALIZE_SPACE:
            jj_consume_token(FUNCTION_NORMALIZE_SPACE);
            break;
        case FUNCTION_TRANSLATE:
            jj_consume_token(FUNCTION_TRANSLATE);
            break;
        case FUNCTION_BOOLEAN:
            jj_consume_token(FUNCTION_BOOLEAN);
            break;
        case FUNCTION_NOT:
            jj_consume_token(FUNCTION_NOT);
            break;
        case FUNCTION_TRUE:
            jj_consume_token(FUNCTION_TRUE);
            break;
        case FUNCTION_FALSE:
            jj_consume_token(FUNCTION_FALSE);
            break;
        case FUNCTION_NULL:
            jj_consume_token(FUNCTION_NULL);
            break;
        case FUNCTION_LANG:
            jj_consume_token(FUNCTION_LANG);
            break;
        case FUNCTION_NUMBER:
            jj_consume_token(FUNCTION_NUMBER);
            break;
        case FUNCTION_SUM:
            jj_consume_token(FUNCTION_SUM);
            break;
        case FUNCTION_FLOOR:
            jj_consume_token(FUNCTION_FLOOR);
            break;
        case FUNCTION_CEILING:
            jj_consume_token(FUNCTION_CEILING);
            break;
        case FUNCTION_ROUND:
            jj_consume_token(FUNCTION_ROUND);
            break;
        case FUNCTION_KEY:
            jj_consume_token(FUNCTION_KEY);
            break;
        case FUNCTION_FORMAT_NUMBER:
            jj_consume_token(FUNCTION_FORMAT_NUMBER);
            break;
        default:
            jj_la1[0] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
        }
        {
            if (true) {
                return token.image;
            }
        }
        throw new Error("Missing return statement in function");
    }

    final public String NCName_Without_CoreFunctions() throws ParseException {
        switch (jj_nt.kind) {
        case NCName:
            jj_consume_token(NCName);
            break;
        case OR:
            jj_consume_token(OR);
            break;
        case AND:
            jj_consume_token(AND);
            break;
        case MOD:
            jj_consume_token(MOD);
            break;
        case DIV:
            jj_consume_token(DIV);
            break;
        default:
            jj_la1[1] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
        }
        {
            if (true) {
                return token.image;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [7] NodeTest ::= WildcardName | NodeType '(' ')' | 'processing-instruction' '(' Literal ')' */
    final public void NodeTest(final ArrayList steps) throws ParseException {
        int axis;
        int type = -1;
        String instruction = null;
        Object name = null;
        Object s;
        Object p;
        final ArrayList ps = new ArrayList();
        switch (jj_nt.kind) {
        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_ENDS_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 87:
        case 89:
            axis = AxisSpecifier();
            if (jj_2_3(2147483647)) {
                type = NodeType();
                jj_consume_token(81);
                jj_consume_token(82);
            } else if (jj_2_4(2147483647)) {
                jj_consume_token(PI);
                jj_consume_token(81);
                jj_consume_token(Literal);
                instruction = unescape(token.image.substring(1, token.image.length() - 1));
                jj_consume_token(82);
            } else {
                switch (jj_nt.kind) {
                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_ENDS_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 89:
                    name = WildcardName();
                    break;
                default:
                    jj_la1[10] = jj_gen;
                    jj_consume_token(-1);
                    throw new ParseException();
                }
            }
            break;
        case 83:
            jj_consume_token(83);
            axis = Compiler.AXIS_SELF;
            type = Compiler.NODE_TYPE_NODE;
            break;
        case 84:
            jj_consume_token(84);
            axis = Compiler.AXIS_PARENT;
            type = Compiler.NODE_TYPE_NODE;
            break;
        default:
            jj_la1[11] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
        }
        label_3: while (true) {
            switch (jj_nt.kind) {
            case 85:
                ;
                break;
            default:
                jj_la1[12] = jj_gen;
                break label_3;
            }
            p = Predicate();
            ps.add(p);
        }
        if (name != null) {
            s = compiler.nodeNameTest(name);
        } else if (instruction != null) {
            s = compiler.processingInstructionTest(instruction);
        } else {
            s = compiler.nodeTypeTest(type);
        }
        steps.add(compiler.step(axis, s, ps.toArray()));
    }

    /* [38] NodeType ::= 'comment' | 'text' | 'processing-instruction' | 'node' */
    final public int NodeType() throws ParseException {
        int type;
        switch (jj_nt.kind) {
        case TEXT:
            jj_consume_token(TEXT);
            type = Compiler.NODE_TYPE_TEXT;
            break;
        case NODE:
            jj_consume_token(NODE);
            type = Compiler.NODE_TYPE_NODE;
            break;
        case COMMENT:
            jj_consume_token(COMMENT);
            type = Compiler.NODE_TYPE_COMMENT;
            break;
        case PI:
            jj_consume_token(PI);
            type = Compiler.NODE_TYPE_PI;
            break;
        default:
            jj_la1[38] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
        }
        {
            if (true) {
                return type;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [21] OrExpr ::= AndExpr | OrExpr 'or' AndExpr */
    final public Object OrExpr() throws ParseException {
        Object ex, r;
        ArrayList list = null;
        ex = AndExpr();
        label_8: while (true) {
            switch (jj_nt.kind) {
            case OR:
                ;
                break;
            default:
                jj_la1[24] = jj_gen;
                break label_8;
            }
            jj_consume_token(OR);
            r = AndExpr();
            if (list == null) {
                list = new ArrayList();
                list.add(ex);
            }
            list.add(r);
        }
        if (list != null) {
            ex = compiler.or(list.toArray());
        }
        {
            if (true) {
                return ex;
            }
        }
        throw new Error("Missing return statement in function");
    }

    final public Object parseExpression() throws ParseException {
        Object ex;
        ex = Expression();
        jj_consume_token(0);
        {
            if (true) {
                return ex;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [19] PathExpr ::= LocationPath | FilterExpr | FilterExpr '/' RelativeLocationPath | FilterExpr '//' RelativeLocationPath */
    final public Object PathExpr() throws ParseException {
        Object ex = null;
        final Object[] steps;
        if (jj_2_6(2147483647)) {
            ex = FilterExpr();
        } else {
            switch (jj_nt.kind) {
            case SLASH:
            case SLASHSLASH:
            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_ENDS_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 83:
            case 84:
            case 87:
            case 89:
                ex = LocationPath();
                break;
            default:
                jj_la1[21] = jj_gen;
                jj_consume_token(-1);
                throw new ParseException();
            }
        }
        {
            if (true) {
                return ex;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [8] Predicate ::= '[' PredicateExpr ']' */
    /* [9] PredicateExpr ::= Expr */
    final public Object Predicate() throws ParseException {
        Object ex;
        jj_consume_token(85);
        ex = Expression();
        jj_consume_token(86);
        {
            if (true) {
                return ex;
            }
        }
        throw new Error("Missing return statement in function");
    }

    /* [15] PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall */
    final public Object PrimaryExpr() throws ParseException {
        Object ex = null;
        switch (jj_nt.kind) {
        case VARIABLE:
            ex = VariableReference();
            break;
        case 81:
            jj_consume_token(81);
            ex = Expression();
            jj_consume_token(82);
            break;
        case Literal:
            jj_consume_token(Literal);
            ex = compiler.literal(unescape(token.image.substring(1, token.image.length() - 1)));
            break;
        case Number:
            jj_consume_token(Number);
            ex = compiler.number(token.image);
            break;
        default:
            jj_la1[16] = jj_gen;
            if (jj_2_5(2147483647)) {
                ex = CoreFunctionCall();
            } else {
                switch (jj_nt.kind) {
                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_ENDS_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:
                    ex = FunctionCall();
                    break;
                default:
                    jj_la1[17] = jj_gen;
                    jj_consume_token(-1);
                    throw new ParseException();
                }
            }
        }
        {
            if (true) {
                return ex;
            }
        }
        throw new Error("Missing return statement in function");
    }

    final public Object QName() throws ParseException {
        String nc1, nc2 = null;
        nc1 = NCName();
        switch (jj_nt.kind) {
        case 80:
            jj_consume_token(80);
            nc2 = NCName();
            break;
        default:
            jj_la1[3] = jj_gen;
            ;
        }
        if (nc2 == null) {
            {
                if (true) {
                    return compiler.qname(null, nc1);
                }
            }
        } else {
            {
                if (true) {
                    return compiler.qname(nc1, nc2);
                }
            }
        }
        throw new Error("Missing return statement in function");
    }

    final public Object QName_Without_CoreFunctions() throws ParseException {
        String nc1, nc2 = null;
        if (jj_2_1(2147483647)) {
            nc1 = NCName();
            jj_consume_token(80);
            nc2 = NCName();
        } else {
            switch (jj_nt.kind) {
            case OR:
            case AND:
            case MOD:
            case DIV:
            case NCName:
                nc1 = NCName_Without_CoreFunctions();
                break;
            default:
                jj_la1[4] = jj_gen;
                jj_consume_token(-1);
                throw new ParseException();
            }
        }
        if (nc2 == null) {
            {
                if (true) {
                    return compiler.qname(null, nc1);
                }
            }
        } else {
            {
                if (true) {
                    return compiler.qname(nc1, nc2);
                }
            }
        }
        throw new Error("Missing return statement in function");
    }

    public void ReInit(final java.io.InputStream stream) {
        jj_input_stream.ReInit(stream, 1, 1);
        token_source.ReInit(jj_input_stream);
        token = new Token();
        token.next = jj_nt = token_source.getNextToken();
        jj_gen = 0;
        for (int i = 0; i < 39; i++) {
            jj_la1[i] = -1;
        }
        for (int i = 0; i < jj_2_rtns.length; i++) {
            jj_2_rtns[i] = new JJCalls();
        }
    }

    public void ReInit(final java.io.Reader stream) {
        jj_input_stream.ReInit(stream, 1, 1);
        token_source.ReInit(jj_input_stream);
        token = new Token();
        token.next = jj_nt = token_source.getNextToken();
        jj_gen = 0;
        for (int i = 0; i < 39; i++) {
            jj_la1[i] = -1;
        }
        for (int i = 0; i < jj_2_rtns.length; i++) {
            jj_2_rtns[i] = new JJCalls();
        }
    }

    public void ReInit(final XPathParserTokenManager tm) {
        token_source = tm;
        token = new Token();
        token.next = jj_nt = token_source.getNextToken();
        jj_gen = 0;
        for (int i = 0; i < 39; i++) {
            jj_la1[i] = -1;
        }
        for (int i = 0; i < jj_2_rtns.length; i++) {
            jj_2_rtns[i] = new JJCalls();
        }
    }

    /*
     * [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] RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | AbbreviatedRelativeLocationPath */
    final public Object RelativeLocationPath() throws ParseException {
        final ArrayList steps = new ArrayList();
        NodeTest(steps);
        label_2: while (true) {
            switch (jj_nt.kind) {
            case SLASH:
            case SLASHSLASH:
                ;
                break;
            default:
                jj_la1[8] = jj_gen;
                break label_2;
            }
            LocationStep(steps);
        }
        {
            if (true) {
                return compiler.locationPath(false, steps.toArray());
            }
        }
        throw new Error("Missing return statement in function");
    }

    public void setCompiler(final Compiler compiler) {
        this.compiler = compiler;
    }

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

    /* [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_ENDS_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 81:
        case 83:
        case 84:
        case 87:
        case 89:
            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");
    }

    private String unescape(String string) {
        int index = string.indexOf("&apos;");
        while (index != -1) {
            string = string.substring(0, index) + "\'" + string.substring(index + 6);
            index = string.indexOf("&apos;");
        }
        index = string.indexOf("&quot;");
        while (index != -1) {
            string = string.substring(0, index) + "\"" + string.substring(index + 6);
            index = string.indexOf("&quot;");
        }
        return string;
    }

    /* [18] UnionExpr ::= PathExpr | UnionExpr '|' PathExpr */
    final public Object UnionExpr() throws ParseException {
        Object ex, r;
        ArrayList list = null;
        ex = PathExpr();
        label_5: while (true) {
            switch (jj_nt.kind) {
            case UNION:
                ;
                break;
            default:
                jj_la1[20] = jj_gen;
                break label_5;
            }
            jj_consume_token(UNION);
            r = PathExpr();
            if (list == null) {
                list = new ArrayList();
                list.add(ex);
            }
            list.add(r);
        }
        if (list != null) {
            ex = compiler.union(list.toArray());
        }
        {
            if (true) {
                return ex;
            }
        }
        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 89:
            jj_consume_token(89);
            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_ENDS_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 80:
            jj_consume_token(80);
            switch (jj_nt.kind) {
            case 89:
                jj_consume_token(89);
                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_ENDS_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);
        } else {
            qn = compiler.qname(null, nc1);
        }
        {
            if (true) {
                return qn;
            }
        }
        throw new Error("Missing return statement in function");
    }
}
