Search in sources :

Example 11 with LTLFormula

use of de.bmoth.parser.ast.nodes.ltl.LTLFormula in project bmoth by hhu-stups.

the class Parser method getLTLFormulaAst.

private LTLFormula getLTLFormulaAst(LtlStartContext context) throws ScopeException {
    LTLFormulaAnalyser formulaAnalyser = new LTLFormulaAnalyser(context);
    SemanticAstCreator astCreator = new SemanticAstCreator(formulaAnalyser);
    return (LTLFormula) astCreator.getAstNode();
}
Also used : LTLFormula(de.bmoth.parser.ast.nodes.ltl.LTLFormula) SemanticAstCreator(de.bmoth.parser.ast.SemanticAstCreator)

Example 12 with LTLFormula

use of de.bmoth.parser.ast.nodes.ltl.LTLFormula in project bmoth by hhu-stups.

the class Parser method getLTLFormulaAsSemanticAst.

public static LTLFormula getLTLFormulaAsSemanticAst(String inputString) throws ParserException {
    Parser parser = new Parser();
    try {
        LtlStartContext context;
        context = parser.parseLTLFormula(inputString);
        LTLFormula ltlFormulaAst = parser.getLTLFormulaAst(context);
        TypeChecker.typecheckLTLFormulaNode(ltlFormulaAst);
        return ltlFormulaAst;
    } catch (ParseErrorException | ScopeException | TypeErrorException e) {
        throw new ParserException(e);
    }
}
Also used : LTLFormula(de.bmoth.parser.ast.nodes.ltl.LTLFormula) TypeErrorException(de.bmoth.parser.ast.TypeErrorException) LtlStartContext(de.bmoth.antlr.BMoThParser.LtlStartContext) BMoThParser(de.bmoth.antlr.BMoThParser)

Example 13 with LTLFormula

use of de.bmoth.parser.ast.nodes.ltl.LTLFormula in project bmoth by hhu-stups.

the class LTLMachineTest method testSimpleLTLTestMachine.

@Test
public void testSimpleLTLTestMachine() {
    MachineNode machine = new MachineBuilder().setName("SimpleLTLTestMachine").setDefinitions("ASSERT_LTL_1 == \"F({x=7})\"").setVariables("x").setInvariant("x : 1..10").setInitialization("x := 1").addOperation("foo = SELECT x < 5 THEN x := x + 1 END").build();
    assertNotNull(machine);
    List<LTLFormula> ltlFormulas = machine.getLTLFormulas();
    LTLFormula ltl1 = ltlFormulas.get(0);
    assertEquals("ASSERT_LTL_1", ltl1.getName());
}
Also used : LTLFormula(de.bmoth.parser.ast.nodes.ltl.LTLFormula) MachineNode(de.bmoth.parser.ast.nodes.MachineNode) Test(org.junit.Test)

Example 14 with LTLFormula

use of de.bmoth.parser.ast.nodes.ltl.LTLFormula in project bmoth by hhu-stups.

the class LTLBuechiTest method testGraphConstructionGloballyFalsity.

@Test
public void testGraphConstructionGloballyFalsity() throws ParserException {
    String formula = "G ({0=1})";
    LTLFormula ltlFormula = Parser.getLTLFormulaAsSemanticAst(formula);
    LTLNode node = LTLTransformations.transformLTLNode(ltlFormula.getLTLNode());
    BuechiAutomaton buechiAutomaton = new BuechiAutomaton(node);
    assertEquals(1, buechiAutomaton.getFinalNodeSet().size());
    logger.log(Level.INFO, buechiAutomaton::toString);
}
Also used : LTLFormula(de.bmoth.parser.ast.nodes.ltl.LTLFormula) BuechiAutomaton(de.bmoth.parser.ast.nodes.ltl.BuechiAutomaton) LTLNode(de.bmoth.parser.ast.nodes.ltl.LTLNode) Test(org.junit.Test)

Example 15 with LTLFormula

use of de.bmoth.parser.ast.nodes.ltl.LTLFormula in project bmoth by hhu-stups.

the class LTLBuechiTest method testGraphConstructionFp1UGp2.

@Test
public void testGraphConstructionFp1UGp2() throws ParserException {
    String formula = "(F {3=4}) U (G {2=3})";
    LTLFormula ltlFormula = Parser.getLTLFormulaAsSemanticAst(formula);
    LTLNode node = LTLTransformations.transformLTLNode(ltlFormula.getLTLNode());
    BuechiAutomaton buechiAutomaton = new BuechiAutomaton(node);
    assertEquals(8, buechiAutomaton.getFinalNodeSet().size());
    logger.log(Level.INFO, buechiAutomaton::toString);
}
Also used : LTLFormula(de.bmoth.parser.ast.nodes.ltl.LTLFormula) BuechiAutomaton(de.bmoth.parser.ast.nodes.ltl.BuechiAutomaton) LTLNode(de.bmoth.parser.ast.nodes.ltl.LTLNode) Test(org.junit.Test)

Aggregations

LTLFormula (de.bmoth.parser.ast.nodes.ltl.LTLFormula)23 Test (org.junit.Test)21 LTLNode (de.bmoth.parser.ast.nodes.ltl.LTLNode)20 BuechiAutomaton (de.bmoth.parser.ast.nodes.ltl.BuechiAutomaton)19 BMoThParser (de.bmoth.antlr.BMoThParser)1 LtlStartContext (de.bmoth.antlr.BMoThParser.LtlStartContext)1 SemanticAstCreator (de.bmoth.parser.ast.SemanticAstCreator)1 TypeErrorException (de.bmoth.parser.ast.TypeErrorException)1 MachineNode (de.bmoth.parser.ast.nodes.MachineNode)1 Node (de.bmoth.parser.ast.nodes.Node)1 LTLBPredicateNode (de.bmoth.parser.ast.nodes.ltl.LTLBPredicateNode)1 LTLPrefixOperatorNode (de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode)1 Ignore (org.junit.Ignore)1