use of de.be4.classicalb.core.preparser.node.Start 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.preparser.node.Start 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.preparser.node.Start 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.preparser.node.Start in project probparsers by bendisposto.
the class Helpers method printAsProlog.
public static void printAsProlog(final Start start, final IPrologTermOutput pout) {
final NodeIdAssignment nodeIds = new NodeIdAssignment();
nodeIds.assignIdentifiers(1, start);
final ClassicalPositionPrinter pprinter = new ClassicalPositionPrinter(nodeIds);
final ASTProlog prolog = new ASTProlog(pout, pprinter);
pout.openTerm("machine");
start.apply(prolog);
pout.closeTerm();
pout.fullstop();
pout.flush();
}
use of de.be4.classicalb.core.preparser.node.Start 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