Search in sources :

Example 6 with TStringLiteral

use of de.be4.classicalb.core.parser.node.TStringLiteral in project probparsers by bendisposto.

the class SyntaxExtensionTranslator method caseAMultilineStringExpression.

@Override
public void caseAMultilineStringExpression(AMultilineStringExpression node) {
    final TMultilineStringContent content = node.getContent();
    final String text = content.getText();
    TStringLiteral tStringLiteral = new TStringLiteral(text, content.getLine(), content.getPos());
    AStringExpression stringNode = new AStringExpression(tStringLiteral);
    stringNode.setStartPos(node.getStartPos());
    stringNode.setEndPos(node.getEndPos());
    node.replaceBy(stringNode);
}
Also used : TMultilineStringContent(de.be4.classicalb.core.parser.node.TMultilineStringContent) TStringLiteral(de.be4.classicalb.core.parser.node.TStringLiteral) AStringExpression(de.be4.classicalb.core.parser.node.AStringExpression)

Example 7 with TStringLiteral

use of de.be4.classicalb.core.parser.node.TStringLiteral 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);
}
Also used : APowSubsetExpression(de.be4.classicalb.core.parser.node.APowSubsetExpression) 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

AStringExpression (de.be4.classicalb.core.parser.node.AStringExpression)7 TStringLiteral (de.be4.classicalb.core.parser.node.TStringLiteral)7 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)4 AExpressionDefinitionDefinition (de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition)3 ATotalFunctionExpression (de.be4.classicalb.core.parser.node.ATotalFunctionExpression)3 AEqualPredicate (de.be4.classicalb.core.parser.node.AEqualPredicate)2 AIdentifierExpression (de.be4.classicalb.core.parser.node.AIdentifierExpression)2 AStringSetExpression (de.be4.classicalb.core.parser.node.AStringSetExpression)2 CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)1 AMultOrCartExpression (de.be4.classicalb.core.parser.node.AMultOrCartExpression)1 APowSubsetExpression (de.be4.classicalb.core.parser.node.APowSubsetExpression)1 APropertiesMachineClause (de.be4.classicalb.core.parser.node.APropertiesMachineClause)1 ASeqExpression (de.be4.classicalb.core.parser.node.ASeqExpression)1 PExpression (de.be4.classicalb.core.parser.node.PExpression)1 PPredicate (de.be4.classicalb.core.parser.node.PPredicate)1 TMultilineStringContent (de.be4.classicalb.core.parser.node.TMultilineStringContent)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1