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());
}
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());
}
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;
}
Aggregations