use of org.antlr.v4.runtime.misc.NotNull in project scheduler by btrplace.
the class MyCstrSpecVisitor method visitCall.
@Override
public FunctionCall visitCall(@NotNull CstrSpecParser.CallContext ctx) {
List<Term> ps = ctx.term().stream().map(t -> (Term<?>) visit(t)).collect(Collectors.toList());
Function f = resolveFunction(ctx.ID().getSymbol(), ps);
FunctionCall.Moment m = FunctionCall.Moment.ANY;
if (ctx.BEGIN() != null) {
m = FunctionCall.Moment.BEGIN;
}
return new FunctionCall(f, ps, m);
}
use of org.antlr.v4.runtime.misc.NotNull in project scheduler by btrplace.
the class MyCstrSpecVisitor method visitTypedef.
@Override
public List<UserVar<?>> visitTypedef(@NotNull CstrSpecParser.TypedefContext ctx) {
Term<?> parent = (Term<?>) visit(ctx.term());
if (parent.type() instanceof Atomic) {
throw new SpecException(filename, ctx.op.getCharPositionInLine(), "The right-hand side must be a collection");
}
List<UserVar<?>> vars = new ArrayList<>();
for (TerminalNode n : ctx.ID()) {
String lbl = n.getText();
UserVar v = new UserVar(lbl, ctx.op.getText(), parent);
symbols.put(v);
vars.add(v);
}
return vars;
}
use of org.antlr.v4.runtime.misc.NotNull in project redsnake by Taken0711.
the class TestUtils method parseProgram.
public static Program parseProgram(@NotNull String... s) {
StringBuilder str = new StringBuilder();
Arrays.stream(s).forEach(st -> str.append(st).append(System.lineSeparator()));
CharStream inputStream = CharStreams.fromString(str.toString());
RedsnakeLexer redsnakeLexer = new RedsnakeLexer(inputStream);
TokenStream commonTokenStream = new CommonTokenStream(redsnakeLexer);
RedsnakeParser parser = new RedsnakeParser(commonTokenStream);
ParseTree t = parser.program();
return (Program) new ASTBuilder().visit(t);
}
use of org.antlr.v4.runtime.misc.NotNull in project vespa by vespa-engine.
the class ProgramParser method prepareParser.
private yqlplusParser prepareParser(String programName, CharStream input) {
yqlplusLexer lexer = new yqlplusLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(new BaseErrorListener() {
@Override
public void syntaxError(@NotNull Recognizer<?, ?> recognizer, @Nullable Object offendingSymbol, int line, int charPositionInLine, @NotNull String msg, @Nullable RecognitionException e) {
throw new ProgramCompileException(new Location(programName, line, charPositionInLine), msg);
}
});
TokenStream tokens = new CommonTokenStream(lexer);
yqlplusParser parser = new yqlplusParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(new BaseErrorListener() {
@Override
public void syntaxError(@NotNull Recognizer<?, ?> recognizer, @Nullable Object offendingSymbol, int line, int charPositionInLine, @NotNull String msg, @Nullable RecognitionException e) {
throw new ProgramCompileException(new Location(programName, line, charPositionInLine), msg);
}
});
parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
return parser;
}
use of org.antlr.v4.runtime.misc.NotNull in project titan.EclipsePlug-ins by eclipse.
the class TitanListener method syntaxError.
@Override
public void syntaxError(@NotNull final Recognizer<?, ?> recognizer, @Nullable final Object offendingSymbol, final int line, final int charPositionInLine, @NotNull final String msg, @Nullable final RecognitionException e) {
SyntacticErrorStorage errorStorage;
if (offendingSymbol instanceof CommonToken) {
final CommonToken token = (CommonToken) offendingSymbol;
errorStorage = new SyntacticErrorStorage(line, token.getStartIndex(), token.getStopIndex() + 1, msg, e);
} else {
errorStorage = new SyntacticErrorStorage(line, charPositionInLine, charPositionInLine + 1, msg, e);
}
errorsStored.add(errorStorage);
}
Aggregations