Search in sources :

Example 1 with ActionsFactory

use of org.spoofax.jsglr2.actions.ActionsFactory 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;
}
Also used : ParseTableReader(org.spoofax.jsglr2.parsetable.ParseTableReader) IStrategoTerm(org.spoofax.interpreter.terms.IStrategoTerm) StateFactory(org.spoofax.jsglr2.states.StateFactory) CharacterClassFactory(org.metaborg.characterclasses.CharacterClassFactory) InputStream(java.io.InputStream) IOException(java.io.IOException) FileObject(org.apache.commons.vfs2.FileObject) IOException(java.io.IOException) TermReader(org.spoofax.terms.io.binary.TermReader) ActionsFactory(org.spoofax.jsglr2.actions.ActionsFactory)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 FileObject (org.apache.commons.vfs2.FileObject)1 CharacterClassFactory (org.metaborg.characterclasses.CharacterClassFactory)1 IStrategoTerm (org.spoofax.interpreter.terms.IStrategoTerm)1 ActionsFactory (org.spoofax.jsglr2.actions.ActionsFactory)1 ParseTableReader (org.spoofax.jsglr2.parsetable.ParseTableReader)1 StateFactory (org.spoofax.jsglr2.states.StateFactory)1 TermReader (org.spoofax.terms.io.binary.TermReader)1