Handle languages as strings in driver (#7074)
authorGereon Kremer <nafur42@gmail.com>
Fri, 27 Aug 2021 18:23:15 +0000 (11:23 -0700)
committerGitHub <noreply@github.com>
Fri, 27 Aug 2021 18:23:15 +0000 (18:23 +0000)
This PR moves the first chunk of code in the driver to use the proper options API for the language options. It is now handled as a string.

18 files changed:
src/main/driver_unified.cpp
src/main/interactive_shell.cpp
src/main/interactive_shell.h
src/options/base_options.toml
src/options/options_handler.cpp
src/options/options_handler.h
src/parser/antlr_input.cpp
src/parser/antlr_input.h
src/parser/input.cpp
src/parser/input.h
src/parser/parser_builder.cpp
src/parser/parser_builder.h
src/parser/smt2/smt2.cpp
src/parser/smt2/smt2.h
test/api/ouroborous.cpp
test/api/smt2_compliance.cpp
test/unit/parser/parser_black.cpp
test/unit/parser/parser_builder_black.cpp

index de6f614e1804068b8e010298fbee46e450cf3695..f68545d0026c9721d99f0257a22e0e8559476ba8 100644 (file)
@@ -158,32 +158,32 @@ int runCvc5(int argc, char* argv[], std::unique_ptr<api::Solver>& solver)
   }
   const char* filename = filenameStr.c_str();
 
-  if (opts->base.inputLanguage == Language::LANG_AUTO)
+  if (solver->getOption("input-language") == "LANG_AUTO")
   {
     if( inputFromStdin ) {
       // We can't do any fancy detection on stdin
-      opts->base.inputLanguage = Language::LANG_CVC;
+      solver->setOption("input-language", "cvc");
     } else {
       size_t len = filenameStr.size();
       if(len >= 5 && !strcmp(".smt2", filename + len - 5)) {
-        opts->base.inputLanguage = Language::LANG_SMTLIB_V2_6;
+        solver->setOption("input-language", "smt2");
       } else if((len >= 2 && !strcmp(".p", filename + len - 2))
                 || (len >= 5 && !strcmp(".tptp", filename + len - 5))) {
-        opts->base.inputLanguage = Language::LANG_TPTP;
+        solver->setOption("input-language", "tptp");
       } else if(( len >= 4 && !strcmp(".cvc", filename + len - 4) )
                 || ( len >= 5 && !strcmp(".cvc4", filename + len - 5) )) {
-        opts->base.inputLanguage = Language::LANG_CVC;
+        solver->setOption("input-language", "cvc");
       } else if((len >= 3 && !strcmp(".sy", filename + len - 3))
                 || (len >= 3 && !strcmp(".sl", filename + len - 3))) {
         // version 2 sygus is the default
-        opts->base.inputLanguage = Language::LANG_SYGUS_V2;
+        solver->setOption("input-language", "sygus2");
       }
     }
   }
 
-  if (opts->base.outputLanguage == Language::LANG_AUTO)
+  if (solver->getOption("output-language") == "LANG_AUTO")
   {
-    opts->base.outputLanguage = opts->base.inputLanguage;
+    solver->setOption("output-language", solver->getOption("input-language"));
   }
   pExecutor->storeOptionsAsOriginal();
 
@@ -197,11 +197,6 @@ int runCvc5(int argc, char* argv[], std::unique_ptr<api::Solver>& solver)
     WarningChannel.setStream(&cvc5::null_os);
   }
 
-  // important even for muzzled builds (to get result output right)
-  (*opts->base.out)
-      << language::SetLanguage(opts->base.outputLanguage);
-
-
   int returnValue = 0;
   {
     // notify SmtEngine that we are starting to parse
@@ -259,19 +254,19 @@ int runCvc5(int argc, char* argv[], std::unique_ptr<api::Solver>& solver)
         pExecutor->doCommand(cmd);
       }
 
