本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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;
}
}
}
示例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);
}
示例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;
}
}
}