use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.
the class SetOperationsTest method generalizedUnionTest.
@Test
public void generalizedUnionTest() throws ParserException {
String formula = "x = union({{4,5}, {1,2}})";
FormulaNode formulaNode = Parser.getFormulaAsSemanticAst(formula);
assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
DeclarationNode declarationNode = formulaNode.getImplicitDeclarations().get(0);
assertEquals("x", declarationNode.getName());
assertEquals(POW_INTEGER, declarationNode.getType().toString());
}
use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.
the class SetOperationsTest method emptySetTest.
@Test
public void emptySetTest() throws ParserException {
String formula = "x = {} & x <: NAT";
FormulaNode formulaNode = Parser.getFormulaAsSemanticAst(formula);
assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
DeclarationNode declarationNode = formulaNode.getImplicitDeclarations().get(0);
assertEquals("x", declarationNode.getName());
assertEquals(POW_INTEGER, declarationNode.getType().toString());
}
use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.
the class SetOperationsTest method properSubsetTest.
@Test
public void properSubsetTest() throws ParserException {
String formula = "x <<: 4 .. 10";
FormulaNode formulaNode = Parser.getFormulaAsSemanticAst(formula);
assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
DeclarationNode declarationNode = formulaNode.getImplicitDeclarations().get(0);
assertEquals("x", declarationNode.getName());
assertEquals(POW_INTEGER, declarationNode.getType().toString());
}
use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.
the class Parser method getFormulaAsSemanticAst.
public static FormulaNode getFormulaAsSemanticAst(String inputString) throws ParserException {
Parser parser = new Parser();
try {
FormulaContext formulaContext;
formulaContext = parser.parseFormula(inputString);
List<String> warnings = CSTAnalyser.analyseConcreteSyntaxTree(formulaContext);
FormulaNode formulaNode = parser.getFormulaAst(formulaContext);
formulaNode.setWarnings(warnings);
TypeChecker.typecheckFormulaNode(formulaNode);
return formulaNode;
} catch (ParseErrorException | TypeErrorException | ScopeException e) {
throw new ParserException(e);
}
}
use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.
the class FunctionsTest method lambdaTest.
@Test
@Ignore
public void lambdaTest() throws ParserException {
String formula = "x = %z.(z : 1..10|z*z)";
FormulaNode formulaNode = Parser.getFormulaAsSemanticAst(formula);
assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
DeclarationNode declarationNode = formulaNode.getImplicitDeclarations().get(0);
assertEquals("x", declarationNode.getName());
assertEquals(POW_INTEGER_INTEGER, declarationNode.getType().toString());
}
Aggregations