Search in sources :

Example 1 with LTLPrefixOperatorNode

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

the class LTLFormulaTest method testGloballyFinally.

@Test
public void testGloballyFinally() throws ParserException {
    String formula = "FG { 1=1 }";
    LTLFormula ltlFormula = Parser.getLTLFormulaAsSemanticAst(formula);
    Node f1 = ltlFormula.getLTLNode();
    assertTrue(f1 instanceof LTLPrefixOperatorNode);
    LTLPrefixOperatorNode p1 = (LTLPrefixOperatorNode) f1;
    assertEquals(LTLPrefixOperatorNode.Kind.FINALLY, p1.getKind());
    LTLNode f2 = p1.getArgument();
    assertTrue(f2 instanceof LTLPrefixOperatorNode);
    LTLPrefixOperatorNode p2 = (LTLPrefixOperatorNode) f2;
    assertEquals(LTLPrefixOperatorNode.Kind.GLOBALLY, p2.getKind());
    LTLNode f3 = p2.getArgument();
    assertTrue(f3 instanceof LTLBPredicateNode);
    LTLBPredicateNode p3 = (LTLBPredicateNode) f3;
    assertTrue(p3.getPredicate() != null);
}
Also used : LTLFormula(de.bmoth.parser.ast.nodes.ltl.LTLFormula) LTLPrefixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode) LTLNode(de.bmoth.parser.ast.nodes.ltl.LTLNode) LTLBPredicateNode(de.bmoth.parser.ast.nodes.ltl.LTLBPredicateNode) LTLPrefixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode) LTLNode(de.bmoth.parser.ast.nodes.ltl.LTLNode) Node(de.bmoth.parser.ast.nodes.Node) LTLBPredicateNode(de.bmoth.parser.ast.nodes.ltl.LTLBPredicateNode) Test(org.junit.Test)

Example 2 with LTLPrefixOperatorNode

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

the class ConvertNotOrToAndNot method transformNode.

@Override
public Node transformNode(Node node) {
    LTLPrefixOperatorNode outerNot = (LTLPrefixOperatorNode) node;
    LTLInfixOperatorNode innerOr = (LTLInfixOperatorNode) outerNot.getArgument();
    return new LTLInfixOperatorNode(AND, new LTLPrefixOperatorNode(NOT, innerOr.getLeft()), new LTLPrefixOperatorNode(NOT, innerOr.getRight()));
}
Also used : LTLPrefixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode) LTLInfixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLInfixOperatorNode)

Example 3 with LTLPrefixOperatorNode

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

the class ConvertNotUntil method transformNode.

@Override
public Node transformNode(Node oldNode) {
    LTLPrefixOperatorNode notOperator = (LTLPrefixOperatorNode) oldNode;
    LTLNode argument = notOperator.getArgument();
    LTLInfixOperatorNode untilOperator = (LTLInfixOperatorNode) argument;
    LTLNode left = untilOperator.getLeft();
    LTLNode right = untilOperator.getRight();
    LTLPrefixOperatorNode notRight = new LTLPrefixOperatorNode(NOT, right);
    LTLPrefixOperatorNode notLeft = new LTLPrefixOperatorNode(NOT, left);
    return new LTLInfixOperatorNode(LTLInfixOperatorNode.Kind.RELEASE, notLeft, notRight);
}
Also used : LTLPrefixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode) LTLNode(de.bmoth.parser.ast.nodes.ltl.LTLNode) LTLInfixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLInfixOperatorNode)

Example 4 with LTLPrefixOperatorNode

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

the class ConvertFinallyPhiOrPsiToFinallyPhiOrFinallyPsi method transformNode.

@Override
public Node transformNode(Node oldNode) {
    LTLPrefixOperatorNode finallyOperator = (LTLPrefixOperatorNode) oldNode;
    LTLNode argument = finallyOperator.getArgument();
    LTLInfixOperatorNode orOperator = (LTLInfixOperatorNode) argument;
    LTLPrefixOperatorNode newNextLeft = new LTLPrefixOperatorNode(FINALLY, orOperator.getLeft());
    LTLPrefixOperatorNode newNextRight = new LTLPrefixOperatorNode(FINALLY, orOperator.getRight());
    return new LTLInfixOperatorNode(OR, newNextLeft, newNextRight);
}
Also used : LTLPrefixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode) LTLNode(de.bmoth.parser.ast.nodes.ltl.LTLNode) LTLInfixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLInfixOperatorNode)

Example 5 with LTLPrefixOperatorNode

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

the class ConvertNotGloballyToFinallyNot method transformNode.

@Override
public Node transformNode(Node node) {
    LTLPrefixOperatorNode not = (LTLPrefixOperatorNode) node;
    LTLPrefixOperatorNode globally = (LTLPrefixOperatorNode) not.getArgument();
    LTLNode inner = globally.getArgument();
    return new LTLPrefixOperatorNode(FINALLY, new LTLPrefixOperatorNode(NOT, inner));
}
Also used : LTLPrefixOperatorNode(de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode) LTLNode(de.bmoth.parser.ast.nodes.ltl.LTLNode)

Aggregations

LTLPrefixOperatorNode (de.bmoth.parser.ast.nodes.ltl.LTLPrefixOperatorNode)14 LTLNode (de.bmoth.parser.ast.nodes.ltl.LTLNode)11 LTLInfixOperatorNode (de.bmoth.parser.ast.nodes.ltl.LTLInfixOperatorNode)9 LTLBPredicateNode (de.bmoth.parser.ast.nodes.ltl.LTLBPredicateNode)4 LTLKeywordNode (de.bmoth.parser.ast.nodes.ltl.LTLKeywordNode)4 Interval (org.antlr.v4.runtime.misc.Interval)2 ParseTree (org.antlr.v4.runtime.tree.ParseTree)2 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)2 Before (org.junit.Before)2 BMoThParser (de.bmoth.antlr.BMoThParser)1 Node (de.bmoth.parser.ast.nodes.Node)1 PredicateNode (de.bmoth.parser.ast.nodes.PredicateNode)1 LTLFormula (de.bmoth.parser.ast.nodes.ltl.LTLFormula)1 Parser (org.antlr.v4.runtime.Parser)1 RuleContext (org.antlr.v4.runtime.RuleContext)1 Token (org.antlr.v4.runtime.Token)1 Test (org.junit.Test)1