private ATerm readFromBinaryFile(final InputStream stream, final boolean headerRead) throws ParseError, IOException { final BAFReader r = new BAFReader(this, stream); return r.readFromBinaryFile(headerRead); }
public ATerm readFromBinaryFile(final boolean headerAlreadyRead) throws ParseError, IOException { if (!headerAlreadyRead && !isBinaryATerm(_reader)) throw new ParseError("Input is not a BAF file"); final int val = _reader.readInt(); if (val != BAF_VERSION) throw new ParseError("Wrong BAF version (wanted " + BAF_VERSION + ", got " + val + "), giving up"); _nrUniqueSymbols = _reader.readInt(); final int nrUniqueTerms = _reader.readInt(); if (isDebugging()) { debug("" + _nrUniqueSymbols + " unique symbols"); debug("" + nrUniqueTerms + " unique terms"); } _symbols = new SymEntry[_nrUniqueSymbols]; readAllSymbols(); final int i = _reader.readInt(); return readTerm(_symbols[i]); }
if (isDebugging()) debug("readTerm()/" + _level + " - " + e.fun.getName() + "[" + arity + "]"); if (isDebugging()) debug(" [" + i + "] - " + val); debug(" [" + i + "] - " + e.topSyms[i].length); if (argSym.terms[val] == null) if (isDebugging()) debug(" [" + i + "] - recurse"); argSym.terms[val] = readTerm(argSym); if (isDebugging()) debug("--"); for (final ATerm arg : args) debug(" + " + arg.getClass()); if (isDebugging()) debug(e.fun + " / " + args); for (final ATerm arg : args) debug("" + arg);
private AFun readSymbol() throws IOException { final String s = _reader.readString(); final int arity = _reader.readInt(); final int quoted = _reader.readInt(); if (isDebugging()) debug(s + " / " + arity + " / " + quoted); return _factory.makeAFun(s, arity, quoted != 0); }
_symbols[i] = e; final AFun fun = readSymbol(); e.fun = fun; final int arity = e.arity = fun.getArity(); e.termWidth = bitWidth(v); e.symWidth[j] = bitWidth(v); e.topSyms[j] = new int[v];
private static boolean isBinaryATerm(final BitStream in) throws IOException { try { final int w1 = in.readInt(); return w1 == BAF_MAGIC; } catch (final EOFException e) { _logger.log(Level.FINE, "", e); } return false; }
try (final BufferedInputStream bis = new BufferedInputStream(stream)) if (BAFReader.isBinaryATerm(bis)) return readFromBinaryFile(bis, true);