nitdoc: do not repeat entries in the index.
[nit.git] / src / mmloader.nit
index 04c3a98..5133747 100644 (file)
@@ -16,7 +16,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# This package is used to load a metamodel 
+# This module is used to load a metamodel
 package mmloader
 
 import metamodel
@@ -24,7 +24,7 @@ import opts
 import location
 
 class Message
-special Comparable
+       super Comparable
        redef type OTHER: Message
 
        readable var _location: nullable Location
@@ -38,17 +38,18 @@ special Comparable
        end
 
        redef fun to_s: String do
-               if location == null then
+               var l = location
+               if l == null then
                        return text
                else
-                       return "{location}: {text}"
+                       return "{l}: {text}"
                end
        end
 end
 
 # Global context for tools
 class ToolContext
-special MMContext
+       super MMContext
        # Number of errors
        readable var _error_count: Int = 0
 
@@ -82,6 +83,7 @@ special MMContext
        do
                _messages.add(new Message(l,s))
                _error_count = _error_count + 1
+               if opt_stop_on_first_error.value then check_errors
        end
 
        # Add an error, show errors and quit
@@ -101,6 +103,7 @@ special MMContext
                else
                        _error_count = _error_count + 1
                end
+               if opt_stop_on_first_error.value then check_errors
        end
 
        # Display an info
@@ -147,13 +150,16 @@ special MMContext
        # Option --verbose
        readable var _opt_verbose: OptionCount = new OptionCount("Verbose", "-v", "--verbose")
 
+       # Option --stop-on-first-error
+       readable var _opt_stop_on_first_error: OptionBool = new OptionBool("Stop on first error", "--stop-on-first-error")
+
        # Verbose level
        readable var _verbose_level: Int = 0
 
        init
        do
                super
-               option_context.add_option(opt_warn, opt_path, opt_log, opt_log_dir, opt_only_parse, opt_only_metamodel, opt_help, opt_version, opt_verbose)
+               option_context.add_option(opt_warn, opt_stop_on_first_error, opt_path, opt_log, opt_log_dir, opt_only_parse, opt_only_metamodel, opt_help, opt_version, opt_verbose)
        end
 
        # Parse and process the options given on the command line
@@ -363,7 +369,7 @@ class ModuleLoader
        protected fun parse_file(context: ToolContext, file: IFStream, filename: String, module_name: Symbol, dir: MMDirectory): MODULE is abstract
 
        # Process a parsed module
-       protected fun process_metamodel(context: ToolContext, module: MODULE) is abstract
+       protected fun process_metamodel(context: ToolContext, mod: MODULE) is abstract
 end
 
 redef class MMModule