From e05a9cccac227b95f1d1ec3c972c0ff77ab301dd Mon Sep 17 00:00:00 2001
From: Manos Koukoutos <emmanouil.koukoutos@epfl.ch>
Date: Tue, 28 Apr 2015 10:19:34 +0200
Subject: [PATCH] Handle malformed options

---
 src/main/scala/leon/LeonOption.scala | 2 +-
 src/main/scala/leon/Main.scala       | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/main/scala/leon/LeonOption.scala b/src/main/scala/leon/LeonOption.scala
index e8b653a5b..06269e696 100644
--- a/src/main/scala/leon/LeonOption.scala
+++ b/src/main/scala/leon/LeonOption.scala
@@ -101,7 +101,7 @@ object OptionsHelpers {
   def nameValue(s: String) = s match {
     case matcher(name, value) => (name, value)
     case matcherWithout(name) => (name, "")
-    case _ => sys.error("") // FIXME
+    case _ => throw new IllegalArgumentException
   }
 
   // helper for options that include patterns
diff --git a/src/main/scala/leon/Main.scala b/src/main/scala/leon/Main.scala
index 5035e0e36..7c8098efb 100644
--- a/src/main/scala/leon/Main.scala
+++ b/src/main/scala/leon/Main.scala
@@ -95,7 +95,14 @@ object Main {
     val files = args.filterNot(_.startsWith("-")).map(new java.io.File(_))
 
     val leonOptions: Set[LeonOption[Any]] = options.map { opt =>
-      val (name, value) = OptionsHelpers.nameValue(opt)
+      val (name, value) = try {
+        OptionsHelpers.nameValue(opt)
+      } catch {
+        case _ : IllegalArgumentException =>
+          initReporter.fatalError(
+            s"Malformed option $opt. Options should have the form --name or --name=value"
+          )
+      }
       // Find respective LeonOptionDef, or report an unknown option
       val df = allOptions.find(_. name == name).getOrElse{
         initReporter.error(s"Unknown option: $name")
-- 
GitLab