use of de.be4.classicalb.core.preparser.parser.Parser in project probparsers by bendisposto.
the class ParseTestUtil method parse.
private static String parse(final String input) throws BCompoundException {
final BParser parser = new BParser();
final Start ast = parser.parse(input, false);
final Ast2String ast2String = new Ast2String();
ast.apply(ast2String);
return ast2String.toString();
}
use of de.be4.classicalb.core.preparser.parser.Parser in project probparsers by bendisposto.
the class PositionAspectTest method testHasGetMethods.
@Test
public void testHasGetMethods() throws Exception {
final String testMachine = "#EXPRESSION 1+2";
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, true);
startNode.getStartPos();
startNode.getEndPos();
}
use of de.be4.classicalb.core.preparser.parser.Parser in project probparsers by bendisposto.
the class PositionAspectTest method testSimpleNode.
@Test
public void testSimpleNode() throws Exception {
final String testMachine = "#EXPRESSION x";
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, true);
final PExpression expression = ((AExpressionParseUnit) startNode.getPParseUnit()).getExpression();
final SourcePosition startPos = expression.getStartPos();
final SourcePosition endPos = expression.getEndPos();
assertNotNull(startNode);
assertNotNull(endPos);
assertEquals(1, startPos.getLine());
assertEquals(13, startPos.getPos());
assertEquals(1, endPos.getLine());
assertEquals(14, endPos.getPos());
}
use of de.be4.classicalb.core.preparser.parser.Parser in project probparsers by bendisposto.
the class DefinitionFilesTest method testCircleReference.
/*
* test circles references between def files
*/
@Test
public void testCircleReference() throws Exception {
final String testMachine = "MACHINE Test\nDEFINITIONS \"DefFile3\"\nEND";
final BParser parser = new BParser("testcase");
try {
parser.parse(testMachine, false, this);
fail("Expected PreParseException missing");
} catch (final BCompoundException e) {
assertTrue(e.getCause() instanceof PreParseException);
}
}
use of de.be4.classicalb.core.preparser.parser.Parser in project probparsers by bendisposto.
the class DefinitionFilesTest method testDefCaching.
@Test
public void testDefCaching() throws Exception {
final String testMachine = "MACHINE Test\nDEFINITIONS \"DefFile1\"; \"DefFile2\"\nEND";
final BParser parser = new BParser("testcase");
final CountingDefinitionFileProvider provider = new CountingDefinitionFileProvider();
parser.parse(testMachine, false, provider);
assertEquals(4, provider.getStoredCounter);
assertEquals(2, provider.storeCounter);
assertEquals(2, provider.getContentCounter);
}
Aggregations