use of de.be4.classicalb.core.parser.ParsingBehaviour 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.ParsingBehaviour in project probparsers by bendisposto.
the class RulesProjectExceptionTest method testRulesMachineInOrdinaryMachineFileException.
@Test
public void testRulesMachineInOrdinaryMachineFileException() throws Exception {
OutputStream output = new OutputStream() {
private StringBuilder string = new StringBuilder();
@Override
public void write(int b) throws IOException {
this.string.append((char) b);
}
@Override
public String toString() {
return this.string.toString();
}
};
PrintStream pStream = new PrintStream(output);
ParsingBehaviour parsingBehaviour = new ParsingBehaviour();
parsingBehaviour.setPrologOutput(true);
BParser bParser = new BParser("RulesMachineInOrdinaryMachineFile.mch");
bParser.fullParsing(new File("src/test/resources/rules/project/RulesMachineInOrdinaryMachineFile.mch"), parsingBehaviour, pStream, pStream);
System.out.println(output.toString());
assertTrue(output.toString().contains("parse_exception"));
}
use of de.be4.classicalb.core.parser.ParsingBehaviour in project probparsers by bendisposto.
the class RulesUtil method getRulesProjectAsPrologTerm.
public static String getRulesProjectAsPrologTerm(final String content) {
RulesProject rulesProject = new RulesProject();
ParsingBehaviour pb = new ParsingBehaviour();
pb.setAddLineNumbers(false);
rulesProject.setParsingBehaviour(pb);
rulesProject.parseRulesMachines(content, new String[] {});
rulesProject.checkAndTranslateProject();
List<IModel> bModels = rulesProject.getBModels();
List<BException> bExceptionList = rulesProject.getBExceptionList();
if (bExceptionList.isEmpty()) {
IModel model = bModels.get(bModels.size() - 2);
PrettyPrinter pp = new PrettyPrinter();
model.getStart().apply(pp);
System.out.println(pp.getPrettyPrint());
}
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();
}
};
rulesProject.printPrologOutput(new PrintStream(output), new PrintStream(output));
return output.toString();
}
use of de.be4.classicalb.core.parser.ParsingBehaviour in project probparsers by bendisposto.
the class RulesMachineFilesTest method testImplicitDependenciesDueToFunctionCall.
@Test
public void testImplicitDependenciesDueToFunctionCall() throws Exception {
File file = new File(dir + "ImplicitDependencyDueFunctionCall.rmch");
ParsingBehaviour parsingBehaviour = new ParsingBehaviour();
parsingBehaviour.setAddLineNumbers(true);
parsingBehaviour.setPrologOutput(true);
RulesProject.parseProject(file, parsingBehaviour, System.out, System.err);
}
use of de.be4.classicalb.core.parser.ParsingBehaviour in project probparsers by bendisposto.
the class RulesMachineFilesTest method testProject2.
@Test
public void testProject2() throws Exception {
File file = new File(dir + "project/references/test1/Rule1.rmch");
ParsingBehaviour parsingBehaviour = new ParsingBehaviour();
parsingBehaviour.setAddLineNumbers(true);
parsingBehaviour.setPrologOutput(true);
RulesProject.parseProject(file, parsingBehaviour, System.out, System.err);
}
Aggregations