From 4f1e73b93e751c557f48131c403bb5c593f00966 Mon Sep 17 00:00:00 2001
From: Philippe Suter <philippe.suter@gmail.com>
Date: Wed, 23 Jun 2010 13:28:44 +0000
Subject: [PATCH]

---
 src/funcheck/AnalysisComponent.scala | 11 +++++++++--
 src/funcheck/FunCheckPlugin.scala    |  3 +++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/funcheck/AnalysisComponent.scala b/src/funcheck/AnalysisComponent.scala
index bf0d8dd67..1b0c26704 100644
--- a/src/funcheck/AnalysisComponent.scala
+++ b/src/funcheck/AnalysisComponent.scala
@@ -33,8 +33,15 @@ class AnalysisComponent(val global: Global, val pluginInstance: FunCheckPlugin)
       fresh = unit.fresh
 
       val prog: purescala.Definitions.Program = extractCode(unit)
-      println("Extracted program for " + unit + ": ")
-      println(prog)
+      if(pluginInstance.stopAfterExtraction) {
+        println("Extracted program for " + unit + ": ")
+        println(prog)
+        println("Extraction complete. Now terminating the compiler process.")
+        exit(0)
+      } else {
+        println("Extracted program for " + unit + ": ")
+        println(prog)
+      }
 
       println("Starting analysis.")
       val analysis = new purescala.Analysis(prog)
diff --git a/src/funcheck/FunCheckPlugin.scala b/src/funcheck/FunCheckPlugin.scala
index 63ecdb8eb..be396d0a1 100644
--- a/src/funcheck/FunCheckPlugin.scala
+++ b/src/funcheck/FunCheckPlugin.scala
@@ -12,11 +12,13 @@ class FunCheckPlugin(val global: Global) extends Plugin {
   val description = "Static analysis for Scala by LARA."
 
   var stopAfterAnalysis: Boolean = true
+  var stopAfterExtraction: Boolean = false
 
   /** The help message displaying the options for that plugin. */
   override val optionsHelp: Option[String] = Some(
     "  -P:funcheck:uniqid             When pretty-printing funcheck trees, show identifiers IDs" + "\n" +
     "  -P:funcheck:with-code          Allows the compiler to keep running after the static analysis" + "\n" +
+    "  -P:funcheck:parse              Checks only whether the program is valid PureScala" + "\n" +
     "  -P:funcheck:extensions=ex1:... Specifies a list of qualified class names of extensions to be loaded"
   )
 
@@ -26,6 +28,7 @@ class FunCheckPlugin(val global: Global) extends Plugin {
       option match {
         case "with-code" =>                      stopAfterAnalysis = false
         case "uniqid"    =>                      purescala.Settings.showIDs = true
+        case "parse"     =>                      stopAfterExtraction = true
         case s if s.startsWith("extensions=") => purescala.Settings.extensionNames = s.substring("extensions=".length, s.length)
         case _ => error("Invalid option: " + option)
       }
-- 
GitLab