changeset 36:3c7210a722f7

- Added code for parsing LorEorG, LorG, LessEqual, LessThan, LShiftAssign and LShift tokens. - Added comments to case statements.
author aziz
date Tue, 26 Jun 2007 08:36:00 +0000
parents c470b9356e35
children 7f3bcb97d017
files trunk/src/Lexer.d trunk/src/Token.d
diffstat 2 files changed, 47 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/Lexer.d	Tue Jun 26 07:57:00 2007 +0000
+++ b/trunk/src/Lexer.d	Tue Jun 26 08:36:00 2007 +0000
@@ -387,9 +387,36 @@
 
       if (c == '`')
         return scanRawStringLiteral(t);
-
-      switch(c)
+      switch (c)
       {
+      case '<': /* <  <=  <>  <>=  <<  <<= */
+        c = *++p;
+        switch (c)
+        {
+        case '=':
+          t.type = TOK.LessEqual;
+          goto Lcommon;
+        case '<':
+          if (p[1] == '=') {
+            ++p;
+            t.type = TOK.LShiftAssign;
+          }
+          else
+            t.type = TOK.LShift;
+          goto Lcommon;
+        case '>':
+          if (p[1] == '=') {
+            ++p;
+            t.type = TOK.LorEorG;
+          }
+          else
+            t.type = TOK.LorG;
+          goto Lcommon;
+        default:
+          t.type = TOK.LessThan;
+          goto Lcommon2;
+        }
+        assert(0);
       case '!':
         c = *++p;
         switch (c)
@@ -431,7 +458,7 @@
           goto Lcommon2;
         }
         assert(0);
-      case '.':
+      case '.': /* .  ..  ... */
         if (p[1] == '.')
         {
           ++p;
@@ -445,7 +472,7 @@
         else
           t.type = TOK.Dot;
         goto Lcommon;
-      case '|':
+      case '|': /* |  ||  |= */
         c = *++p;
         if (c == '=')
           t.type = TOK.OrAssign;
@@ -456,7 +483,7 @@
           goto Lcommon2;
         }
         goto Lcommon;
-      case '&':
+      case '&': /* &  &&  &= */
         c = *++p;
         if (c == '=')
           t.type = TOK.AndAssign;
@@ -467,7 +494,7 @@
           goto Lcommon2;
         }
         goto Lcommon;
-      case '+':
+      case '+': /* +  ++  += */
         c = *++p;
         if (c == '=')
           t.type = TOK.PlusAssign;
@@ -478,7 +505,7 @@
           goto Lcommon2;
         }
         goto Lcommon;
-      case '-':
+      case '-': /* -  --  -= */
         c = *++p;
         if (c == '=')
           t.type = TOK.MinusAssign;
@@ -489,7 +516,7 @@
           goto Lcommon2;
         }
         goto Lcommon;
-      case '=':
+      case '=': /* =  == */
         if (p[1] == '=') {
           ++p;
           t.type = TOK.Equal;
@@ -497,7 +524,7 @@
         else
           t.type = TOK.Assign;
         goto Lcommon;
-      case '~':
+      case '~': /* ~  ~= */
          if (p[1] == '=') {
            ++p;
            t.type = TOK.CatAssign;
@@ -505,7 +532,7 @@
          else
            t.type = TOK.Tilde;
          goto Lcommon;
-      case '*':
+      case '*': /* *  *= */
          if (p[1] == '=') {
            ++p;
            t.type = TOK.MulAssign;
@@ -513,7 +540,7 @@
          else
            t.type = TOK.Mul;
          goto Lcommon;
-      case '^':
+      case '^': /* ^  ^= */
          if (p[1] == '=') {
            ++p;
            t.type = TOK.XorAssign;
@@ -521,7 +548,7 @@
          else
            t.type = TOK.Xor;
          goto Lcommon;
-      case '%':
+      case '%': /* %  %= */
          if (p[1] == '=') {
            ++p;
            t.type = TOK.ModAssign;
--- a/trunk/src/Token.d	Tue Jun 26 07:57:00 2007 +0000
+++ b/trunk/src/Token.d	Tue Jun 26 08:36:00 2007 +0000
@@ -17,7 +17,8 @@
   String,
   Character,
   Number,
-/* Braces */
+
+  // Brackets
   LParen,
   RParen,
   LBracket,
@@ -27,14 +28,20 @@
 
   Dot, Slice, Ellipses,
 
+  // Floating point operators
   Unordered,
   UorE,
   UorG,
   UorGorE,
   UorL,
   UorLorE,
+  LorEorG,
+  LorG,
 
+  // Normal operators
   Assign, Equal, NotEqual, Not,
+  LessEqual, LessThan,
+  LShiftAssign, LShift,
   OrAssign, OrLogical, OrBinary,
   AndAssign, AndLogical, AndBinary,
   PlusAssign, PlusPlus, Plus,