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


Java TokenSource.nextToken方法代码示例

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


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

示例1: StatementSplitter

import org.antlr.v4.runtime.TokenSource; //导入方法依赖的package包/类
public StatementSplitter(String sql, Set<String> delimiters)
{
    TokenSource tokens = getLexer(sql, delimiters);
    ImmutableList.Builder<Statement> list = ImmutableList.builder();
    StringBuilder sb = new StringBuilder();
    while (true) {
        Token token = tokens.nextToken();
        if (token.getType() == Token.EOF) {
            break;
        }
        if (token.getType() == SqlBaseParser.DELIMITER) {
            String statement = sb.toString().trim();
            if (!statement.isEmpty()) {
                list.add(new Statement(statement, token.getText()));
            }
            sb = new StringBuilder();
        }
        else {
            sb.append(token.getText());
        }
    }
    this.completeStatements = list.build();
    this.partialStatement = sb.toString().trim();
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:25,代码来源:StatementSplitter.java

示例2: squeezeStatement

import org.antlr.v4.runtime.TokenSource; //导入方法依赖的package包/类
public static String squeezeStatement(String sql)
{
    TokenSource tokens = getLexer(sql, ImmutableSet.of());
    StringBuilder sb = new StringBuilder();
    while (true) {
        Token token = tokens.nextToken();
        if (token.getType() == Token.EOF) {
            break;
        }
        if (token.getType() == SqlBaseLexer.WS) {
            sb.append(' ');
        }
        else {
            sb.append(token.getText());
        }
    }
    return sb.toString().trim();
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:19,代码来源:StatementSplitter.java

示例3: squeezeStatement

import org.antlr.v4.runtime.TokenSource; //导入方法依赖的package包/类
public static String squeezeStatement(String sql)
{
    TokenSource tokens = getLexer(sql, ImmutableSet.<String>of());
    StringBuilder sb = new StringBuilder();
    while (true) {
        Token token = tokens.nextToken();
        if (token.getType() == Token.EOF) {
            break;
        }
        if (token.getType() == SqlBaseLexer.WS) {
            sb.append(' ');
        }
        else {
            sb.append(token.getText());
        }
    }
    return sb.toString().trim();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:StatementSplitter.java

示例4: isEmptyStatement

import org.antlr.v4.runtime.TokenSource; //导入方法依赖的package包/类
public static boolean isEmptyStatement(String sql)
{
    TokenSource tokens = getLexer(sql, ImmutableSet.of());
    while (true) {
        Token token = tokens.nextToken();
        if (token.getType() == Token.EOF) {
            return true;
        }
        if (token.getChannel() != Token.HIDDEN_CHANNEL) {
            return false;
        }
    }
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:14,代码来源:StatementSplitter.java

示例5: initTokens

import org.antlr.v4.runtime.TokenSource; //导入方法依赖的package包/类
/**
 * @requires the tokens of this are not initialized yet && source != null
 * @modifies this
 * @effects Initializes the tokens of this with the given token source.
 */
private void initTokens(TokenSource source) {
    Assert.isTrue(tokens.isEmpty());

    Token token;

    do {
        token = source.nextToken();
        tokens.add(token);
    } while (token.getType() != Token.EOF);
}
 
开发者ID:mwillema,项目名称:protobuf-netbeans-plugin,代码行数:16,代码来源:AntlrDocument.java

示例6: isEmptyStatement

import org.antlr.v4.runtime.TokenSource; //导入方法依赖的package包/类
public static boolean isEmptyStatement(String sql)
{
    TokenSource tokens = getLexer(sql, ImmutableSet.<String>of());
    while (true) {
        Token token = tokens.nextToken();
        if (token.getType() == Token.EOF) {
            return true;
        }
        if (token.getChannel() != Token.HIDDEN_CHANNEL) {
            return false;
        }
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:14,代码来源:StatementSplitter.java


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