Search in sources :

Example 1 with ASequenceSubstitution

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

the class ASTBuilder method createSequenceSubstitution.

public static PSubstitution createSequenceSubstitution(PSubstitution sub1, PSubstitution sub2, PSubstitution... subs) {
    List<PSubstitution> subList = new ArrayList<>();
    subList.add(sub1);
    subList.add(sub2);
    for (PSubstitution pSubstitution : subs) {
        subList.add(pSubstitution);
    }
    return new ASequenceSubstitution(subList);
}
Also used : PSubstitution(de.be4.classicalb.core.parser.node.PSubstitution) ArrayList(java.util.ArrayList) ASequenceSubstitution(de.be4.classicalb.core.parser.node.ASequenceSubstitution)

Example 2 with ASequenceSubstitution

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

the class SourcePositionsTest method testSequenceSubst.

@Test
public void testSequenceSubst() throws Exception {
    final String testMachine = "#SUBSTITUTION skip; x:=5; skip";
    final Start result = getAst(testMachine);
    final ASubstitutionParseUnit substParseUnit = (ASubstitutionParseUnit) result.getPParseUnit();
    assertEquals(1, substParseUnit.getStartPos().getLine());
    assertEquals(1, substParseUnit.getStartPos().getPos());
    assertEquals(1, substParseUnit.getEndPos().getLine());
    assertEquals(testMachine.length() + 1, substParseUnit.getEndPos().getPos());
    final ASequenceSubstitution sequenceSubst = (ASequenceSubstitution) substParseUnit.getSubstitution();
    assertEquals(1, sequenceSubst.getStartPos().getLine());
    assertEquals(15, sequenceSubst.getStartPos().getPos());
    assertEquals(1, sequenceSubst.getEndPos().getLine());
    assertEquals(testMachine.length() + 1, sequenceSubst.getEndPos().getPos());
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) ASubstitutionParseUnit(de.be4.classicalb.core.parser.node.ASubstitutionParseUnit) ASequenceSubstitution(de.be4.classicalb.core.parser.node.ASequenceSubstitution) Test(org.junit.Test)

Aggregations

ASequenceSubstitution (de.be4.classicalb.core.parser.node.ASequenceSubstitution)2 ASubstitutionParseUnit (de.be4.classicalb.core.parser.node.ASubstitutionParseUnit)1 PSubstitution (de.be4.classicalb.core.parser.node.PSubstitution)1 Start (de.be4.classicalb.core.parser.node.Start)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1