use of org.jdbi.v3.core.internal.lexer.SqlScriptLexer in project jdbi by jdbi.
the class SqlScriptParser method parse.
public String parse(CharStream charStream) {
StringBuilder sb = new StringBuilder();
SqlScriptLexer lexer = new SqlScriptLexer(charStream);
lexer.addErrorListener(new ErrorListener());
boolean endOfFile = false;
while (!endOfFile) {
Token t = lexer.nextToken();
switch(t.getType()) {
case Token.EOF:
endOfFile = true;
break;
case SqlScriptLexer.SEMICOLON:
semicolonHandler.handle(t, sb);
break;
case SqlScriptLexer.COMMENT:
case SqlScriptLexer.MULTI_LINE_COMMENT:
break;
case SqlScriptLexer.NEWLINES:
if (sb.length() > 0) {
sb.append(' ');
}
break;
case SqlScriptLexer.QUOTED_TEXT:
case SqlScriptLexer.LITERAL:
case SqlScriptLexer.OTHER:
sb.append(t.getText());
break;
default:
throw new IllegalArgumentException("Unrecognizable token " + t);
}
}
return sb.toString();
}
Aggregations