* Driver.cs: Handle tokenization errors with the correct error
authorJackson Harper <jackson@novell.com>
Thu, 10 Jun 2004 21:00:18 +0000 (21:00 -0000)
committerJackson Harper <jackson@novell.com>
Thu, 10 Jun 2004 21:00:18 +0000 (21:00 -0000)
message.
* Report.cs: Print error messages properly. Add an extra \n after
the assemble file message.
* ilasm.exe.sources: Add new exception, remove old one.

svn path=/trunk/mcs/; revision=29240

mcs/ilasm/ChangeLog
mcs/ilasm/Driver.cs
mcs/ilasm/Report.cs
mcs/ilasm/ilasm.exe.sources

index 03b681be5f701f3987a62d619de13a2a6c9c92b2..b2a58d21e2cafb08f0be2e1b248df118530d2ef5 100644 (file)
@@ -1,3 +1,11 @@
+2004-06-10  Jackson Harper  <jackson@ximian.com>
+
+       * Driver.cs: Handle tokenization errors with the correct error
+       message.
+       * Report.cs: Print error messages properly. Add an extra \n after
+       the assemble file message.
+       * ilasm.exe.sources: Add new exception, remove old one.
+       
 2004-06-04  Jackson Harper  <jackson@ximian.com>
 
        * Driver.cs: Do everything using the invariant culture.
index 177cf3e5b8d9d2ea37db29e398ff8250491ea2b3..d71f205cade42fefde08243b951f8d064ef54523 100644 (file)
@@ -29,7 +29,11 @@ namespace Mono.ILASM {
 
                         DriverMain driver = new DriverMain (args);
                         try {
-                                driver.Run ();
+                                if (!driver.Run ()) {
+                                        Console.WriteLine ();
+                                        Console.WriteLine ("***** FAILURE *****");
+                                        return 1;
+                                }
                         } catch (Exception e) {
                                 Console.WriteLine (e);
                                 Console.WriteLine ("Error while compiling.");
@@ -61,7 +65,7 @@ namespace Mono.ILASM {
                                 report = new Report (quiet);
                         }
 
-                        public void Run ()
+                        public bool Run ()
                         {
                                 try {
                                         if (il_file_list.Count == 0)
@@ -72,12 +76,16 @@ namespace Mono.ILASM {
                                         foreach (string file_path in il_file_list)
                                                 ProcessFile (file_path);
                                         if (scan_only)
-                                                return;
+                                                return true;
 
+                                        if (report.ErrorCount > 0)
+                                                return false;
                                         codegen.Write ();
                                 } catch {
-                                        throw;
+                                        return false;
                                 }
+
+                                return true;
                         }
 
                         private void ProcessFile (string file_path)
@@ -114,6 +122,9 @@ namespace Mono.ILASM {
                                                                 new yydebug.yyDebugSimple ());
                                         else
                                                 parser.yyparse (new ScannerAdapter (scanner),  null);
+                                } catch (ILTokenizingException ilte) {
+                                        report.Error (file_path + "(" + ilte.Location.line + ") : error : " +
+                                                        "syntax error at token '" + ilte.Token + "'.");
                                 } catch {
                                         Console.WriteLine ("Error at: " + scanner.Reader.Location);
                                         throw;
index 4d2d98fb41b84a3fc7373b8cd04ce2249aa7c50e..1d6d7718a36dbbb94ada805f32eee6e82553b389 100644 (file)
@@ -42,12 +42,13 @@ namespace Mono.ILASM {
 
                         Console.WriteLine ("Assembling '{0}' , {1}, to {2} --> '{3}'", file,
                                            GetListing (listing), target, output);
+                        Console.WriteLine ();
                 }
 
                 public void Error (string message)
                 {
                         error_count++;
-                        Console.WriteLine ("Error: " + message);
+                        Console.WriteLine (message);
                 }
 
                 private string GetListing (string listing)
index 5f92577067ad175f6dd2dc85d914f30dfed274a8..1ce255355dfa805a1ec55d4bc2ff8c4d3b901157 100644 (file)
@@ -61,7 +61,7 @@ codegen/ModifiableType.cs
 codegen/Sentinel.cs
 parser/ScannerAdapter.cs
 scanner/ILReader.cs
-scanner/ILSyntaxError.cs
+scanner/ILTokenizingException.cs
 scanner/ILTables.cs
 scanner/ILToken.cs
 scanner/ILTokenizer.cs