tools: errors and warnings need Location
authorJean-Sebastien Gelinas <calestar@gmail.com>
Mon, 13 Jul 2009 14:05:59 +0000 (10:05 -0400)
committerJean Privat <jean@pryen.org>
Thu, 23 Jul 2009 22:43:43 +0000 (18:43 -0400)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

src/mmloader.nit
src/nitc.nit
src/syntax/mmbuilder.nit
src/syntax/syntax.nit
src/syntax/syntax_base.nit

index 11eb90a..246c50d 100644 (file)
@@ -38,14 +38,14 @@ special MMContext
        end
 
        # Display an error
-       fun error(s: String)
+       fun error(l: nullable Location, s: String)
        do
                stderr.write("{s}\n")
                _error_count = _error_count + 1
        end
 
        # Display a warning
-       fun warning(s: String)
+       fun warning(l: nullable Location, s: String)
        do
                if _opt_warn.value == 0 then return
                stderr.write("{s}\n")
@@ -160,7 +160,7 @@ special MMContext
                                var full_name = dir.full_name_for(module_name)
                                if _processing_modules.has(full_name) then
                                        # FIXME: Generate better error
-                                       error("Error: Dependency loop for module {full_name}")
+                                       error(null, "Error: Dependency loop for module {full_name}")
                                        check_errors
                                end
                                _processing_modules.add(full_name)
@@ -199,7 +199,7 @@ special MMContext
                end
 
                if not filename.file_exists then
-                       error("Error: File {filename} not found.")
+                       error(null, "Error: File {filename} not found.")
                        check_errors
                        abort
                end
@@ -208,7 +208,7 @@ special MMContext
                var m = try_to_load(module_name, dir)
                if m != null then return m
 
-               error("Error: {filename} is not a NIT source module.")
+               error(null, "Error: {filename} is not a NIT source module.")
                check_errors
                abort
        end
@@ -232,7 +232,7 @@ special MMContext
                        if m != null then return m
                end
                # FIXME: Generate better error
-               error("Error: No ressource found for module {module_name}.")
+               error(null, "Error: No ressource found for module {module_name}.")
                check_errors
                abort
        end
@@ -301,7 +301,7 @@ class ModuleLoader
                end
 
                if file.eof then
-                       context.error("Error: Problem in opening file {filename}")
+                       context.error(null, "Error: Problem in opening file {filename}")
                        context.check_errors
                end
                var m = parse_file(context, file, filename, module_name, dir)
index 2f544bd..3e962d2 100644 (file)
@@ -70,7 +70,7 @@ special AbstractCompiler
                                if dir.file_exists then clibdir = dir
                        end
                        if clibdir == null then
-                               error("Error: Cannot locate NIT C library directory. Uses --clibdir or envvar NIT_DIR.")
+                               error(null, "Error: Cannot locate NIT C library directory. Uses --clibdir or envvar NIT_DIR.")
                                check_errors
                        end
                end
@@ -86,7 +86,7 @@ special AbstractCompiler
                                if dir.file_exists then bindir = dir
                        end
                        if bindir == null then
-                               error("Error: Cannot locate NIT tools directory. Uses --bindir or envvar NIT_DIR.")
+                               error(null, "Error: Cannot locate NIT tools directory. Uses --bindir or envvar NIT_DIR.")
                                check_errors
                        end
                end
index 8e8489d..942dea7 100644 (file)
@@ -450,7 +450,7 @@ redef class AModule
                end
                if no_import != null then
                        if not module_names_to_import.is_empty then
-                               tc.error("{no_import.locate}: Error: Top modules cannot import other modules.")
+                               tc.error(null, "{no_import.locate}: Error: Top modules cannot import other modules.")
                        end
                else if module_names_to_import.is_empty then
                        var stdname = once "standard".to_symbol
index 0e18983..d35ad6a 100644 (file)
@@ -37,7 +37,7 @@ special ModuleLoader
                if node_tree.n_base == null then
                        var err = node_tree.n_eof
                        assert err isa PError
-                       context.error("{err.locate}: {err.message}")
+                       context.error(err.location, "{err.locate}: {err.message}")
                        context.check_errors
                end
                var node_module = node_tree.n_base
index 23d9973..3f40293 100644 (file)
@@ -355,13 +355,13 @@ special Visitor
        # Display an error for a given syntax node
        fun error(n: nullable PNode, s: String)
        do
-               _tc.error("{locate(n)}: {s}")
+               _tc.error(n.location, "{locate(n)}: {s}")
        end
 
        # Display a warning for a given syntax node
        fun warning(n: nullable PNode, s: String)
        do
-               _tc.warning("{locate(n)}: {s}")
+               _tc.warning(n.location, "{locate(n)}: {s}")
        end
 
        #