use of de.be4.eventb.core.parser.parser.Parser in project probparsers by bendisposto.
the class RecursiveMachineLoader method printAsProlog.
public void printAsProlog(final IPrologTermOutput pout) {
final ClassicalPositionPrinter pprinter = new ClassicalPositionPrinter(getNodeIdMapping());
pprinter.printSourcePositions(parsingBehaviour.isAddLineNumbers());
final ASTProlog prolog = new ASTProlog(pout, pprinter);
// parser version
pout.openTerm("parser_version");
pout.printAtom(BParser.getBuildRevision());
pout.closeTerm();
pout.fullstop();
// machine
pout.openTerm("classical_b");
pout.printAtom(main);
pout.openList();
List<File> allFiles = new ArrayList<>();
allFiles.addAll(machineFilesLoaded);
allFiles.addAll(definitionFilesLoaded);
for (final File file : allFiles) {
try {
pout.printAtom(file.getCanonicalPath());
} catch (IOException e) {
pout.printAtom(file.getPath());
}
}
pout.closeList();
pout.closeTerm();
pout.fullstop();
for (final Map.Entry<String, Start> entry : getParsedMachines().entrySet()) {
pout.openTerm("machine");
entry.getValue().apply(prolog);
pout.closeTerm();
pout.fullstop();
}
pout.flush();
}
use of de.be4.eventb.core.parser.parser.Parser in project probparsers by bendisposto.
the class StructuralTest method testConstantsClause.
@Test
public void testConstantsClause() throws Exception {
final String testMachine = "MACHINE SimplyStructure\nCONSTANTS dd, e, Ff\nPROPERTIES dd : BOOL\nEND";
// System.out.println("Parsing: \"" + testMachine + "\":");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
assertNotNull(startNode);
// TODO more tests
}
use of de.be4.eventb.core.parser.parser.Parser in project probparsers by bendisposto.
the class StructuralTest method testClausesStructure.
@Test
public void testClausesStructure() throws Exception {
final String testMachine = "MACHINE SimplyStructure\n" + "VARIABLES aa, b, Cc\n" + "INVARIANT aa : NAT\n" + "INITIALISATION aa:=1\n" + "CONSTANTS dd, e, Ff\n" + "PROPERTIES dd : NAT\n" + "SETS GGG; Hhh; JJ = {dada, dudu, TUTUT}; iII; kkk = {LLL}\nEND";
// System.out.println("Parsing: \"" + testMachine + "\":");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, true);
assertNotNull(startNode);
// TODO more tests
}
use of de.be4.eventb.core.parser.parser.Parser in project probparsers by bendisposto.
the class UnparsableMachineTest method testParsable.
@Test(expected = BCompoundException.class)
public void testParsable() throws Exception {
final BParser parser = new BParser(machine.getName());
Start start = parser.parseFile(machine, false);
assertNotNull(start);
}
use of de.be4.eventb.core.parser.parser.Parser in project probparsers by bendisposto.
the class Ticket295 method ticker295.
// #x. /* comment */ (x>1000 & x<2**10)
@Test
public void ticker295() throws Exception {
// String input = "#FORMULA #x. /* comment */ (x>1000 & x<2**10)";
String input1 = "#FORMULA #x. /*buh */ ( x>1000 & x<2**10)";
String input2 = "#FORMULA #x.(/*buh */ x>1000 & x<2**10)";
DefinitionTypes defTypes1 = new DefinitionTypes();
final BLexer lexer1 = new BLexer(new PushbackReader(new StringReader(input1), 99), defTypes1, input1.length());
DefinitionTypes defTypes2 = new DefinitionTypes();
final BLexer lexer2 = new BLexer(new PushbackReader(new StringReader(input2), 99), defTypes2, input2.length());
Parser parser1 = new Parser(lexer1);
Parser parser2 = new Parser(lexer2);
final Start rootNode1 = parser1.parse();
final Start rootNode2 = parser2.parse();
final String result1 = getTreeAsString(rootNode1);
final String result2 = getTreeAsString(rootNode2);
assertNotNull(rootNode1);
assertNotNull(rootNode2);
assertEquals(result1, result2);
}
Aggregations