use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorLitmusAArch64 method visitBranch.
@Override
public Object visitBranch(LitmusAArch64Parser.BranchContext ctx) {
Label label = programBuilder.getOrCreateLabel(ctx.label().getText());
if (ctx.branchCondition() == null) {
return programBuilder.addChild(mainThread, EventFactory.newGoto(label));
}
Event lastEvent = programBuilder.getLastEvent(mainThread);
if (!(lastEvent instanceof Cmp)) {
throw new ParsingException("Invalid syntax near " + ctx.getText());
}
Cmp cmp = (Cmp) lastEvent;
Atom expr = new Atom(cmp.getLeft(), ctx.branchCondition().op, cmp.getRight());
return programBuilder.addChild(mainThread, EventFactory.newJump(expr, label));
}
use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorLitmusAssertions method visitAssertionList.
@Override
public AbstractAssert visitAssertionList(LitmusAssertionsParser.AssertionListContext ctx) {
AbstractAssert ass = ctx.assertion().accept(this);
if (ctx.AssertionNot() != null) {
ass.setType(AbstractAssert.ASSERT_TYPE_NOT_EXISTS);
} else if (ctx.AssertionExists() != null) {
ass.setType(AbstractAssert.ASSERT_TYPE_EXISTS);
} else if (ctx.AssertionForall() != null) {
ass = new AssertNot(ass);
ass.setType(AbstractAssert.ASSERT_TYPE_FORALL);
} else if (ctx.AssertionFinal() != null) {
ass.setType(AbstractAssert.ASSERT_TYPE_FINAL);
} else {
throw new ParsingException("Unrecognised assertion type");
}
return ass;
}
use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorLitmusC method visitGlobalDeclaratorArray.
@Override
public Object visitGlobalDeclaratorArray(LitmusCParser.GlobalDeclaratorArrayContext ctx) {
String name = ctx.varName().getText();
Integer size = ctx.DigitSequence() != null ? Integer.parseInt(ctx.DigitSequence().getText()) : null;
if (ctx.initArray() == null && size != null && size > 0) {
programBuilder.newObject(name, size);
return null;
}
if (ctx.initArray() != null) {
if (size == null || ctx.initArray().arrayElement().size() == size) {
List<IConst> values = new ArrayList<>();
for (LitmusCParser.ArrayElementContext elCtx : ctx.initArray().arrayElement()) {
if (elCtx.constant() != null) {
values.add(new IValue(new BigInteger(elCtx.constant().getText()), ARCH_PRECISION));
} else {
String varName = elCtx.varName().getText();
// see test/resources/arrays/ok/C-array-ok-17.litmus
MemoryObject object = programBuilder.getObject(varName);
if (object != null) {
values.add(object);
} else {
object = programBuilder.getOrNewObject(varName);
values.add(elCtx.Ast() == null ? object : object.getInitialValue(0));
}
}
}
MemoryObject object = programBuilder.newObject(name, values.size());
for (int i = 0; i < values.size(); i++) {
object.setInitialValue(i, values.get(i));
}
return null;
}
}
throw new ParsingException("Invalid syntax near " + ctx.getText());
}
use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorLitmusC method visitNreAssignment.
@Override
public Object visitNreAssignment(LitmusCParser.NreAssignmentContext ctx) {
ExprInterface variable = (ExprInterface) ctx.varName().accept(this);
if (ctx.Ast() == null) {
if (variable instanceof Register) {
returnRegister = (Register) variable;
ctx.re().accept(this);
return null;
}
throw new ParsingException("Invalid syntax near " + ctx.getText());
}
ExprInterface value = (ExprInterface) ctx.re().accept(this);
if (variable instanceof MemoryObject || variable instanceof Register) {
Event event = EventFactory.newStore((IExpr) variable, value, "NA");
return programBuilder.addChild(currentThread, event);
}
throw new ParsingException("Invalid syntax near " + ctx.getText());
}
use of com.dat3m.dartagnan.exception.ParsingException in project Dat3M by hernanponcedeleon.
the class VisitorLitmusC method visitNreRegDeclaration.
@Override
public Object visitNreRegDeclaration(LitmusCParser.NreRegDeclarationContext ctx) {
Register register = programBuilder.getRegister(scope, ctx.varName().getText());
if (register == null) {
register = programBuilder.getOrCreateRegister(scope, ctx.varName().getText(), ARCH_PRECISION);
if (ctx.re() != null) {
returnRegister = register;
ctx.re().accept(this);
}
return null;
}
throw new ParsingException("Register " + ctx.varName().getText() + " is already initialised");
}
Aggregations