Search in sources :

Example 1 with ASubstitutionParseUnit

use of de.be4.classicalb.core.parser.node.ASubstitutionParseUnit 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)

Example 2 with ASubstitutionParseUnit

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

the class SourcePositionsTest method testMultilineSubst.

@Test
public void testMultilineSubst() throws Exception {
    final String testMachine = "#SUBSTITUTION IF 1=1\n" + "THEN skip\n" + "ELSE skip\n" + "END";
    final Start result = getAst(testMachine);
    final ASubstitutionParseUnit substParseUnit = (ASubstitutionParseUnit) result.getPParseUnit();
    assertEquals(1, substParseUnit.getStartPos().getLine());
    assertEquals(1, substParseUnit.getStartPos().getPos());
    assertEquals(4, substParseUnit.getEndPos().getLine());
    assertEquals(4, substParseUnit.getEndPos().getPos());
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) ASubstitutionParseUnit(de.be4.classicalb.core.parser.node.ASubstitutionParseUnit) Test(org.junit.Test)

Example 3 with ASubstitutionParseUnit

use of de.be4.classicalb.core.parser.node.ASubstitutionParseUnit in project prob2 by bendisposto.

the class DomBuilder method createSubstitutionAST.

private Start createSubstitutionAST(final PSubstitution pSub) {
    Start start = new Start();
    ASubstitutionParseUnit node2 = new ASubstitutionParseUnit();
    start.setPParseUnit(node2);
    start.setEOF(EOF);
    node2.setSubstitution((PSubstitution) pSub.clone());
    node2.getSubstitution().apply(new RenameIdentifiers());
    return start;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) ASubstitutionParseUnit(de.be4.classicalb.core.parser.node.ASubstitutionParseUnit)

Aggregations

ASubstitutionParseUnit (de.be4.classicalb.core.parser.node.ASubstitutionParseUnit)3 Start (de.be4.classicalb.core.parser.node.Start)3 Test (org.junit.Test)2 ASequenceSubstitution (de.be4.classicalb.core.parser.node.ASequenceSubstitution)1