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


Java Token.DEFAULT_CHANNEL属性代码示例

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


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

示例1: nextToken

/**
 * Return the next token from the character stream and records this last
 * token in case it resides on the default channel. This recorded token
 * is used to determine when the lexer could possibly match a regex
 * literal.
 *
 * @return the next token from the character stream.
 */
@Override
public Token nextToken() {

    // Get the next token.
    Token next = super.nextToken();

    if (next.getChannel() == Token.DEFAULT_CHANNEL) {
        // Keep track of the last token on the default channel.
        this.lastToken = next;
    }

    return next;
}
 
开发者ID:rockscript,项目名称:rockscript,代码行数:21,代码来源:ECMAScriptLexer.java

示例2: nextToken

@Override
public Token nextToken()
{
    if (_input == null) {
        throw new IllegalStateException("nextToken requires a non-null input stream.");
    }

    // Mark start location in char stream so unbuffered streams are
    // guaranteed at least have text of current token
    int tokenStartMarker = _input.mark();
    try {
        outer:
        while (true) {
            if (_hitEOF) {
                emitEOF();
                return _token;
            }

            _token = null;
            _channel = Token.DEFAULT_CHANNEL;
            _tokenStartCharIndex = _input.index();
            _tokenStartCharPositionInLine = getInterpreter().getCharPositionInLine();
            _tokenStartLine = getInterpreter().getLine();
            _text = null;
            do {
                _type = Token.INVALID_TYPE;
                int ttype = -1;

                // This entire method is copied from org.antlr.v4.runtime.Lexer, with the following bit
                // added to match the delimiters before we attempt to match the token
                boolean found = false;
                for (String terminator : delimiters) {
                    if (match(terminator)) {
                        ttype = SqlBaseParser.DELIMITER;
                        found = true;
                        break;
                    }
                }

                if (!found) {
                    try {
                        ttype = getInterpreter().match(_input, _mode);
                    }
                    catch (LexerNoViableAltException e) {
                        notifyListeners(e);        // report error
                        recover(e);
                        ttype = SKIP;
                    }
                }

                if (_input.LA(1) == IntStream.EOF) {
                    _hitEOF = true;
                }
                if (_type == Token.INVALID_TYPE) {
                    _type = ttype;
                }
                if (_type == SKIP) {
                    continue outer;
                }
            }
            while (_type == MORE);
            if (_token == null) {
                emit();
            }
            return _token;
        }
    }
    finally {
        // make sure we release marker after match or
        // unbuffered char stream will keep buffering
        _input.release(tokenStartMarker);
    }
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:73,代码来源:DelimiterLexer.java


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