当前位置: 首页>>代码示例>>Java>>正文


Java LexerInput.EOF属性代码示例

本文整理汇总了Java中org.netbeans.spi.lexer.LexerInput.EOF属性的典型用法代码示例。如果您正苦于以下问题:Java LexerInput.EOF属性的具体用法?Java LexerInput.EOF怎么用?Java LexerInput.EOF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.netbeans.spi.lexer.LexerInput的用法示例。


在下文中一共展示了LexerInput.EOF属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkLexerInputFinished

/**
 * Check that there are no more characters to be read from the given
 * lexer input operation.
 */
private void checkLexerInputFinished() {
    if (read() != LexerInput.EOF || readLength() > 0) {
        StringBuilder sb = new StringBuilder(100);
        int readLen = readLength();
        sb.append("Lexer ").append(lexer); // NOI18N
        sb.append("\n  returned null token but lexerInput.readLength()="); // NOI18N
        sb.append(readLen);
        sb.append("\n  lexer-state: ").append(lexer.state());
        sb.append("\n  ").append(this); // NOI18N
        sb.append("\n  Chars: \"");
        for (int i = 0; i < readLen; i++) {
            sb.append(CharSequenceUtilities.debugChar(readExistingAtIndex(i)));
        }
        sb.append("\" - these characters need to be tokenized."); // NOI18N
        sb.append("\nFix the lexer to not return null token in this state."); // NOI18N
        throw new IllegalStateException(sb.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:LexerInputOperation.java

示例2: nextToken

public Token<ATokenId> nextToken () {
    LexerInput lexerInput = info.input ();
    int i = lexerInput.read ();
    if (i == ' ') {
        do {
            i = lexerInput.read ();
        } while (i == ' ');
        if (i != LexerInput.EOF) {
            lexerInput.backup (1);
        }
        return info.tokenFactory ().createToken (tokenIds.get (0));
    } else {
        if (i == LexerInput.EOF) {
            return null;
        } else {
            do {
                i = lexerInput.read ();
            } while (i != ' ' && i != LexerInput.EOF);
            if (i != LexerInput.EOF) {
                lexerInput.backup (1);
            }
            return info.tokenFactory ().createToken (tokenIds.get (1));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ALanguageHierarchy.java

示例3: read

public int read(int index) { // index >= 0 is guaranteed by contract
    index += tokenStartIndex;
    if (index < readEndIndex()) {
        // Check whether the char is preprocessed
        int rls = preprocessedText.rawLengthShift(index);
        if (rls != lastRawLengthShift) { // Preprocessed
            lastRawLengthShift = rls;
            if (prepStartIndex >= index) { // prepStartIndex already inited
                prepStartIndex = index;
            }
            prepEndIndex = index + 1;
        }
        return preprocessedText.charAt(index);
    } else { // must read next or return EOF
        return LexerInput.EOF;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PreprocessedTextLexerInputOperation.java

示例4: processParsedEntity

private Token<DTDTokenId> processParsedEntity() {
    int ch;
    boolean first = true;
    while ((ch = input.read()) != LexerInput.EOF) {
        if (ch == ';') {
            return first ? null : tokenFactory.createToken(DTDTokenId.REFERENCE);
        }
        if (!((first && Character.isLetter(ch)) || 
                (!first && (
                    ch == '-' || ch == '.' || Character.isLetterOrDigit(ch))))) {
            // not an entity reference, fall back to normal text processing:
            break;
        } 
        first = false;
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:DTDLexer.java

示例5: skipWhitespace

/**
 * Skips whitespaces within declaration, produces DTDToken if whitespace
 * is found. Does not change state / substate.
 * @return 
 */
private Token<DTDTokenId> skipWhitespace() {
    int ch;
    int start = input.readLength();
    while ((ch = input.read()) != LexerInput.EOF) {
        if (!Character.isWhitespace(ch)) {
            input.backup(1);
            if ((input.readLength() - start) > 0) {
                return tokenFactory.createToken(DTDTokenId.WS, input.readLength() - start);
            }
            break;
        }
    }
    if ((input.readLength() - start) > 0) {
        return tokenFactory.createToken(DTDTokenId.WS, input.readLength() - start);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:DTDLexer.java

示例6: readRemainingLine

@SuppressWarnings("fallthrough")
private final void readRemainingLine() {
    
    int character = input.read();
    
    while(character != LexerInput.EOF) {
        switch (character) {
            case '\r':
                input.consumeNewline();
            case '\n':
            case LexerInput.EOF:
                return;
        }
        character = input.read();
    }
    
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:17,代码来源:GlslLexer.java

示例7: read

private int read() {
    int result = input.read();
    if (result == LexerInput.EOF) {
        result = CharStream.EOF;
    }

    return result;
}
 
开发者ID:onekosha,项目名称:nb-clojure,代码行数:8,代码来源:AntlrCharStream.java

示例8: processDeclarationName

private Token<DTDTokenId> processDeclarationName() {
    int ch;
    boolean first = true;
    while ((ch = input.read()) != LexerInput.EOF) {
        if (first && (ch == '%') && (state == ISI_ENTITY)) {
            int n = input.read();
            if (Character.isWhitespace(n)) {
                // ENTITY % whatever. Emit OPERATOR
                return tokenFactory.createToken(DTDTokenId.OPERATOR);
            }
            input.backup(1);
        }
        if (ch == '%' || ch == '&') {
            Token<DTDTokenId> t = processEntityOrCharacterRef();
            substate = SUB_DECLARATION_DEF;
            if (t != null) {
                return t;
            } else {
                return error();
            }
        }
        if (!isNametokenChar(ch, first)) {
            if (first) {
                substate = SUB_DECLARATION_DEF;
                return error();
            }
            input.backup(1);
            break;
        }
        first = false;
    }
    substate = SUB_DECLARATION_DEF;
    return tokenFactory.createToken(DTDTokenId.NAME);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:DTDLexer.java

示例9: readChar

@Override
public char readChar() throws IOException {
    int read = input.read();

    if (read == LexerInput.EOF) {
        throw new IOException("EOF reached.");
    }
    return (char) read;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:9,代码来源:PoshCharStream.java

示例10: nextProcessingContent

private Token<DTDTokenId> nextProcessingContent() {
    int ch;
    boolean white = false;
    int whiteStart = -1;
    
    while ((ch = input.read()) != LexerInput.EOF) {
        if (ch == '?') {
            if (whiteStart > 0) {
                return tokenFactory.createToken(DTDTokenId.PI_CONTENT, whiteStart);
            }
            if (input.readLength() > 1) {
                input.backup(1);
                return tokenFactory.createToken(DTDTokenId.PI_CONTENT);
            }
            ch = input.read();
            if (ch == '>') {
                return tokenFactory.createToken(DTDTokenId.SYMBOL);
            }
            // exit the processing content
            setState(ISI_INIT);
            return tokenFactory.createToken(DTDTokenId.ERROR);
        }
        if (Character.isWhitespace(ch)) {
            if (whiteStart == -1) {
                whiteStart = input.readLength();
            }
            if (input.readLength() == 1) {
                white = true;
            }
        } else if (white) {
            // report whitespace & continue lexing in the same state:
            return tokenFactory.createToken(DTDTokenId.WS);
        }
    }
    return tokenFactory.createToken(DTDTokenId.PI_CONTENT);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:DTDLexer.java

示例11: nextToken

@Override
public Token<CPTokenId> nextToken() {
    //just read whole input
    while(input.read() != LexerInput.EOF) {};
    //and create one big token
    return input.readLength() > 0 
            ? tokenFactory.createToken(CPTokenId.CSS) 
            : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CPLexer.java

示例12: BeginToken

@Override
public char BeginToken() throws IOException {
    int chr = input.read();
    if (chr == LexerInput.EOF) {
        throw new IOException();
    }
    return (char) chr;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:8,代码来源:PoshCharStream.java

示例13: commandLine

private Token<JShellToken>  commandLine() {
    int c = input.read();
    if (c == LexerInput.EOF) {
        return null;
    }
    if (Character.isWhitespace(c)) {
        boolean endsNonWhite = eatWhitespace();
        if (!endsNonWhite) {
            input.backup(1);
        } else {
            setState(S.INITIAL);
        }
        return blockToken(JShellToken.WHITESPACE);
    }
    int quote = 0;
    if (c == '\'' || c == '"') {
        quote = c;
        c = input.read();
    }
    
    if (c == '-') {
        // dash-option
        return readParameter(JShellToken.COMMAND_OPTION, quote);
    } else {
        return readParameter(quote == 0  ? JShellToken.COMMAND_PARAM : JShellToken.COMMAND_STRING, quote);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JShellLexer.java

示例14: readParameter

private Token<JShellToken> readParameter(JShellToken tokenId, int quote) {
    int c = input.read();
    boolean verbatim = false;
    
    while (true) {
        if (c == LexerInput.EOF) {
            // only partial token
            state = S.INITIAL;
            return tokenFactory.createToken(tokenId, input.readLength(), PartType.START);
        }
        if (c == '\\') { // NOI18N
            // next character verbatim
            verbatim = true;
            c = input.read();
            continue;
        }
        if (!verbatim && c == quote) {
            break;
        }
        if (!verbatim && quote == 0) {
            if (Character.isWhitespace(c)) {
                input.backup(1);
                break;
            }
        } else if (c == '\n') { // NOI18N
            // unterminated quote
            input.backup(1);
            state = S.INITIAL;
            return tokenFactory.createToken(tokenId, input.readLength(), PartType.START);
        }
        verbatim = false;
        c = input.read();
    }
    return tokenFactory.createToken(tokenId, input.readLength());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:JShellLexer.java

示例15: nextProcessingTarget

private Token<DTDTokenId> nextProcessingTarget() {
    int ch;
    boolean first = true;
    
    while ((ch = input.read()) != LexerInput.EOF) {
        if (ch == '?') { // NOI18N
            if (first) {
                return nextProcessingContent();
            }
            substate = SUB_PROCESSING_CONTENT;
            input.backup(1);
            break;
        } else if (Character.isWhitespace(ch)) {
            if (first) {
                return tokenFactory.createToken(DTDTokenId.ERROR);
            }
            substate = SUB_PROCESSING_CONTENT;
            input.backup(1);
            break;
        }
        if (!((first & Character.isLetter(ch)) ||
            (!first && Character.isLetterOrDigit(ch)))) {
            // apparently an error:
            return tokenFactory.createToken(DTDTokenId.ERROR);
        }
        first = false;
    }
    if ("xml".equalsIgnoreCase(input.readText().toString())) { // NOI18N
        substate = SUB_PROCESSING_XML;
    }
    return tokenFactory.createToken(DTDTokenId.TARGET);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:DTDLexer.java


注:本文中的org.netbeans.spi.lexer.LexerInput.EOF属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。