use of verdict.vdm.vdm_lustre.Expression in project VERDICT by ge-high-assurance.
the class VerdictLustreListener method exitIntExpr.
/**
* Extract an int literal.
*/
@Override
public void exitIntExpr(LustreParser.IntExprContext ctx) {
ctx.expression = new Expression();
ctx.expression.setIntLiteral(new BigInteger(ctx.INT().getText()));
}
use of verdict.vdm.vdm_lustre.Expression in project VERDICT by ge-high-assurance.
the class VerdictLustreListener method exitBoolExpr.
/**
* Extract a bool literal.
*/
@Override
public void exitBoolExpr(LustreParser.BoolExprContext ctx) {
ctx.expression = new Expression();
ctx.expression.setBoolLiteral(Boolean.valueOf(ctx.BOOL().getText()));
}
use of verdict.vdm.vdm_lustre.Expression in project VERDICT by ge-high-assurance.
the class VerdictLustreListener method exitNaryExpr.
/**
* Extract a nary expression.
*/
@Override
public void exitNaryExpr(LustreParser.NaryExprContext ctx) {
ExpressionList expressionList = new ExpressionList();
ctx.expr().forEach(e -> expressionList.getExpression().add(e.expression));
ctx.expression = new Expression();
switch(ctx.op.getText()) {
case "#":
ctx.expression.setDiese(expressionList);
break;
case "nor":
ctx.expression.setNor(expressionList);
break;
}
}
use of verdict.vdm.vdm_lustre.Expression in project VERDICT by ge-high-assurance.
the class VerdictLustreListener method exitRecordExpr.
/**
* Extract a record literal.
*/
@Override
public void exitRecordExpr(LustreParser.RecordExprContext ctx) {
RecordLiteral recordLiteral = new RecordLiteral();
recordLiteral.setRecordType(ctx.ID().getText());
ctx.fieldExpr().forEach(f -> recordLiteral.getFieldDefinition().add(f.fieldDefinition));
ctx.expression = new Expression();
ctx.expression.setRecordLiteral(recordLiteral);
}
use of verdict.vdm.vdm_lustre.Expression in project VERDICT by ge-high-assurance.
the class VDM2Lustre method visit.
public void visit(ComponentType componentType, NodeBody nodeBody, String componentInstanceID, boolean impl_type) {
// Rename componentType
String cmpName = componentType.getName();
cmpName = cmpName.replace(".", "_dot_");
cmpName = cmpName.replace("::", "_double_colon_");
componentType.setName(cmpName);
// Node Equation
NodeEquation node_eq = new NodeEquation();
// Return variables
NodeEquationLHS eq_lhs = new NodeEquationLHS();
// Node Call
Expression node = new Expression();
NodeCall nodeCall = new NodeCall();
if (impl_type) {
nodeCall.setNodeId(componentType.getName() + "_dot_Impl");
} else {
nodeCall.setNodeId(componentType.getName());
}
// Port
for (Port port : componentType.getPort()) {
// //Event Port Definition
// for (Port port : componentType.getPort()) {
// visit(port);
// }
// MODE
PortMode port_mode = port.getMode();
if (port_mode == PortMode.IN) {
Expression arg = new Expression();
arg.setIdentifier(port.getName());
nodeCall.getArgument().add(arg);
}
if (port_mode == PortMode.OUT) {
VariableDeclaration var = new VariableDeclaration();
// Node Name
String output_name = port.getName();
String var_name = componentInstanceID + "_port_" + output_name;
var.setName(var_name);
// Node DataType
DataType dataType = port.getType();
var.setDataType(dataType);
nodeBody.getVariableDeclaration().add(var);
eq_lhs.getIdentifier().add(var_name);
}
}
// Ignore node call that do not have output
if (eq_lhs.getIdentifier() != null) {
node.setCall(nodeCall);
node_eq.setRhs(node);
node_eq.setLhs(eq_lhs);
nodeBody.getEquation().add(node_eq);
}
}
Aggregations