use of de.be4.classicalb.core.parser.BParser in project prob2 by bendisposto.
the class ClassicalBFactory method parseFile.
/**
* Parse a file into an AST {@link Start}.
*
* @param model
* {@link File} containing B machine
* @param bparser
* {@link BParser} for parsing
* @return {@link Start} AST after parsing model with {@link BParser} bparser
* @throws IOException
* if an I/O error occurred
* @throws ProBError
* if the file could not be parsed
*/
public Start parseFile(final File model, final BParser bparser) throws IOException {
try {
logger.trace("Parsing main file '{}'", model.getAbsolutePath());
Start ast = null;
ast = bparser.parseFile(model, false);
return ast;
} catch (BCompoundException e) {
throw new ProBError(e);
}
}
use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.
the class SubstitutionTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
// System.out.println("Parsing \"" + testMachine + "\"");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println(string);
return string;
}
use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.
the class AtelierBCompatibilityTest method testSysExtension.
@Test
public void testSysExtension() throws IOException, BCompoundException {
String PATH = "src/test/resources/atelierb/sys_extension/";
String file = PATH + "main.sys";
File f = new File(file);
BParser bparser = new BParser();
Start ast = bparser.parseFile(f, false);
assertNotNull(ast);
RecursiveMachineLoader rml = new RecursiveMachineLoader(PATH, bparser.getContentProvider());
rml.loadAllMachines(f, ast, bparser.getDefinitions());
}
use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.
the class Helpers method fullParsing.
public static String fullParsing(String filename, ParsingBehaviour parsingBehaviour) {
final File machineFile = new File(filename);
final BParser parser = new BParser(machineFile.getAbsolutePath());
OutputStream output = new OutputStream() {
private StringBuilder string = new StringBuilder();
@Override
public void write(int b) throws IOException {
this.string.append((char) b);
}
public String toString() {
return this.string.toString();
}
};
PrintStream printStream = new PrintStream(output);
parser.fullParsing(machineFile, parsingBehaviour, printStream, printStream);
printStream.flush();
printStream.close();
return output.toString();
}
use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.
the class Helpers method getTreeAsString.
public static String getTreeAsString(final String testMachine) throws BCompoundException {
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println(string);
return string;
}
Aggregations