Logo Search packages:      
Sourcecode: jruby-joni version File versions  Download package

Node org::joni::Parser::parseExp ( TokenType  term ) [inline, private]

goto end_of_token;!

Definition at line 673 of file Parser.java.

                                          {
        if (token.type == term) {
            //!goto end_of_token;!
            return new StringNode();
        }
        
        Node node = null;
        boolean group = false;

        switch(token.type) {
        case ALT:
        case EOT:
            // !end_of_token:!
            return new StringNode(); // node_new_empty
            
        case SUBEXP_OPEN:
            node = parseEnclose(TokenType.SUBEXP_CLOSE);
            if (returnCode == 1) {
                group = true;
            } else if (returnCode == 2) { /* option only */
                int prev = env.option;
                EncloseNode en = (EncloseNode)node;
                env.option = en.option;
                fetchToken();
                Node target = parseSubExp(term);
                env.option = prev;
                en.setTarget(target);
                return node;                
            }
            break;
            
        case SUBEXP_CLOSE:
            if (!syntax.allowUnmatchedCloseSubexp()) newSyntaxException(ERR_UNMATCHED_CLOSE_PARENTHESIS);
            
            if (token.escaped) {
                // !goto tk_raw_byte;!
                return parseExpTkRawByte(group);
            } else {
                // !goto tk_byte;!
                return parseExpTkByte(group);
            }
            
        case STRING:
            // !tk_byte:!
            return parseExpTkByte(group);
            
        case RAW_BYTE:
            // !tk_raw_byte:!
            return parseExpTkRawByte(group);
            
        case CODE_POINT:
            byte[]buf = new byte[Config.ENC_CODE_TO_MBC_MAXLEN];
            int num = enc.codeToMbc(token.getCode(), buf, 0);
            // #ifdef NUMBERED_CHAR_IS_NOT_CASE_AMBIG ... // setRaw() #else 
            node = new StringNode(buf, 0, num);
            break;
            
        case QUOTE_OPEN:
            int[]endOp = new int[]{syntax.metaCharTable.esc, 'E'};
            int qstart = p;
            int qend = findStrPosition(endOp, endOp.length, qstart, stop); // will set nextChar!!!
            if (qend == -1) {
                nextChar = qend = stop;
            }
            node = new StringNode(bytes, qstart, qend);
            p = nextChar;
            break;

        case CHAR_TYPE:
            switch(token.getPropCType()) {
            case CharacterType.WORD:
                node = new CTypeNode(token.getPropCType(), token.getPropNot());
                break;
            
            case CharacterType.SPACE:
            case CharacterType.DIGIT:
            case CharacterType.XDIGIT:
                // #ifdef USE_SHARED_CCLASS_TABLE ... #endif
                CClassNode ccn = new CClassNode();
                ccn.addCType(token.getPropCType(), false, env, this);
                if (token.getPropNot()) ccn.setNot();
                node = ccn;
                break;
                
            default:
                newInternalException(ERR_PARSER_BUG);
                
            } // inner switch
            break;
            
        case CHAR_PROPERTY:
            node = parseCharProperty();
            break;
            
        case CC_CC_OPEN:
            CClassNode cc = parseCharClass();
            node = cc;
            if (isIgnoreCase(env.option)) {
                ApplyCaseFoldArg arg = new ApplyCaseFoldArg(env, cc);
                enc.applyAllCaseFold(env.caseFoldFlag, ApplyCaseFold.INSTANCE, arg);
            
                if (arg.altRoot != null) {
                    node = ConsAltNode.newAltNode(node, arg.altRoot);
                }
            }
            break;
            
        case ANYCHAR:
            node = new AnyCharNode();
            break;
            
        case ANYCHAR_ANYTIME:
            node = new AnyCharNode();
            QuantifierNode qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
            qn.setTarget(node);
            node = qn;
            break;
            
        case BACKREF:
            int[]backRefs = token.getBackrefNum() > 1 ? token.getBackrefRefs() : new int[]{token.getBackrefRef1()};
            node = new BackRefNode(token.getBackrefNum(),
                            backRefs,
                            token.getBackrefByName(),
                            token.getBackrefExistLevel(), // #ifdef USE_BACKREF_AT_LEVEL
                            token.getBackrefLevel(),      // ...
                            env);
            
            break;
            
        case CALL:
            if (Config.USE_SUBEXP_CALL) {
                int gNum = token.getCallGNum();

                if (gNum < 0) {
                    gNum = backrefRelToAbs(gNum);
                    if (gNum <= 0) newValueException(ERR_INVALID_BACKREF);
                }
                node = new CallNode(bytes, token.getCallNameP(), token.getCallNameEnd(), gNum);
                env.numCall++;
                break;
            } // USE_SUBEXP_CALL
            break;

        case ANCHOR:
            node = new AnchorNode(token.getAnchor()); // possible bug in oniguruma
            break;
            
        case OP_REPEAT:
        case INTERVAL:
            if (syntax.contextIndepRepeatOps()) {
                if (syntax.contextInvalidRepeatOps()) {
                    newSyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED);
                } else {
                    node = new StringNode(); // node_new_empty
                }
            } else {
                // !goto tk_byte;!
                return parseExpTkByte(group);
            }
            break;
            
        default:
            newInternalException(ERR_PARSER_BUG);
        } //switch
        
        //targetp = node;
        
        // !re_entry:!
        fetchToken();
        
        // !repeat:!
        return parseExpRepeat(node, group);
    }

Generated by  Doxygen 1.6.0   Back to index