-      ParserBuilder parserBuilder(pExecutor->getSolver(),
-                                  pExecutor->getSymbolManager(),
-                                  *opts);
+      ParserBuilder parserBuilder(
+          pExecutor->getSolver(), pExecutor->getSymbolManager(), true);
       std::unique_ptr<Parser> parser(parserBuilder.build());
       if( inputFromStdin ) {
         parser->setInput(Input::newStreamInput(
-            opts->base.inputLanguage, cin, filename));
+            solver->getOption("input-language"), cin, filename));
       }
       else
       {
-        parser->setInput(Input::newFileInput(opts->base.inputLanguage,
-                                             filename,
-                                             opts->parser.memoryMap));
+        parser->setInput(
+            Input::newFileInput(solver->getOption("input-language"),
+                                filename,
+                                solver->getOption("mmap") == "true"));
       }
 
       bool interrupted = false;
index 14a507aeeb2ffeb5dbd350aa8b86b312700a22ac..8cb40cfdb6df960c5c7036980ee0f52cf490e484 100644 (file)
@@ -91,17 +91,17 @@ static set<string> s_declarations;
 #endif /* HAVE_LIBEDITLINE */
 
 InteractiveShell::InteractiveShell(api::Solver* solver, SymbolManager* sm)
-    : d_options(solver->getOptions()),
-      d_in(*d_options.base.in),
-      d_out(*d_options.base.out),
+    : d_solver(solver),
+      d_in(*solver->getOptions().base.in),
+      d_out(*solver->getOptions().base.out),
       d_quit(false)
 {
-  ParserBuilder parserBuilder(solver, sm, d_options);
+  ParserBuilder parserBuilder(solver, sm, true);
   /* Create parser with bogus input. */
   d_parser = parserBuilder.build();
-  if (d_options.parser.forceLogicStringWasSetByUser)
+  if (d_solver->getOptions().parser.forceLogicStringWasSetByUser)
   {
-    LogicInfo tmp(d_options.parser.forceLogicString);
+    LogicInfo tmp(d_solver->getOption("force-logic"));
     d_parser->forceLogic(tmp.getLogicString());
   }
 
@@ -116,34 +116,30 @@ InteractiveShell::InteractiveShell(api::Solver* solver, SymbolManager* sm)
 #endif /* EDITLINE_COMPENTRY_FUNC_RETURNS_CHARP */
     ::using_history();
 
-    Language lang = d_options.base.inputLanguage;
-    switch(lang) {
-      case Language::LANG_CVC:
-        d_historyFilename = string(getenv("HOME")) + "/.cvc5_history";
-        commandsBegin = cvc_commands;
-        commandsEnd =
-            cvc_commands + sizeof(cvc_commands) / sizeof(*cvc_commands);
-        break;
-      case Language::LANG_TPTP:
-        d_historyFilename = string(getenv("HOME")) + "/.cvc5_history_tptp";
-        commandsBegin = tptp_commands;
-        commandsEnd =
-            tptp_commands + sizeof(tptp_commands) / sizeof(*tptp_commands);
-        break;
-      default:
-        if (language::isLangSmt2(lang))
-        {
-          d_historyFilename = string(getenv("HOME")) + "/.cvc5_history_smtlib2";
-          commandsBegin = smt2_commands;
-          commandsEnd =
-              smt2_commands + sizeof(smt2_commands) / sizeof(*smt2_commands);
-        }
-        else
-        {
-          std::stringstream ss;
-          ss << "internal error: unhandled language " << lang;
-          throw Exception(ss.str());
-        }
+    std::string lang = solver->getOption("input-language");
+    if (lang == "LANG_CVC")
+    {
+      d_historyFilename = string(getenv("HOME")) + "/.cvc5_history";
+      commandsBegin = cvc_commands;
+      commandsEnd = cvc_commands + sizeof(cvc_commands) / sizeof(*cvc_commands);
+    }
+    else if (lang == "LANG_TPTP")
+    {
+      d_historyFilename = string(getenv("HOME")) + "/.cvc5_history_tptp";
+      commandsBegin = tptp_commands;
+      commandsEnd =
+          tptp_commands + sizeof(tptp_commands) / sizeof(*tptp_commands);
+    }
+    else if (lang == "LANG_SMTLIB_V2_6")
+    {
+      d_historyFilename = string(getenv("HOME")) + "/.cvc5_history_smtlib2";
+      commandsBegin = smt2_commands;
+      commandsEnd =
+          smt2_commands + sizeof(smt2_commands) / sizeof(*smt2_commands);
+    }
+    else
+    {
+      throw Exception("internal error: unhandled language " + lang);
     }
     d_usingEditline = true;
     int err = ::read_history(d_historyFilename.c_str());
@@ -313,7 +309,7 @@ restart:
   }
 
   d_parser->setInput(Input::newStringInput(
-      d_options.base.inputLanguage, input, INPUT_FILENAME));
+      d_solver->getOption("input-language"), input, INPUT_FILENAME));
 
   /* There may be more than one command in the input. Build up a
      sequence. */
