Author: manjula
Date: 2005-03-30 22:51:33 -0500 (Wed, 30 Mar 2005)
New Revision: 42412

Modified:
   trunk/mcs/mbas/ChangeLog
   trunk/mcs/mbas/mb-tokenizer.cs
Log:
Support declaration of decimal numbers with no digits before point


Modified: trunk/mcs/mbas/ChangeLog
===================================================================
--- trunk/mcs/mbas/ChangeLog    2005-03-31 02:32:49 UTC (rev 42411)
+++ trunk/mcs/mbas/ChangeLog    2005-03-31 03:51:33 UTC (rev 42412)
@@ -1,3 +1,6 @@
+2005-03-31 Manjula GHM <[EMAIL PROTECTED]>
+       *mb-tokenizer.cs: Support declaration of decimal numbers with no digits 
before point like '.52' instead of '0.52'
+
 2005-03-29 Manjula GHM <[EMAIL PROTECTED]>
        *assign.cs: Disallow New Date assignment with types other than date and 
object type
 

Modified: trunk/mcs/mbas/mb-tokenizer.cs
===================================================================
--- trunk/mcs/mbas/mb-tokenizer.cs      2005-03-31 02:32:49 UTC (rev 42411)
+++ trunk/mcs/mbas/mb-tokenizer.cs      2005-03-31 03:51:33 UTC (rev 42412)
@@ -2,7 +2,7 @@
 // Mono.MonoBASIC.Tokenizer.cs: The Tokenizer for the MonoBASIC compiler
 //
 // Author: A Rafael D Teixeira ([EMAIL PROTECTED])
-//        
+//      : Manjula GHM ([EMAIL PROTECTED])  
 // Based on cs-tokenizer.cs by Miguel de Icaza ([EMAIL PROTECTED])
 //
 // Licensed under the terms of the GNU GPL
@@ -498,7 +498,6 @@
                        
                        if (c != -1)
                                number.Append ((char) c);
-                       
                        while ((d = peekChar ()) != -1){
                                if (Char.IsDigit ((char)d)){
                                        number.Append ((char) d);
@@ -662,12 +661,14 @@
                        bool is_real = false;
                        number = new StringBuilder ();
                        int type;
+                       bool non_prefixdecimal = false; //To capture decimals 
like .50
 
                        number.Length = 0;
 
                        if (Char.IsDigit ((char)c)){
                                decimal_digits (c);
-                               c = peekChar ();
+                               c = peekChar ();        
+                               non_prefixdecimal = true;
                        }
 
                        //
@@ -675,11 +676,13 @@
                        // "1.1" vs "1.ToString()" (LITERAL_SINGLE vs NUMBER 
DOT IDENTIFIER)
                        //
                        if (c == '.'){
+                               if (non_prefixdecimal == false)
+                                        putback ('.');
                                if (decimal_digits (getChar())){
                                        is_real = true;
                                        c = peekChar ();
                                } else {
-                                       putback ('.');
+                       //              putback ('.');
                                        number.Length -= 1;
                                        val = 
System.Int64.Parse(number.ToString());
                                        return integer_type_suffix('.');
@@ -731,6 +734,7 @@
                                return putback_char;
                        return reader.Peek ();
                }
+               
 
                void putback (int c)
                {
@@ -943,6 +947,14 @@
                                }
                        
                                // handle numeric literals
+
+                               if (Char.IsDigit ((char) c))
+                                {
+                                        cant_have_a_type_character = true;
+                                        tokens_seen = true;
+                                        return is_number (c);
+                                }
+
                                if (c == '.')
                                {
                                        cant_have_a_type_character = true;
@@ -951,14 +963,6 @@
                                                return is_number (c);
                                        return Token.DOT;
                                }
-                               
-                               if (Char.IsDigit ((char) c))
-                               {
-                                       cant_have_a_type_character = true;
-                                       tokens_seen = true;
-                                       return is_number (c);
-                               }
-
                                if ((t = is_punct ((char)c, ref doread)) != 
Token.ERROR) {
                                        cant_have_a_type_character = true;
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to