use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorBase method visitAxiomDefinition.
@Override
public Object visitAxiomDefinition(CatParser.AxiomDefinitionContext ctx) {
try {
Relation r = ctx.e.accept(relationVisitor);
if (r == null) {
throw new ParsingException(ctx.getText());
}
Constructor<?> constructor = ctx.cls.getConstructor(Relation.class);
wmm.addAxiom((Axiom) constructor.newInstance(r));
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new ParsingException(ctx.getText());
}
return null;
}
use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorBase method visitLetRecAndDefinition.
@Override
public Object visitLetRecAndDefinition(CatParser.LetRecAndDefinitionContext ctx) {
RecursiveRelation rRecursive = (RecursiveRelation) relationRepository.getRelation(RecursiveRelation.class, ctx.n.getText());
Relation rConcrete = ctx.e.accept(relationVisitor);
if (rRecursive == null || rConcrete == null) {
throw new ParsingException(ctx.getText());
}
rRecursive.setConcreteRelation(rConcrete);
recursiveGroup.add(rRecursive);
return null;
}
use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorBase method visitLetRecDefinition.
@Override
public Object visitLetRecDefinition(CatParser.LetRecDefinitionContext ctx) {
recursiveGroup = new HashSet<>();
recursiveDef = true;
RecursiveRelation rRecursive = (RecursiveRelation) relationRepository.getRelation(RecursiveRelation.class, ctx.n.getText());
Relation rConcrete = ctx.e.accept(relationVisitor);
if (rRecursive == null || rConcrete == null) {
throw new ParsingException(ctx.getText());
}
rRecursive.setConcreteRelation(rConcrete);
recursiveGroup.add(rRecursive);
for (CatParser.LetRecAndDefinitionContext c : ctx.letRecAndDefinition()) {
c.accept(this);
}
wmm.addRecursiveGroup(recursiveGroup);
recursiveDef = false;
return null;
}
use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class ProgramParser method parse.
public Program parse(String raw, String format) throws Exception {
switch(format) {
case "c":
case "i":
File CFile = File.createTempFile("dat3m", ".c");
CFile.deleteOnExit();
String name = CFile.getName().substring(0, CFile.getName().lastIndexOf('.'));
try (FileWriter writer = new FileWriter(CFile)) {
writer.write(raw);
}
compileWithClang(CFile);
compileWithSmack(CFile);
File BplFile = new File(System.getenv("DAT3M_HOME") + "/output/" + name + ".bpl");
BplFile.deleteOnExit();
Program p = new ProgramParser().parse(BplFile);
CFile.delete();
BplFile.delete();
return p;
case "bpl":
return new ParserBoogie().parse(CharStreams.fromString(raw));
case "litmus":
return getConcreteLitmusParser(raw.toUpperCase()).parse(CharStreams.fromString(raw));
}
throw new ParsingException("Unknown input file type");
}
use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorBoogie method preProc_decl.
private void preProc_decl(Proc_declContext ctx) {
String name = ctx.proc_sign().Ident().getText();
if (procedures.containsKey(name)) {
throw new ParsingException("Procedure " + name + " is already defined");
}
if (name.equals("main") && ctx.proc_sign().proc_sign_in() != null) {
threadCallingValues.put(threadCount, new ArrayList<>());
for (Attr_typed_idents_whereContext atiwC : ctx.proc_sign().proc_sign_in().attr_typed_idents_wheres().attr_typed_idents_where()) {
for (ParseTree ident : atiwC.typed_idents_where().typed_idents().idents().Ident()) {
String type = atiwC.typed_idents_where().typed_idents().type().getText();
int precision = type.contains("bv") ? Integer.parseInt(type.split("bv")[1]) : ARCH_PRECISION;
threadCallingValues.get(threadCount).add(programBuilder.getOrCreateRegister(threadCount, currentScope.getID() + ":" + ident.getText(), precision));
}
}
}
procedures.put(name, ctx);
}
Aggregations