use of io.shardingjdbc.core.parsing.lexer.token.Token in project sharding-jdbc by shardingjdbc.
the class AbstractCreateParser method parseIndex.
private void parseIndex(final DDLStatement ddlStatement) {
Token currentToken = lexerEngine.getCurrentToken();
int beginPosition = currentToken.getEndPosition() - currentToken.getLiterals().length();
String literals = currentToken.getLiterals();
lexerEngine.skipUntil(DefaultKeyword.ON);
lexerEngine.nextToken();
String tableName = lexerEngine.getCurrentToken().getLiterals();
ddlStatement.getSqlTokens().add(new IndexToken(beginPosition, literals, tableName));
}
use of io.shardingjdbc.core.parsing.lexer.token.Token in project sharding-jdbc by shardingjdbc.
the class Lexer method nextToken.
/**
* Analyse next token.
*/
public final void nextToken() {
skipIgnoredToken();
if (isVariableBegin()) {
currentToken = new Tokenizer(input, dictionary, offset).scanVariable();
} else if (isNCharBegin()) {
currentToken = new Tokenizer(input, dictionary, ++offset).scanChars();
} else if (isIdentifierBegin()) {
currentToken = new Tokenizer(input, dictionary, offset).scanIdentifier();
} else if (isHexDecimalBegin()) {
currentToken = new Tokenizer(input, dictionary, offset).scanHexDecimal();
} else if (isNumberBegin()) {
currentToken = new Tokenizer(input, dictionary, offset).scanNumber();
} else if (isSymbolBegin()) {
currentToken = new Tokenizer(input, dictionary, offset).scanSymbol();
} else if (isCharsBegin()) {
currentToken = new Tokenizer(input, dictionary, offset).scanChars();
} else if (isEnd()) {
currentToken = new Token(Assist.END, "", offset);
} else {
throw new SQLParsingException(this, Assist.ERROR);
}
offset = currentToken.getEndPosition();
}
use of io.shardingjdbc.core.parsing.lexer.token.Token in project sharding-jdbc by shardingjdbc.
the class Tokenizer method scanSymbol.
/**
* scan symbol.
*
* @return symbol token
*/
public Token scanSymbol() {
int length = 0;
while (CharType.isSymbol(charAt(offset + length))) {
length++;
}
String literals = input.substring(offset, offset + length);
Symbol symbol;
while (null == (symbol = Symbol.literalsOf(literals))) {
literals = input.substring(offset, offset + --length);
}
return new Token(symbol, literals, offset + length);
}
use of io.shardingjdbc.core.parsing.lexer.token.Token in project sharding-jdbc by shardingjdbc.
the class LexerAssert method assertNextToken.
public static void assertNextToken(final Lexer lexer, final TokenType expectedTokenType, final String expectedLiterals) {
lexer.nextToken();
Token actualToken = lexer.getCurrentToken();
assertThat(actualToken.getType(), is(expectedTokenType));
assertThat(actualToken.getLiterals(), is(expectedLiterals));
}
use of io.shardingjdbc.core.parsing.lexer.token.Token in project sharding-jdbc by shardingjdbc.
the class AbstractDropParser method parseIndex.
private void parseIndex(final DDLStatement ddlStatement) {
Token currentToken = lexerEngine.getCurrentToken();
int beginPosition = currentToken.getEndPosition() - currentToken.getLiterals().length();
String literals = currentToken.getLiterals();
lexerEngine.skipUntil(DefaultKeyword.ON);
if (lexerEngine.skipIfEqual(DefaultKeyword.ON)) {
tableReferencesClauseParser.parseSingleTableWithoutAlias(ddlStatement);
ddlStatement.getSqlTokens().add(new IndexToken(beginPosition, literals, ddlStatement.getTables().getSingleTableName()));
} else {
ddlStatement.getSqlTokens().add(new IndexToken(beginPosition, literals, ""));
}
}
Aggregations