use of de.be4.eventbalg.core.parser.parser.Parser in project probparsers by bendisposto.
the class ASTPrologTest method checkProlog.
private void checkProlog(final int counter, final String bspec, final String expected) throws BCompoundException {
final BParser parser = new BParser("testcase");
if (remove_restrictions) {
parser.getOptions().setRestrictProverExpressions(false);
}
final Start startNode = parser.parse(bspec, false, new NoContentProvider());
checkAST(counter, expected, startNode);
}
use of de.be4.eventbalg.core.parser.parser.Parser in project probparsers by bendisposto.
the class ParseableButProblematicOnWindows method testParsable.
@Test
public void testParsable() throws Exception {
final BParser parser = new BParser(machine.getName());
Start start = parser.parseFile(machine, false);
start.apply(new PositionTester());
assertNotNull(start);
}
use of de.be4.eventbalg.core.parser.parser.Parser in project probparsers by bendisposto.
the class ParseableButProblematicOnWindowsWindowsLF method testParsable.
@Test
public void testParsable() throws Exception {
final BParser parser = new BParser(machine.getName());
Start start = parser.parseFile(machine, false);
start.apply(new PositionTester());
assertNotNull(start);
}
use of de.be4.eventbalg.core.parser.parser.Parser in project probparsers by bendisposto.
the class PreParser method parse.
public void parse() throws PreParseException, IOException, BException, BCompoundException {
final PreLexer preLexer = new PreLexer(pushbackReader);
final Parser preParser = new Parser(preLexer);
Start rootNode = null;
try {
rootNode = preParser.parse();
} catch (final ParserException e) {
if (e.getToken() instanceof de.be4.classicalb.core.preparser.node.TDefinitions) {
final Token errorToken = e.getToken();
final String message = "[" + errorToken.getLine() + "," + errorToken.getPos() + "] " + "Clause 'DEFINITIONS' is used more than once";
throw new PreParseException(e.getToken(), message);
} else {
throw new PreParseException(e.getToken(), e.getLocalizedMessage());
}
} catch (final LexerException e) {
throw new PreParseException(e.getLocalizedMessage());
}
final DefinitionPreCollector collector = new DefinitionPreCollector();
rootNode.apply(collector);
evaluateDefinitionFiles(collector.getFileDefinitions());
List<Token> sortedDefinitionList = sortDefinitionsByTopologicalOrderAndCheckForCycles(collector.getDefinitions());
evaluateTypes(sortedDefinitionList, collector.getDefinitions());
}
use of de.be4.eventbalg.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();
}
Aggregations