changeset 26:c3d7373db241

- Added code for parsing Assign and Equal tokens. - Inserted gotos to single character tokens to avoid incrementing the pointer 'p'.
author aziz
date Sun, 24 Jun 2007 12:26:02 +0000
parents 9c866208b3f6
children 43b6bf56f0e9
files trunk/src/Lexer.d trunk/src/Token.d
diffstat 2 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/Lexer.d	Sun Jun 24 11:35:04 2007 +0000
+++ b/trunk/src/Lexer.d	Sun Jun 24 12:26:02 2007 +0000
@@ -281,8 +281,10 @@
           t.type = TOK.OrAssign;
         else if (c == '|')
           t.type = TOK.OrLogical;
-        else
+        else {
           t.type = TOK.OrBinary;
+          goto Lcommon2;
+        }
         goto Lcommon;
       case '&':
         c = *++p;
@@ -290,8 +292,10 @@
           t.type = TOK.AndAssign;
         else if (c == '&')
           t.type = TOK.AndLogical;
-        else
+        else {
           t.type = TOK.AndBinary;
+          goto Lcommon2;
+        }
         goto Lcommon;
       case '+':
         c = *++p;
@@ -299,8 +303,10 @@
           t.type = TOK.PlusAssign;
         else if (c == '+')
           t.type = TOK.PlusPlus;
-        else
+        else {
           t.type = TOK.Plus;
+          goto Lcommon2;
+        }
         goto Lcommon;
       case '-':
         c = *++p;
@@ -308,8 +314,18 @@
           t.type = TOK.MinusAssign;
         else if (c == '-')
           t.type = TOK.MinusMinus;
+        else {
+          t.type = TOK.Minus;
+          goto Lcommon2;
+        }
+        goto Lcommon;
+      case '=':
+        if (p[1] == '=') {
+          ++p;
+          t.type = TOK.Equal;
+        }
         else
-          t.type = TOK.Minus;
+          t.type = TOK.Assign;
         goto Lcommon;
       case '(':
         t.type = TOK.LParen;
@@ -343,9 +359,9 @@
         goto Lcommon;
       case '$':
         t.type = TOK.Dollar;
-        goto Lcommon;
       Lcommon:
         ++p;
+      Lcommon2:
         t.end = p;
         return;
       default:
--- a/trunk/src/Token.d	Sun Jun 24 11:35:04 2007 +0000
+++ b/trunk/src/Token.d	Sun Jun 24 12:26:02 2007 +0000
@@ -28,6 +28,7 @@
 
   Dot, Slice, Ellipses,
 
+  Assign, Equal,
   OrAssign, OrLogical, OrBinary,
   AndAssign, AndLogical, AndBinary,
   PlusAssign, PlusPlus, Plus,