foundation.jpa.querydsl.groupby.GroupByLexer Maven / Gradle / Ivy
package foundation.jpa.querydsl.groupby;
import foundation.rpg.parser.Element;
import foundation.rpg.parser.Lexer;
import foundation.rpg.parser.Input;
import foundation.rpg.parser.Position;
import foundation.rpg.parser.End;
import java.io.IOException;
import foundation.rpg.parser.TokenBuilder;
public class GroupByLexer implements Lexer {
private final foundation.jpa.querydsl.groupby.GroupByFactory factory;
public GroupByLexer(foundation.jpa.querydsl.groupby.GroupByFactory factory) {
this.factory = factory;
}
public foundation.jpa.querydsl.groupby.GroupByFactory getFactory() {
return factory;
}
public Element next(Input input) throws IOException {
int state = 0;
int symbol = input.lookahead();
TokenBuilder builder = new TokenBuilder(input);
if(symbol < 0) return new ElementEnd(new End(builder.build()));
for(; true; symbol = builder.next()) {
switch(state) {
case 0:
switch(symbol) {
case ',': state = 1; break;
case '.': state = 2; break;
default:
if(Lexer.matchesGroup('s', symbol)) { state = 3; break; }
if(Lexer.matchesGroup('i', symbol)) { state = 4; break; }
input.error("Unexpected character: '" + (char) symbol + "'");
}
break;
case 1:
return new ElementComma(new foundation.rpg.common.symbols.Comma(builder.build()));
case 2:
return new ElementDot(new foundation.rpg.common.symbols.Dot(builder.build()));
case 3:
if(Lexer.matchesGroup('s', symbol)) { state = 3; break; }
return new ElementWhiteSpace(new foundation.rpg.common.symbols.WhiteSpace(builder.build()));
case 4:
if(Lexer.matchesGroup('w', symbol)) { state = 5; break; }
return new ElementIdentifier(new foundation.rpg.common.symbols.Identifier(builder.build()));
case 5:
if(Lexer.matchesGroup('w', symbol)) { state = 5; break; }
return new ElementIdentifier(new foundation.rpg.common.symbols.Identifier(builder.build()));
}
}
}
}