* ILTokenizingExpcetion.cs: New exception thrown by the tokenizer
authorJackson Harper <jackson@novell.com>
Thu, 10 Jun 2004 21:01:19 +0000 (21:01 -0000)
committerJackson Harper <jackson@novell.com>
Thu, 10 Jun 2004 21:01:19 +0000 (21:01 -0000)
if any tokenizing errors occur.
* ILTokenizer.cs:
* NumberHelper.cs: Use the new exception.

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

mcs/ilasm/scanner/ChangeLog
mcs/ilasm/scanner/ILTokenizer.cs
mcs/ilasm/scanner/ILTokenizingException.cs [new file with mode: 0644]
mcs/ilasm/scanner/NumberHelper.cs

index 23bc23c7048430cea7745bad9be5460a98cfce77..f124495e9404a9d581ba0f9039eb2876ec8653f3 100644 (file)
@@ -1,3 +1,10 @@
+2004-06-10  Jackson Harper  <jackson@ximian.com>
+
+       * ILTokenizingExpcetion.cs: New exception thrown by the tokenizer
+       if any tokenizing errors occur.
+       * ILTokenizer.cs:
+       * NumberHelper.cs: Use the new exception.
+       
 2004-06-04  Jackson Harper  <jackson@ximian.com>
 
        * ILTokenizer.cs: Handle comments first, handle whitespace in hex
index 2be062c64ecaaceed4a9f040105b67803db0036d..c3f7841502cc19679fde92b48b89fdbd88df4165 100644 (file)
@@ -112,12 +112,13 @@ namespace Mono.ILASM {
                                         }\r
 \r
                                         if (!is_hex (ch))\r
-                                                throw new Exception ("Invalid hex value. '" + (char) ch + "'."); // yeah proper error reporting would be great\r
+                                                throw new ILTokenizingException (reader.Location, ((char) ch).ToString ());\r
                                         hx += (char) ch;\r
                                         if (is_hex (reader.Peek ()))\r
                                                 hx += (char) reader.Read ();\r
                                         else if (!Char.IsWhiteSpace ((char) reader.Peek ()) && reader.Peek () != ')')\r
-                                                throw new Exception ("Invalid hex value. '" + (char) reader.Peek () + "'.");\r
+                                                throw new ILTokenizingException (reader.Location,\r
+                                                                ((char) reader.Peek ()).ToString ());\r
                                         res.token = Token.HEXBYTE;\r
                                         res.val = Byte.Parse (hx, NumberStyles.HexNumber);\r
 \r
diff --git a/mcs/ilasm/scanner/ILTokenizingException.cs b/mcs/ilasm/scanner/ILTokenizingException.cs
new file mode 100644 (file)
index 0000000..a8284b4
--- /dev/null
@@ -0,0 +1,29 @@
+//
+// Mono.ILASM.ILTokenizingException
+//
+// Author(s):
+//  Jackson Harper (jackson@ximian.com)
+//
+// Copyright 2004 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+        public class ILTokenizingException : Exception {
+
+                public readonly Location Location;
+                public readonly string Token;
+
+                public ILTokenizingException (Location location, string token)
+                {
+                        Location = location;
+                        Token = token;
+                }
+        }
+
+}
+
+
index 0beb7c234858ae694ed64285ae5eb9b0fb4ad9b7..385f5a66b948f6b1b277a0280c9625b123e2191a 100644 (file)
@@ -86,7 +86,7 @@ namespace Mono.ILASM {
 \r
                                 if (is_e (ch)) {\r
                                         if (is_real)\r
-                                                throw new Exception ("Bad number format, multiples e's found.");\r
+                                                throw new ILTokenizingException (reader.Location, num_builder.ToString ());\r
 \r
                                         is_real = true;\r
                                 }\r
@@ -137,7 +137,7 @@ namespace Mono.ILASM {
                                 reader.RestoreLocation ();\r
                                 num = String.Empty;\r
                                 Reset ();\r
-                                throw new ILSyntaxError ("Bad number format! '" + num_builder + "'");\r
+                                throw new ILTokenizingException (reader.Location, num_builder.ToString ());\r
                         }\r
                         return num;\r
                 }\r
@@ -155,12 +155,12 @@ namespace Mono.ILASM {
 \r
                         ch = reader.Read ();\r
                         if (ch != '0')\r
-                                throw new Exception ("Bad hex number format, first char is not 0");\r
+                                throw new ILTokenizingException (reader.Location, ((char) ch).ToString ());\r
 \r
                         ch = reader.Read ();\r
 \r
                         if (ch != 'x' && ch != 'X')\r
-                                throw new Exception ("Bad hex number format, second char is not x or X");\r
+                                throw new ILTokenizingException (reader.Location, "0" + (char) ch);\r
 \r
                         do {\r
                                 ch = reader.Read ();\r
@@ -171,7 +171,7 @@ namespace Mono.ILASM {
                                         break;\r
 \r
                                 if (num_builder.Length == 32)\r
-                                        throw new Exception ("Number too big.");\r
+                                        throw new ILTokenizingException (reader.Location, num_builder.ToString ());\r
 \r
                         } while (ch != -1);\r
 \r
@@ -192,7 +192,7 @@ namespace Mono.ILASM {
                                 reader.RestoreLocation ();\r
                                 num = String.Empty;\r
                                 Reset ();\r
-                                throw new ILSyntaxError ("Bad hex number format! '" + tnum + "'");\r
+                                throw new ILTokenizingException (reader.Location, tnum);\r
                         }\r
                         return num;\r
                 }\r