use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class Helpers method getPrettyPrint.
public static String getPrettyPrint(final String testMachine) {
final BParser parser = new BParser("testcase");
Start startNode;
try {
startNode = parser.parse(testMachine, false);
} catch (BCompoundException e) {
throw new RuntimeException(e);
}
PrettyPrinter pp = new PrettyPrinter();
startNode.apply(pp);
return pp.getPrettyPrint();
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class LetPredicateTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
final Start startNode = parser.parse(testMachine, false);
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
return ast2String.toString();
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class FilePragmaTest method testFilePragma.
@Test
public void testFilePragma() throws IOException, BCompoundException {
String PATH = "src/test/resources/pragmas/filePragma/";
String file = PATH + "Main1.mch";
File f = new File(file);
BParser bparser = new BParser();
Start ast = bparser.parseFile(f, false);
assertNotNull(ast);
RecursiveMachineLoader rml = new RecursiveMachineLoader(PATH, bparser.getContentProvider(), new ParsingBehaviour());
rml.loadAllMachines(f, ast, bparser.getDefinitions());
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class DefinitionFilesTest method testNotExistingFile.
@Test
public void testNotExistingFile() {
final String testMachine = "MACHINE Test\nDEFINITIONS \"DefFile\"; def1 == xx\nEND";
try {
new BParser("testcase").parse(testMachine, false, new PlainFileContentProvider());
fail("Expected exception was not thrown");
} catch (final BCompoundException e) {
// EXPECTED
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class DefinitionFilesTest method testOneDefinitionFile.
@Test
public void testOneDefinitionFile() throws BCompoundException {
final String testMachine = "MACHINE Test\nDEFINITIONS \"DefFile\"; def1 == xx\nINVARIANT def2 = def3\nEND";
final BParser parser = new BParser("testcase");
parser.parse(testMachine, true, this);
final IDefinitions definitions = parser.getDefinitions();
final AExpressionDefinitionDefinition def1 = (AExpressionDefinitionDefinition) definitions.getDefinition("def1");
assertEquals("def1", def1.getName().getText());
assertEquals(0, def1.getParameters().size());
assertTrue(def1.getRhs() instanceof AIdentifierExpression);
final AExpressionDefinitionDefinition def2 = (AExpressionDefinitionDefinition) definitions.getDefinition("def2");
assertEquals("def2", def2.getName().getText());
assertEquals(0, def2.getParameters().size());
assertTrue(def2.getRhs() instanceof AIdentifierExpression);
}
Aggregations