use of de.be4.eventb.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class ASTBuilder method addChooseDefinition.
public static void addChooseDefinition(IDefinitions iDefinitions) {
if (iDefinitions.containsDefinition(CHOOSE)) {
return;
}
/*-
* TO_STRING(S) == "0";
* EXTERNAL_FUNCTION_TO_STRING(X) == (X --> STRING);
*/
AExpressionDefinitionDefinition chooseDef = new AExpressionDefinitionDefinition();
chooseDef.setName(new TIdentifierLiteral(CHOOSE));
chooseDef.setParameters(createIdentifierList("X"));
chooseDef.setRhs(new AStringExpression(new TStringLiteral("a member of X")));
iDefinitions.addDefinition(chooseDef, IDefinitions.Type.Expression);
AExpressionDefinitionDefinition chooseDefType = new AExpressionDefinitionDefinition();
chooseDefType.setName(new TIdentifierLiteral("EXTERNAL_FUNCTION_CHOOSE"));
chooseDefType.setParameters(createIdentifierList("T"));
chooseDefType.setRhs(new ATotalFunctionExpression(new APowSubsetExpression(createIdentifier("T")), createIdentifier("T")));
iDefinitions.addDefinition(chooseDefType, IDefinitions.Type.Expression);
}
use of de.be4.eventb.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class ASTBuilder method addPrintSubDefinitionToIdefinitions.
public static void addPrintSubDefinitionToIdefinitions(IDefinitions definitions) {
if (definitions.containsDefinition(PRINT)) {
return;
}
/*-
* PRINT(x) == skip;
* EXTERNAL_SUBSTITUTION_PRINT(T) == T; /* declare as external for any type T
*/
ASubstitutionDefinitionDefinition printDef = new ASubstitutionDefinitionDefinition();
printDef.setName(new TDefLiteralSubstitution(PRINT));
printDef.setParameters(createIdentifierList("value"));
printDef.setRhs(new ASkipSubstitution());
definitions.addDefinition(printDef, IDefinitions.Type.Substitution);
AExpressionDefinitionDefinition forceDefType = new AExpressionDefinitionDefinition();
forceDefType.setName(new TIdentifierLiteral("EXTERNAL_SUBSTITUTION_" + PRINT));
forceDefType.setParameters(createIdentifierList("T"));
forceDefType.setRhs(createIdentifier("T"));
definitions.addDefinition(forceDefType, IDefinitions.Type.Expression);
}
use of de.be4.eventb.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class ASTBuilder method createAIdentifierExpression.
public static AIdentifierExpression createAIdentifierExpression(TIdentifierLiteral identifierLiteral) {
final String name = identifierLiteral.getText();
ArrayList<TIdentifierLiteral> list = new ArrayList<>();
TIdentifierLiteral literal = new TIdentifierLiteral(name);
list.add(literal);
AIdentifierExpression result = new AIdentifierExpression(list);
result.setStartPos(identifierLiteral.getStartPos());
result.setEndPos(identifierLiteral.getEndPos());
return result;
}
use of de.be4.eventb.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class ASTBuilder method addBooleanPreferenceDefinition.
public static void addBooleanPreferenceDefinition(IDefinitions iDefinitions, String name, boolean bool) {
AExpressionDefinitionDefinition def = new AExpressionDefinitionDefinition(new TIdentifierLiteral(name), new ArrayList<PExpression>(), bool ? new ABooleanTrueExpression() : new ABooleanFalseExpression());
iDefinitions.addDefinition(def, IDefinitions.Type.Expression);
}
use of de.be4.eventb.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class BMachine method addPromotesClause.
public void addPromotesClause(List<String> operationList) {
APromotesMachineClause promotes = new APromotesMachineClause();
List<PExpression> opList = new ArrayList<>();
for (String name : operationList) {
List<TIdentifierLiteral> idList = new ArrayList<>();
idList.add(new TIdentifierLiteral(name));
AIdentifierExpression idExpr = new AIdentifierExpression(idList);
opList.add(idExpr);
}
promotes.setOperationNames(opList);
this.parseUnit.getMachineClauses().add(promotes);
}
Aggregations