use of de.be4.classicalb.core.parser.node.AStringExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkTagsAttribute.
private void checkTagsAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
final List<String> tags = new ArrayList<>();
for (PExpression pExpression : arguments) {
if (pExpression instanceof AIdentifierExpression) {
final AIdentifierExpression ident = (AIdentifierExpression) pExpression;
final String identifierAsString = Utils.getTIdentifierListAsString(ident.getIdentifier());
tags.add(identifierAsString);
} else if (pExpression instanceof AStringExpression) {
final AStringExpression stringExpr = (AStringExpression) pExpression;
tags.add(stringExpr.getContent().getText());
} else {
errorList.add(new CheckException("Expected identifier or string after the TAGS attribute.", pOperationAttribute));
}
}
currentOperation.addTags(tags);
return;
}
use of de.be4.classicalb.core.parser.node.AStringExpression 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);
}
use of de.be4.classicalb.core.parser.node.AStringExpression 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.classicalb.core.parser.node.AStringExpression in project probparsers by bendisposto.
the class RulesMachineChecker method countPlaceHoldersInExpression.
private Integer countPlaceHoldersInExpression(PExpression param) {
if (param instanceof AConcatExpression) {
AConcatExpression con = (AConcatExpression) param;
Integer left = countPlaceHoldersInExpression(con.getLeft());
Integer right = countPlaceHoldersInExpression(con.getRight());
if (left == null || right == null) {
return null;
} else {
return left + right;
}
} else if (param instanceof AStringExpression) {
AStringExpression string = (AStringExpression) param;
String content = string.getContent().getText();
String subString = "~w";
return countOccurrences(content, subString);
} else {
return null;
}
}
use of de.be4.classicalb.core.parser.node.AStringExpression in project probparsers by bendisposto.
the class LTLFormulaVisitor method parseDefinition.
public void parseDefinition(AExpressionDefinitionDefinition def) {
if (!(def.getRhs() instanceof AStringExpression)) {
throw new LTLParseException("Error: LTL formula is not in a string representation.");
}
AStringExpression stringNode = (AStringExpression) def.getRhs();
this.ltlFormula = stringNode.getContent().getText();
try {
this.ltlFormulaStart = parseLTLFormula(ltlFormula);
} catch (Exception e) {
String message = "Parsing definition " + name + " (line " + def.getStartPos().getLine() + "):\n";
throw new LTLParseException(message + e.getMessage());
}
}
Aggregations