use of org.spoofax.jsglr.client.ParseTable in project spoofax by metaborg.
the class JSGLR1FileParseTableProvider method parseTable.
@Override
public ParseTable 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 ParseTable(parseTableTerm, termFactory, persistedTable);
} else {
parseTable = new ParseTable(parseTableTerm, termFactory);
}
} catch (Exception e) {
throw new IOException("Could not load parse table from " + resource, e);
}
return parseTable;
}
use of org.spoofax.jsglr.client.ParseTable in project spoofax by metaborg.
the class JSGLR1IncrementalParseTableProvider method parseTable.
@Override
public ParseTable 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);
final IStrategoTerm parseTableTerm = termReader.parseFromStream(stream);
FileObject persistedTable = resource.getParent().resolveFile("table.bin");
if (persistedTable.exists()) {
if (referenceTable != null) {
parseTable = new ParseTable(parseTableTerm, termFactory, persistedTable, referenceTable);
} else {
parseTable = new ParseTable(parseTableTerm, termFactory, persistedTable);
}
} else {
parseTable = new ParseTable(parseTableTerm, termFactory);
}
} catch (Exception e) {
throw new IOException("Could not load parse table from " + resource, e);
}
return parseTable;
}
Aggregations