use of verdict.vdm.vdm_lustre.ConstantDeclaration in project VERDICT by ge-high-assurance.
the class VerdictLustreListener method exitRecordProjectionExpr.
/**
* Extract a record projection expression.
*/
@Override
public void exitRecordProjectionExpr(LustreParser.RecordProjectionExprContext ctx) {
RecordProjection recordProjection = new RecordProjection();
if (ctx.ID() != null) {
recordProjection.setFieldId(ctx.ID().getText());
}
if (ctx.expr() != null) {
recordProjection.setRecordReference(ctx.expr().expression);
String identifier = ctx.expr().expression.getIdentifier();
if (identifier != null) {
ConstantDeclaration constantDeclaration = constantDeclarations.get(identifier);
if (constantDeclaration != null) {
Expression definition = constantDeclaration.getDefinition();
if (definition != null) {
RecordLiteral recordLiteral = definition.getRecordLiteral();
if (recordLiteral != null) {
recordProjection.setRecordType(recordLiteral.getRecordType());
}
}
}
}
}
ctx.expression = new Expression();
ctx.expression.setRecordProjection(recordProjection);
}
use of verdict.vdm.vdm_lustre.ConstantDeclaration in project VERDICT by ge-high-assurance.
the class VerdictLustreListener method exitOneConstDecl.
/**
* Extract a constant declaration.
*/
@Override
public void exitOneConstDecl(LustreParser.OneConstDeclContext ctx) {
LustreProgram program = model.getDataflowCode();
ctx.ID().forEach(id -> {
ConstantDeclaration constantDeclaration = new ConstantDeclaration();
if (ctx.type() != null) {
constantDeclaration.setDataType(ctx.type().dataType);
}
if (ctx.expr() != null) {
constantDeclaration.setDefinition(ctx.expr().expression);
}
String name = id.getText();
constantDeclaration.setName(name);
constantDeclarations.put(name, constantDeclaration);
program.getConstantDeclaration().add(constantDeclaration);
});
}
use of verdict.vdm.vdm_lustre.ConstantDeclaration in project VERDICT by ge-high-assurance.
the class PrettyPrinter method visit.
public void visit(NodeBody nodeBody) {
sb.append("let");
sb.append(NL);
if (nodeBody.getVariableDeclaration().size() > 0) {
sb.append("var");
sb.append(NL);
}
for (VariableDeclaration var : nodeBody.getVariableDeclaration()) {
visit(var);
sb.append(NL);
sb.append(";");
}
for (ConstantDeclaration constant : nodeBody.getConstantDeclaration()) {
sb.append("const");
visit(constant);
sb.append(NL);
sb.append(";");
}
for (Expression expr : nodeBody.getAssertion()) {
visit(expr);
}
for (NodeEquation neq : nodeBody.getEquation()) {
visit(neq);
}
for (NodeProperty property : nodeBody.getProperty()) {
visit(property);
}
sb.append("tel");
}
use of verdict.vdm.vdm_lustre.ConstantDeclaration in project VERDICT by ge-high-assurance.
the class Agree2Vdm method translateConstStatementImpl.
private ConstantDeclaration translateConstStatementImpl(ConstStatementImpl constStmtImpl, HashSet<String> dataTypeDecl, HashSet<String> nodeDecl, Model model) {
ConstantDeclaration vdmConstDeclaration = new ConstantDeclaration();
vdmConstDeclaration.setName(constStmtImpl.getName());
vdmConstDeclaration.setDefinition(getVdmExpressionFromAgreeExpression(constStmtImpl.getExpr(), dataTypeDecl, nodeDecl, model));
vdmConstDeclaration.setDataType(getVdmTypeFromAgreeType(constStmtImpl.getType(), dataTypeDecl, model));
return vdmConstDeclaration;
}
Aggregations