use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class RulesMachineChecker method caseAIdentifierExpression.
@Override
public void caseAIdentifierExpression(AIdentifierExpression node) {
List<TIdentifierLiteral> copy = new ArrayList<>(node.getIdentifier());
if (copy.size() > 1) {
this.errorList.add(new CheckException("Identifier renaming is not allowed in a RULES_MACHINE.", node));
}
final String name = copy.get(0).getText();
if (currentOperation != null) {
currentOperation.addReadVariable(node);
}
if (!this.identifierScope.contains(name)) {
addReadIdentifier(node);
}
}
use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class ASTPrologTest method testFreeType.
@Test
public void testFreeType() throws BCompoundException {
final AConstructorFreetypeConstructor multi = new AConstructorFreetypeConstructor(new TIdentifierLiteral("multi"), new APowSubsetExpression(new AIntegerSetExpression()));
final AConstructorFreetypeConstructor single = new AConstructorFreetypeConstructor(new TIdentifierLiteral("single"), new AIntegerSetExpression());
final AFreetype freetype = new AFreetype(new TIdentifierLiteral("T"), Arrays.<PFreetypeConstructor>asList(multi, single));
AFreetypesMachineClause clause = new AFreetypesMachineClause(Arrays.<PFreetype>asList(freetype));
final StringWriter swriter = new StringWriter();
NodeIdAssignment nodeids = new NodeIdAssignment();
clause.apply(nodeids);
IPrologTermOutput pout = new PrologTermOutput(new PrintWriter(swriter), false);
PositionPrinter pprinter = new ClassicalPositionPrinter(nodeids);
ASTProlog prolog = new ASTProlog(pout, pprinter);
clause.apply(prolog);
String code = swriter.toString();
assertFalse(code.isEmpty());
assertEquals("freetypes(0,[freetype(1,'T',[constructor(2,multi,pow_subset(3,integer_set(4))),constructor(5,single,integer_set(6))])])", code);
}
use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class CreateFreetypeTest method createFreetype.
private AFreetypesMachineClause createFreetype() {
final AConstructorFreetypeConstructor cons1 = new AConstructorFreetypeConstructor(new TIdentifierLiteral(CONS_BOOL), new ABoolSetExpression());
final AConstructorFreetypeConstructor cons2 = new AConstructorFreetypeConstructor(new TIdentifierLiteral(CONS_INT), new AIntSetExpression());
final AElementFreetypeConstructor cons3 = new AElementFreetypeConstructor(new TIdentifierLiteral(CONS_EMPTY));
final AFreetype freetype = new AFreetype(new TIdentifierLiteral(FREETYPE_NAME), Arrays.<PFreetypeConstructor>asList(cons1, cons2, cons3));
return new AFreetypesMachineClause(Arrays.<PFreetype>asList(freetype));
}
use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class ASTBuilder method addFormatToStringDefinition.
public static void addFormatToStringDefinition(IDefinitions iDefinitions) {
if (iDefinitions.containsDefinition(FORMAT_TO_STRING)) {
return;
}
/*-
* FORMAT_TO_STRING(MyFormatString,ListOfValues) == "0";
* EXTERNAL_FUNCTION_FORMAT_TO_STRING(TO_STRING_TYPE) == STRING*seq(TO_STRING_TYPE) --> STRING;
*/
AExpressionDefinitionDefinition formatDef = new AExpressionDefinitionDefinition();
formatDef.setName(new TIdentifierLiteral(FORMAT_TO_STRING));
formatDef.setParameters(createExpressionList("S", "T"));
formatDef.setRhs(new AStringExpression(new TStringLiteral("abc")));
iDefinitions.addDefinition(formatDef, IDefinitions.Type.Expression);
AExpressionDefinitionDefinition formatType = new AExpressionDefinitionDefinition();
formatType.setName(new TIdentifierLiteral("EXTERNAL_FUNCTION_FORMAT_TO_STRING"));
formatType.setParameters(createExpressionList("T"));
formatType.setRhs(new ATotalFunctionExpression(new AMultOrCartExpression(new AStringSetExpression(), new ASeqExpression(createIdentifier("T"))), new AStringSetExpression()));
iDefinitions.addDefinition(formatType, IDefinitions.Type.Expression);
}
use of de.be4.eventbalg.core.parser.node.TIdentifierLiteral in project probparsers by bendisposto.
the class ASTBuilder method addToStringDefinition.
public static void addToStringDefinition(IDefinitions definitions) {
if (definitions.containsDefinition(TO_STRING)) {
return;
}
/*-
* TO_STRING(S) == "0";
* EXTERNAL_FUNCTION_TO_STRING(X) == X -->STRING;
*/
AExpressionDefinitionDefinition toStringDef = new AExpressionDefinitionDefinition();
toStringDef.setName(new TIdentifierLiteral(TO_STRING));
toStringDef.setParameters(createIdentifierList("S"));
toStringDef.setRhs(new AStringExpression(new TStringLiteral("0")));
definitions.addDefinition(toStringDef, IDefinitions.Type.Expression);
AExpressionDefinitionDefinition toStringTypeDef = new AExpressionDefinitionDefinition();
toStringTypeDef.setName(new TIdentifierLiteral("EXTERNAL_FUNCTION_TO_STRING"));
toStringTypeDef.setParameters(createIdentifierList("X"));
toStringTypeDef.setRhs(new ATotalFunctionExpression(createIdentifier("X"), new AStringSetExpression()));
definitions.addDefinition(toStringTypeDef, IDefinitions.Type.Expression);
}
Aggregations