Search in sources :

Example 1 with AMultOrCartExpression

use of de.be4.classicalb.core.parser.node.AMultOrCartExpression 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);
}
Also used : AStringSetExpression(de.be4.classicalb.core.parser.node.AStringSetExpression) AMultOrCartExpression(de.be4.classicalb.core.parser.node.AMultOrCartExpression) ASeqExpression(de.be4.classicalb.core.parser.node.ASeqExpression) AExpressionDefinitionDefinition(de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition) AStringExpression(de.be4.classicalb.core.parser.node.AStringExpression) TStringLiteral(de.be4.classicalb.core.parser.node.TStringLiteral) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral) ATotalFunctionExpression(de.be4.classicalb.core.parser.node.ATotalFunctionExpression)

Aggregations

AExpressionDefinitionDefinition (de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition)1 AMultOrCartExpression (de.be4.classicalb.core.parser.node.AMultOrCartExpression)1 ASeqExpression (de.be4.classicalb.core.parser.node.ASeqExpression)1 AStringExpression (de.be4.classicalb.core.parser.node.AStringExpression)1 AStringSetExpression (de.be4.classicalb.core.parser.node.AStringSetExpression)1 ATotalFunctionExpression (de.be4.classicalb.core.parser.node.ATotalFunctionExpression)1 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)1 TStringLiteral (de.be4.classicalb.core.parser.node.TStringLiteral)1