net.intelie.pipes.generated.PipesTokenManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-api Show documentation
Show all versions of pipes-api Show documentation
Intelie Pipes' API classes and interfaces
package net.intelie.pipes.generated;
import net.intelie.pipes.ast.SourceLocation;
import net.intelie.pipes.util.PipesCharStream;
public interface PipesTokenManager {
class Token extends net.intelie.pipes.generated.Token {
public String fullCode;
public int beginPos, endPos;
public Token(String fullCode) {
this.fullCode = fullCode;
}
}
PipesCharStream stream();
default Token copyToken(net.intelie.pipes.generated.Token token) {
PipesCharStream stream = stream();
Token myToken = new Token(stream.getInput());
myToken.fullCode = stream.getInput();
myToken.beginPos = stream.getBeginIndex();
myToken.endPos = stream.getIndex();
myToken.next = token.next;
myToken.image = token.image;
myToken.kind = token.kind;
myToken.beginColumn = token.beginColumn;
myToken.beginLine = token.beginLine;
myToken.endColumn = token.endColumn;
myToken.endLine = token.endLine;
myToken.specialToken = token.specialToken;
return myToken;
}
class Pipe extends PipeParserCoreTokenManager implements PipesTokenManager {
private final PipesCharStream stream;
public Pipe(PipesCharStream stream) {
super(stream);
this.stream = stream;
}
@Override
public PipesCharStream stream() {
return stream;
}
@Override
protected Token jjFillToken() {
return copyToken(super.jjFillToken());
}
}
class Filter extends FilterParserCoreTokenManager implements PipesTokenManager {
private final PipesCharStream stream;
public Filter(PipesCharStream stream) {
super(stream);
this.stream = stream;
}
@Override
public PipesCharStream stream() {
return stream;
}
@Override
protected Token jjFillToken() {
return copyToken(super.jjFillToken());
}
}
class Span extends TimeSpanParserCoreTokenManager implements PipesTokenManager {
private final PipesCharStream stream;
public Span(PipesCharStream stream) {
super(stream);
this.stream = stream;
}
@Override
public PipesCharStream stream() {
return stream;
}
@Override
protected Token jjFillToken() {
return copyToken(super.jjFillToken());
}
}
static SourceLocation toFullLocation(Token token) {
if (token.image == null || token.image.isEmpty()) {
return toLocation(token);
} else {
return new SourceLocation(toLocation(token), toLocationEnd(token));
}
}
static SourceLocation toLocation(Token token) {
return new SourceLocation(token.fullCode, token.beginPos, token.beginLine, token.beginColumn);
}
static SourceLocation toLocationBegin(Token token) {
return toLocation((Token) token.next);
}
static SourceLocation toLocationEnd(Token token) {
return new SourceLocation(token.fullCode, token.endPos + 1,
token.endLine, token.endColumn);
}
static SourceLocation toLocationPoint(Token token) {
return new SourceLocation(token.fullCode, token.endPos,
token.endLine, token.endColumn);
}
}