diff trunk/src/dil/Lexer.d @ 396:0a4619735ce9

Applied fixes to Lexer, Parser and other classes. Added asserts to cmd.Generate.syntaxToDoc(). Added if-statements to Declaration, Expression and Statement classes to check for null variables. Fixed octal number scanner in Lexer.scanNumber(). Fixes in Parser: skip comma in parseBaseClasses(); changed || to &&; added 'qword' to list of asm type prefixes.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 21 Sep 2007 12:47:47 +0200
parents fce1e6133dac
children c99f8aeb7b4a
line wrap: on
line diff
--- a/trunk/src/dil/Lexer.d	Wed Sep 19 23:12:20 2007 +0300
+++ b/trunk/src/dil/Lexer.d	Fri Sep 21 12:47:47 2007 +0200
@@ -1335,24 +1335,33 @@
     case 'x','X':
       goto LscanHex;
     case 'b','B':
-      goto LscanBin;
+      goto LscanBinary;
     case 'L':
       if (p[1] == 'i')
-        goto LscanReal;
-      break;
+        goto LscanReal; // 0Li
+      break; // 0L
     case '.':
       if (p[1] == '.')
-        break;
+        break; // 0..
+      // 0.
     case 'i','f','F', // Imaginary and float literal suffixes.
          'e', 'E':    // Float exponent.
       goto LscanReal;
     default:
-      if (*p == '_' || isoctal(*p))
-        goto LscanOct;
+      if (*p == '_')
+        goto LscanOctal; // 0_
+      else if (isdigit(*p))
+      {
+        if (*p == '8' || *p == '9')
+          goto Loctal_hasDecimalDigits; // 08 or 09
+        else
+          goto Loctal_enter_loop; // 0[0-7]
+      }
     }
 
     // Number 0
     assert(p[-1] == '0');
+    assert(*p != '_' && !isdigit(*p));
     assert(ulong_ == 0);
     isDecimal = true;
     goto Lfinalize;
@@ -1440,7 +1449,7 @@
 
     goto Lfinalize;
 
-  LscanBin:
+  LscanBinary:
     assert(digits == 0);
     assert(*p == 'b');
     while (1)
@@ -1471,33 +1480,31 @@
     assert( !(*p == '0' || *p == '1' || *p == '_') );
     goto Lfinalize;
 
-  LscanOct:
-    assert(*p == '_' || isoctal(*p));
-    if (*p != '_')
-      goto Lenter_loop_oct;
+  LscanOctal:
+    assert(*p == '_');
     while (1)
     {
       if (*++p == '_')
         continue;
       if (!isoctal(*p))
         break;
-    Lenter_loop_oct:
+    Loctal_enter_loop:
       if (ulong_ < ulong.max/2 || (ulong_ == ulong.max/2 && *p <= '1'))
       {
         ulong_ *= 8;
         ulong_ += *p - '0';
-        ++p;
         continue;
       }
       // Overflow: skip following digits.
       overflow = true;
-      while (isdigit(*++p)) {}
+      while (isoctal(*++p)) {}
       break;
     }
 
     bool hasDecimalDigits;
     if (isdigit(*p))
     {
+    Loctal_hasDecimalDigits:
       hasDecimalDigits = true;
       while (isdigit(*++p)) {}
     }