/** * Finds and loads a logic into the given symbol table * * @param logicName name of the logic to load * @param symTable the symbol table into which to load it * @return null if read OK, an error if a problem happened */ public /* @Nullable */ IResponse loadLogic( String logicName, SymbolTable symTable, /* @Nullable */ IPos pos) { ILogic sx = null; // = findLogic(logicName, smtConfig.logicPath, pos); { String name = logicName; ISource source; InputStream input = null; try { SMT.Configuration config = smtConfig.clone(); config.interactive = false; input = SMT.logicFinder.find(smtConfig, name, pos); if (input == null) return smtConfig.responseFactory.error( "Unexpected null result: No logic loaded " + name, pos); // The above error should not happen, because an exception // ought to be thrown for any problems in find(). source = config.smtFactory.createSource(config, input, null); IParser p = config.smtFactory.createParser(config, source); sx = p.parseLogic(); symTable.logicInUse = sx; } catch (IParser.ParserException e) { return smtConfig.responseFactory.error( "Failed to parse the logic file " + name + ": " + e, e.pos()); } catch (Utils.SMTLIBException e) { return e.errorResponse; } catch (Exception e) { return smtConfig.responseFactory.error( "Failed to read the logic file for " + name + ": " + e, null); } finally { try { if (input != null) input.close(); } catch (java.io.IOException e) { return smtConfig.responseFactory.error( "Failed to close a stream while parsing " + name + " : " + e, null); } } } if (sx == null) { return smtConfig.responseFactory.error("Failed to load logic", pos); } // The second element should be the name of the logic, if specified if (!logicName.equals(sx.logicName().value())) { return smtConfig.responseFactory.error( "Definition of logic " + logicName + " is mal-formed (internal name does not match file name): " + sx.logicName().value(), sx.logicName().pos()); } return loadLogic(sx, symTable); }