use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project prob2 by bendisposto.
the class EventBMachineTranslator method translateMachine.
public Node translateMachine() {
AEventBModelParseUnit ast = new AEventBModelParseUnit();
ast.setName(new TIdentifierLiteral(machine.getName()));
List<PModelClause> clauses = new ArrayList<>();
clauses.add(processContexts());
ARefinesModelClause refines = processRefines();
if (refines != null) {
clauses.add(refines);
}
clauses.add(processVariables());
clauses.addAll(processInvariantsAndTheorems());
AVariantModelClause variant = processVariant();
if (variant != null) {
clauses.add(variant);
}
clauses.add(processEvents());
ast.setModelClauses(clauses);
return ast;
}
use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project prob2 by bendisposto.
the class ContextTranslator method processSets.
private ASetsContextClause processSets() {
List<PSet> sets = new ArrayList<>();
for (Set bSet : context.getSets()) {
List<TIdentifierLiteral> names = new ArrayList<>();
names.add(new TIdentifierLiteral(bSet.getName()));
sets.add(new ADeferredSetSet(names));
}
return new ASetsContextClause(sets);
}
use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project prob2 by bendisposto.
the class ComponentExtractor method caseAMachineParseUnit.
@Override
public void caseAMachineParseUnit(final AMachineParseUnit node) {
String name = node.getName().getText();
MachineModifier machineM = new MachineModifier(new EventBMachine(name), typeEnv);
ModelElementList<Context> seen = new ModelElementList<>();
for (TIdentifierLiteral contextName : node.getSeenNames()) {
String cName = contextName.getText();
AbstractElement context = getContext(cName);
seen = seen.addElement((Context) context);
}
machineM = machineM.setSees(seen);
if (node.getRefinesNames().size() == 1) {
String mname = node.getRefinesNames().getFirst().getText();
EventBMachine machine = getMachine(mname);
machineM = machineM.setRefines(machine);
} else if (node.getRefinesNames().size() > 1) {
throw new IllegalArgumentException("Machines can only refine one abstract machine. Found " + node.getRefinesNames().size() + " refined machines");
}
machineM = machineM.addComment(getComment(node.getComments()));
MachineExtractor mE = new MachineExtractor(machineM, typeEnv);
node.apply(mE);
modelM = modelM.addMachine(mE.getMachine());
}
use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project prob2 by bendisposto.
the class ComponentExtractor method caseAProcedureParseUnit.
@Override
public void caseAProcedureParseUnit(final AProcedureParseUnit node) {
String name = node.getName().getText();
LinkedList<TIdentifierLiteral> seen = node.getSeen();
Context ctx = null;
if (node.getSeen().size() == 1) {
String cName = seen.getFirst().getText();
ctx = getContext(cName);
} else if (node.getSeen().size() > 1) {
throw new IllegalArgumentException("Error in " + name + " definition: " + node.getStartPos() + " only one context may be seen by a procedure");
}
Procedure procedure = new Procedure(name, ctx, typeEnv);
ProcedureExtractor pE = new ProcedureExtractor(procedure, node, typeEnv);
modelM = modelM.addProcedure(pE.getProcedure());
}
use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class ASTBuilder method addForceDefinition.
public static void addForceDefinition(IDefinitions iDefinitions) {
if (iDefinitions.containsDefinition(FORCE)) {
return;
}
/*-
* EXTERNAL_FUNCTION_FORCE(T) == T --> T;
* FORCE(value) == value;
* forces evaluation of symbolic set representations
* usage: FORCE({ x | x:1..100 & x mod 2 = 0 } )
*/
AExpressionDefinitionDefinition forceDef = new AExpressionDefinitionDefinition();
forceDef.setName(new TIdentifierLiteral(FORCE));
String value = "value";
forceDef.setParameters(createIdentifierList(value));
forceDef.setRhs(createIdentifier(value));
iDefinitions.addDefinition(forceDef, IDefinitions.Type.Expression);
AExpressionDefinitionDefinition forceDefType = new AExpressionDefinitionDefinition();
forceDefType.setName(new TIdentifierLiteral("EXTERNAL_FUNCTION_" + FORCE));
forceDefType.setParameters(createIdentifierList("T"));
forceDefType.setRhs(new ATotalFunctionExpression(createIdentifier("T"), createIdentifier("T")));
iDefinitions.addDefinition(forceDefType, IDefinitions.Type.Expression);
}
Aggregations