@@ -364,7 +360,7 @@ restart:
   }
   catch (ParserException& pe)
   {
-    if (language::isLangSmt2(d_options.base.outputLanguage))
+    if (d_solver->getOption("output-language") == "LANG_SMTLIB_V2_6")
     {
       d_out << "(error \"" << pe << "\")" << endl;
     }
index cf5f22b51753bfc18538d4f81635c227a80c772f..d4736470f06ef658b3801cf20d284becf4e910d8 100644 (file)
@@ -40,7 +40,7 @@ class SymbolManager;
 
 class InteractiveShell
 {
-  const Options& d_options;
+  api::Solver* d_solver;
   std::istream& d_in;
   std::ostream& d_out;
   parser::Parser* d_parser;
index a049348a68b240fcf9cbcf7c641b59f8886aa9d8..bf0134200c73baa87112f962f7fedf746ccf4f29 100644 (file)
@@ -49,6 +49,7 @@ public = true
   type       = "Language"
   default    = "Language::LANG_AUTO"
   handler    = "stringToLanguage"
+  predicates = ["applyOutputLanguage"]
   includes   = ["options/language.h"]
   help       = "force output language (default is \"auto\"; see --output-lang help)"
 
index 149aa767b1810d6de18133567418c37703427157..1b6cff5191e770ef27877ca1a64b2a55216ca66c 100644 (file)
@@ -34,6 +34,7 @@
 #include "options/didyoumean.h"
 #include "options/language.h"
 #include "options/option_exception.h"
+#include "options/set_language.h"
 #include "options/smt_options.h"
 #include "options/theory_options.h"
 #include "smt/command.h"
@@ -513,6 +514,13 @@ Language OptionsHandler::stringToLanguage(const std::string& option,
   Unreachable();
 }
 
+void OptionsHandler::applyOutputLanguage(const std::string& option,
+                                         const std::string& flag,
+                                         Language lang)
+{
+  d_options->base.out << language::SetLanguage(lang);
+}
+
 void OptionsHandler::languageIsNotAST(const std::string& option,
                                       const std::string& flag,
                                       Language lang)
index 3b8eb724f9ca90505e42ea76e653bde378db3d4e..0d625c5daf77526087831ddd2f8d5c03c33c2bc9 100644 (file)
@@ -153,6 +153,10 @@ public:
   Language stringToLanguage(const std::string& option,
                             const std::string& flag,
                             const std::string& optarg);
+  /** Apply the output language to the default output stream */
+  void applyOutputLanguage(const std::string& option,
+                           const std::string& flag,
+                           Language lang);
   /** Check that lang is not LANG_AST (which is not allowed as input language). */
   void languageIsNotAST(const std::string& option,
                         const std::string& flag,
index 6d5cbb5cc64a098621ea5a9d781b484da2250219..c190fe7f02421af612e21f57c597c3b4be0a8ff8 100644 (file)
@@ -185,35 +185,30 @@ AntlrInputStream::newStringInputStream(const std::string& input,
   return new AntlrInputStream(name, inputStream, false, input_duplicate, NULL);
 }
 
-AntlrInput* AntlrInput::newInput(Language lang, AntlrInputStream& inputStream)
+AntlrInput* AntlrInput::newInput(const std::string& lang,
+                                 AntlrInputStream& inputStream)
 {
-  AntlrInput* input;
-
-  switch(lang) {
-    case Language::LANG_CVC:
-    {
-      input = new CvcInput(inputStream);
-      break;
-    }
-
-    case Language::LANG_SYGUS_V2: input = new SygusInput(inputStream); break;
-
-    case Language::LANG_TPTP: input = new TptpInput(inputStream); break;
-
-    default:
-      if (language::isLangSmt2(lang))
-      {
-        input = new Smt2Input(inputStream);
-      }
-      else
-      {
-        std::stringstream ss;
-        ss << "unable to detect input file format, try --lang ";
-        throw InputStreamException(ss.str());
-      }
+  if (lang == "LANG_CVC")
+  {
+    return new CvcInput(inputStream);
+  }
+  else if (lang == "LANG_SYGUS_V2")
+  {
+    return new SygusInput(inputStream);
+  }
+  else if (lang == "LANG_TPTP")
+  {
+    return new TptpInput(inputStream);
+  }
+  else if (lang == "LANG_SMTLIB_V2_6")
+  {
+    return new Smt2Input(inputStream);
+  }
+  else
+  {
+    throw InputStreamException(
+        "unable to detect input file format, try --lang ");
   }
-
-  return input;
 }
 
 AntlrInput::AntlrInput(AntlrInputStream& inputStream, unsigned int lookahead) :
index 52650f56118b402f58baa3b6d628b9b8a66e9de4..7799d279dbea8cdbe2e10e5e2457fe2bd79ec8be 100644 (file)
@@ -155,7 +155,8 @@ public:
    * @param inputStream the input stream
    *
    * */
-  static AntlrInput* newInput(Language lang, AntlrInputStream& inputStream);
+  static AntlrInput* newInput(const std::string& lang,
+                              AntlrInputStream& inputStream);
 
   /** Retrieve the text associated with a token. */
   static std::string tokenText(pANTLR3_COMMON_TOKEN token);
index 9d4c65eae4a3662399977a9653d189e42e4ded5a..c8c005b3602634c13005948a5556735e4767ccbc 100644 (file)
@@ -51,7 +51,7 @@ InputStream *Input::getInputStream() {
   return d_inputStream;
 }
 
-Input* Input::newFileInput(Language lang,
+Input* Input::newFileInput(const std::string& lang,
                            const std::string& filename,
                            bool useMmap)
 {
@@ -60,7 +60,7 @@ Input* Input::newFileInput(Language lang,
   return AntlrInput::newInput(lang, *inputStream);
 }
 
-Input* Input::newStreamInput(Language lang,
+Input* Input::newStreamInput(const std::string& lang,
                              std::istream& input,
                              const std::string& name)
 {
@@ -69,7 +69,7 @@ Input* Input::newStreamInput(Language lang,
   return AntlrInput::newInput(lang, *inputStream);
 }
 
-Input* Input::newStringInput(Language lang,
+Input* Input::newStringInput(const std::string& lang,
                              const std::string& str,
                              const std::string& name)
 {
index 94bbe1d8a7cb79a16d6bfc4f94d2f4eaea1def57..7d7254339d8e0d18de9369f1068dfcf3828dc689 100644 (file)
@@ -100,7 +100,7 @@ class CVC5_EXPORT Input
     * @param filename the input filename
     * @param useMmap true if the parser should use memory-mapped I/O (default: false)
     */
-  static Input* newFileInput(Language lang,
+  static Input* newFileInput(const std::string& lang,
                              const std::string& filename,
                              bool useMmap = false);
 
@@ -113,7 +113,7 @@ class CVC5_EXPORT Input
    * (false, the default, means that the entire Input might be read
    * before being lexed and parsed)
    */
-  static Input* newStreamInput(Language lang,
+  static Input* newStreamInput(const std::string& lang,
                                std::istream& input,
                                const std::string& name);
 
@@ -123,7 +123,7 @@ class CVC5_EXPORT Input
    * @param input the input string
    * @param name the name of the stream, for use in error messages
    */
-  static Input* newStringInput(Language lang,
+  static Input* newStringInput(const std::string& lang,
                                const std::string& input,
                                const std::string& name);
 
index 1ac03fb832a5cbd83d213fe71eb693f80e08bcd7..6658364021d6851b21ea7ce3c2ab2b9b1cc6f634 100644 (file)
 namespace cvc5 {
 namespace parser {
 
-ParserBuilder::ParserBuilder(api::Solver* solver, SymbolManager* sm)
-    : d_solver(solver), d_symman(sm)
-{
-  init(solver, sm);
-}
-
 ParserBuilder::ParserBuilder(api::Solver* solver,
                              SymbolManager* sm,
-                             const Options& options)
+                             bool useOptions)
     : d_solver(solver), d_symman(sm)
 {
   init(solver, sm);
-  withOptions(options);
+  if (useOptions)
+  {
+    withOptions(solver->getOptions());
+  }
 }
 
 void ParserBuilder::init(api::Solver* solver, SymbolManager* sm)
 {
-  d_lang = Language::LANG_AUTO;
+  d_lang = "LANG_AUTO";
   d_solver = solver;
   d_symman = sm;
   d_checksEnabled = true;
@@ -64,24 +61,17 @@ void ParserBuilder::init(api::Solver* solver, SymbolManager* sm)
 Parser* ParserBuilder::build()
 {
   Parser* parser = NULL;
-  switch (d_lang)
+  if (d_lang == "LANG_SYGUS_V2" || d_lang == "LANG_SMTLIB_V2_6")
+  {
+    parser = new Smt2(d_solver, d_symman, d_strictMode, d_parseOnly);
+  }
+  else if (d_lang == "LANG_TPTP")
+  {
+    parser = new Tptp(d_solver, d_symman, d_strictMode, d_parseOnly);
+  }
+  else
   {
-    case Language::LANG_SYGUS_V2:
-      parser = new Smt2(d_solver, d_symman, d_strictMode, d_parseOnly);
-      break;
-    case Language::LANG_TPTP:
-      parser = new Tptp(d_solver, d_symman, d_strictMode, d_parseOnly);
-      break;
-    default:
-      if (language::isLangSmt2(d_lang))
-      {
-        parser = new Smt2(d_solver, d_symman, d_strictMode, d_parseOnly);
-      }
-      else
-      {
-        parser = new Cvc(d_solver, d_symman, d_strictMode, d_parseOnly);
-      }
-      break;
+    parser = new Cvc(d_solver, d_symman, d_strictMode, d_parseOnly);
   }
 
   if( d_checksEnabled ) {
@@ -108,7 +98,7 @@ ParserBuilder& ParserBuilder::withChecks(bool flag) {
   return *this;
 }
 
-ParserBuilder& ParserBuilder::withInputLanguage(Language lang)
+ParserBuilder& ParserBuilder::withInputLanguage(const std::string& lang)
 {
   d_lang = lang;
   return *this;
@@ -122,7 +112,7 @@ ParserBuilder& ParserBuilder::withParseOnly(bool flag) {
 ParserBuilder& ParserBuilder::withOptions(const Options& opts)
 {
   ParserBuilder& retval = *this;
-  retval = retval.withInputLanguage(opts.base.inputLanguage)
+  retval = retval.withInputLanguage(d_solver->getOption("input-language"))
                .withChecks(opts.parser.semanticChecks)
                .withStrictMode(opts.parser.strictParsing)
                .withParseOnly(opts.base.parseOnly)
index 61819a8f922e780b164392c2bf63c04886f1646e..23a9daae2f00583359afe196d042b219cc1cbda1 100644 (file)
@@ -45,7 +45,7 @@ class Parser;
 class CVC5_EXPORT ParserBuilder
 {
   /** The input language */
-  Language d_lang;
+  std::string d_lang;
 
   /** The API Solver object. */
   api::Solver* d_solver;
@@ -76,11 +76,7 @@ class CVC5_EXPORT ParserBuilder
 
  public:
   /** Create a parser builder using the given Solver and filename. */
-  ParserBuilder(api::Solver* solver, SymbolManager* sm);
-
-  ParserBuilder(api::Solver* solver,
-                SymbolManager* sm,
-                const Options& options);
+  ParserBuilder(api::Solver* solver, SymbolManager* sm, bool useOptions);
 
   /** Build the parser, using the current settings. */
   Parser* build();
@@ -93,7 +89,7 @@ class CVC5_EXPORT ParserBuilder
    *
    * (Default: LANG_AUTO)
    */
-  ParserBuilder& withInputLanguage(Language lang);
+  ParserBuilder& withInputLanguage(const std::string& lang);
 
   /**
    * Are we only parsing, or doing something with the resulting
index fe777fe27cbfdcc6630721951133d2f7140b2b60..39492a98c4ee958c67e22ad40446ced6a137aab5 100644 (file)
@@ -334,7 +334,7 @@ api::Term Smt2::getExpressionForNameAndType(const std::string& name,
 
 bool Smt2::getTesterName(api::Term cons, std::string& name)
 {
-  if ((v2_6() || sygus_v2()) && strictModeEnabled())
+  if ((v2_6() || sygus()) && strictModeEnabled())
   {
     // 2.6 or above uses indexed tester symbols, if we are in strict mode,
     // we do not automatically define is-cons for constructor cons.
@@ -711,9 +711,10 @@ api::Grammar* Smt2::mkGrammar(const std::vector<api::Term>& boundVars,
   return d_allocGrammars.back().get();
 }
 
-bool Smt2::sygus() const { return language::isLangSygus(getLanguage()); }
-
-bool Smt2::sygus_v2() const { return getLanguage() == Language::LANG_SYGUS_V2; }
+bool Smt2::sygus() const
+{
+  return d_solver->getOption("input-language") == "LANG_SYGUS_V2";
+}
 
 void Smt2::checkThatLogicIsSet()
 {
index 50b4a4efcfd3ba274c5a5e0a5df42951e58dc5e5..c3f93708d9f3031dd2c08106c798c366c5b0658c 100644 (file)
@@ -230,12 +230,10 @@ class Smt2 : public Parser
    */
   bool v2_6(bool exact = false) const
   {
-    return language::isLangSmt2(getLanguage());
+    return d_solver->getOption("input-language") == "LANG_SMTLIB_V2_6";
   }
   /** Are we using a sygus language? */
   bool sygus() const;
-  /** Are we using the sygus version 2.0 format? */
-  bool sygus_v2() const;
 
   /**
    * Returns true if the language that we are parsing (SMT-LIB version >=2.5
index 92e58085d9dec3ac8c0a166bbe3285bfa828129f..06b6e320b3274a83394bb7a6ab3af62d7cbe7260 100644 (file)
@@ -96,14 +96,16 @@ std::string parse(std::string instr,
   }
 
   api::Solver solver;
-  Language ilang = input_language == "smt2" ? Language::LANG_SMTLIB_V2_6
-                                            : Language::LANG_CVC;
+  std::string ilang =
+      input_language == "smt2" ? "LANG_SMTLIB_V2_6" : "LANG_CVC";
 
   solver.setOption("input-language", input_language);
   solver.setOption("output-language", output_language);
   SymbolManager symman(&solver);
   std::unique_ptr<Parser> parser(
-      ParserBuilder(&solver, &symman).withInputLanguage(ilang).build());
+      ParserBuilder(&solver, &symman, false)
+          .withInputLanguage(solver.getOption("input-language"))
+          .build());
   parser->setInput(
       Input::newStringInput(ilang, declarations, "internal-buffer"));
   // we don't need to execute the commands, but we DO need to parse them to
index 921d7585f8deaf0d15cd9c17abba03467b26405d..888f722a72a84ad8f878638701e3b902967c19c6 100644 (file)
@@ -59,11 +59,9 @@ void testGetInfo(api::Solver* solver, const char* s)
 {
   std::unique_ptr<SymbolManager> symman(new SymbolManager(solver));
 
-  std::unique_ptr<Parser> p(
-      ParserBuilder(solver, symman.get(), solver->getOptions()).build());
-  p->setInput(Input::newStringInput(Language::LANG_SMTLIB_V2_6,
-                                    string("(get-info ") + s + ")",
-                                    "<internal>"));
+  std::unique_ptr<Parser> p(ParserBuilder(solver, symman.get(), true).build());
+  p->setInput(Input::newStringInput(
+      "LANG_SMTLIB_V2_6", string("(get-info ") + s + ")", "<internal>"));
   assert(p != NULL);
   Command* c = p->nextCommand();
   assert(c != NULL);
index 42b7d41f71110b64585b1797187de61cf62355ae..17d4b963ea9ad2ed4073864eb9b01bbc136cf2df 100644 (file)
@@ -36,7 +36,7 @@ namespace test {
 class TestParserBlackParser : public TestInternal
 {
  protected:
-  TestParserBlackParser(Language lang) : d_lang(lang) {}
+  TestParserBlackParser(const std::string& lang) : d_lang(lang) {}
 
   virtual ~TestParserBlackParser() {}
 
@@ -78,10 +78,10 @@ class TestParserBlackParser : public TestInternal
   void tryGoodInput(const std::string goodInput)
   {
     d_symman.reset(new SymbolManager(d_solver.get()));
-    std::unique_ptr<Parser> parser(ParserBuilder(d_solver.get(), d_symman.get())
-                                       .withOptions(d_solver->getOptions())
-                                       .withInputLanguage(d_lang)
-                                       .build());
+    std::unique_ptr<Parser> parser(
+        ParserBuilder(d_solver.get(), d_symman.get(), true)
+            .withInputLanguage(d_lang)
+            .build());
     parser->setInput(Input::newStringInput(d_lang, goodInput, "test"));
     ASSERT_FALSE(parser->done());
     Command* cmd;
@@ -97,11 +97,11 @@ class TestParserBlackParser : public TestInternal
   void tryBadInput(const std::string badInput, bool strictMode = false)
   {
     d_symman.reset(new SymbolManager(d_solver.get()));
-    std::unique_ptr<Parser> parser(ParserBuilder(d_solver.get(), d_symman.get())
-                                       .withOptions(d_solver->getOptions())
-                                       .withInputLanguage(d_lang)
-                                       .withStrictMode(strictMode)
-                                       .build());
+    std::unique_ptr<Parser> parser(
+        ParserBuilder(d_solver.get(), d_symman.get(), true)
+            .withInputLanguage(d_lang)
+            .withStrictMode(strictMode)
+            .build());
     parser->setInput(Input::newStringInput(d_lang, badInput, "test"));
     ASSERT_THROW(
         {
@@ -119,12 +119,12 @@ class TestParserBlackParser : public TestInternal
   void tryGoodExpr(const std::string goodExpr)
   {
     d_symman.reset(new SymbolManager(d_solver.get()));
-    std::unique_ptr<Parser> parser(ParserBuilder(d_solver.get(), d_symman.get())
-                                       .withOptions(d_solver->getOptions())
-                                       .withInputLanguage(d_lang)
-                                       .build());
+    std::unique_ptr<Parser> parser(
+        ParserBuilder(d_solver.get(), d_symman.get(), true)
+            .withInputLanguage(d_lang)
+            .build());
     parser->setInput(Input::newStringInput(d_lang, goodExpr, "test"));
-    if (d_lang == Language::LANG_SMTLIB_V2_6)
+    if (d_lang == "LANG_SMTLIB_V2_6")
     {
       /* Use QF_LIA to make multiplication ("*") available */
       std::unique_ptr<Command> cmd(
@@ -153,11 +153,11 @@ class TestParserBlackParser : public TestInternal
   void tryBadExpr(const std::string badExpr, bool strictMode = false)
   {
     d_symman.reset(new SymbolManager(d_solver.get()));
-    std::unique_ptr<Parser> parser(ParserBuilder(d_solver.get(), d_symman.get())
-                                       .withOptions(d_solver->getOptions())
-                                       .withInputLanguage(d_lang)
-                                       .withStrictMode(strictMode)
-                                       .build());
+    std::unique_ptr<Parser> parser(
+        ParserBuilder(d_solver.get(), d_symman.get(), true)
+            .withInputLanguage(d_lang)
+            .withStrictMode(strictMode)
+            .build());
     parser->setInput(Input::newStringInput(d_lang, badExpr, "test"));
     setupContext(*parser);
     ASSERT_FALSE(parser->done());
@@ -169,7 +169,7 @@ class TestParserBlackParser : public TestInternal
                  , ParserException);
   }
 
-  Language d_lang;
+  std::string d_lang;
   std::unique_ptr<cvc5::api::Solver> d_solver;
   std::unique_ptr<SymbolManager> d_symman;
 };
@@ -179,7 +179,7 @@ class TestParserBlackParser : public TestInternal
 class TestParserBlackCvCParser : public TestParserBlackParser
 {
  protected:
-  TestParserBlackCvCParser() : TestParserBlackParser(Language::LANG_CVC) {}
+  TestParserBlackCvCParser() : TestParserBlackParser("LANG_CVC") {}
 };
 
 TEST_F(TestParserBlackCvCParser, good_inputs)
@@ -277,10 +277,7 @@ TEST_F(TestParserBlackCvCParser, bad_exprs)
 class TestParserBlackSmt2Parser : public TestParserBlackParser
 {
  protected:
-  TestParserBlackSmt2Parser()
-      : TestParserBlackParser(Language::LANG_SMTLIB_V2_6)
-  {
-  }
+  TestParserBlackSmt2Parser() : TestParserBlackParser("LANG_SMTLIB_V2_6") {}
 };
 
 TEST_F(TestParserBlackSmt2Parser, good_inputs)
index b941a4eda82910ee06dcb42e849af4d431705fb8..1c493e6a21459dc03522564b3ba5e150ce757ad1 100644 (file)
@@ -70,10 +70,10 @@ TEST_F(TestParseBlackParserBuilder, empty_file_input)
   char* filename = mkTemp();
   ASSERT_NE(filename, nullptr);
 
-  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get())
-                                     .withInputLanguage(Language::LANG_CVC)
+  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get(), false)
+                                     .withInputLanguage("LANG_CVC")
                                      .build());
-  parser->setInput(Input::newFileInput(Language::LANG_CVC, filename, false));
+  parser->setInput(Input::newFileInput("LANG_CVC", filename, false));
   checkEmptyInput(parser.get());
 
   remove(filename);
@@ -88,10 +88,10 @@ TEST_F(TestParseBlackParserBuilder, simple_file_input)
   fs << "TRUE" << std::endl;
   fs.close();
 
-  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get())
-                                     .withInputLanguage(Language::LANG_CVC)
+  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get(), false)
+                                     .withInputLanguage("LANG_CVC")
                                      .build());
-  parser->setInput(Input::newFileInput(Language::LANG_CVC, filename, false));
+  parser->setInput(Input::newFileInput("LANG_CVC", filename, false));
   checkTrueInput(parser.get());
 
   remove(filename);
@@ -100,39 +100,39 @@ TEST_F(TestParseBlackParserBuilder, simple_file_input)
 
 TEST_F(TestParseBlackParserBuilder, empty_string_input)
 {
-  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get())
-                                     .withInputLanguage(Language::LANG_CVC)
+  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get(), false)
+                                     .withInputLanguage("LANG_CVC")
                                      .build());
-  parser->setInput(Input::newStringInput(Language::LANG_CVC, "", "foo"));
+  parser->setInput(Input::newStringInput("LANG_CVC", "", "foo"));
   checkEmptyInput(parser.get());
 }
 
 TEST_F(TestParseBlackParserBuilder, true_string_input)
 {
-  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get())
-                                     .withInputLanguage(Language::LANG_CVC)
+  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get(), false)
+                                     .withInputLanguage("LANG_CVC")
                                      .build());
-  parser->setInput(Input::newStringInput(Language::LANG_CVC, "TRUE", "foo"));
+  parser->setInput(Input::newStringInput("LANG_CVC", "TRUE", "foo"));
   checkTrueInput(parser.get());
 }
 
 TEST_F(TestParseBlackParserBuilder, empty_stream_input)
 {
   std::stringstream ss("", std::ios_base::in);
-  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get())
-                                     .withInputLanguage(Language::LANG_CVC)
+  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get(), false)
+                                     .withInputLanguage("LANG_CVC")
                                      .build());
-  parser->setInput(Input::newStreamInput(Language::LANG_CVC, ss, "foo"));
+  parser->setInput(Input::newStreamInput("LANG_CVC", ss, "foo"));
   checkEmptyInput(parser.get());
 }
 
 TEST_F(TestParseBlackParserBuilder, true_stream_input)
 {
   std::stringstream ss("TRUE", std::ios_base::in);
-  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get())
-                                     .withInputLanguage(Language::LANG_CVC)
+  std::unique_ptr<Parser> parser(ParserBuilder(&d_solver, d_symman.get(), false)
+                                     .withInputLanguage("LANG_CVC")
                                      .build());
-  parser->setInput(Input::newStreamInput(Language::LANG_CVC, ss, "foo"));
+  parser->setInput(Input::newStreamInput("LANG_CVC", ss, "foo"));
   checkTrueInput(parser.get());
 }