use of org.metaborg.characterclasses.CharacterClassFactory in project spoofax by metaborg.
the class JSGLR2FileParseTableProvider method parseTable.
@Override
public IParseTable parseTable() throws IOException {
if (parseTable != null) {
return parseTable;
}
resource.refresh();
if (!resource.exists()) {
throw new IOException("Could not load parse table from " + resource + ", file does not exist");
}
try (final InputStream stream = resource.getContent().getInputStream()) {
final TermReader termReader = new TermReader(termFactory);
IStrategoTerm parseTableTerm = termReader.parseFromStream(stream);
FileObject persistedTable = resource.getParent().resolveFile("table.bin");
if (!persistedTable.exists()) {
parseTable = new ParseTableReader(new CharacterClassFactory(true, true), new ActionsFactory(true), new StateFactory()).read(parseTableTerm);
} else {
parseTable = new ParseTableReader(new CharacterClassFactory(true, true), new ActionsFactory(true), new StateFactory()).read(parseTableTerm, persistedTable);
}
} catch (Exception e) {
throw new IOException("Could not load parse table from " + resource, e);
}
return parseTable;
}
Aggregations