diff lexer/Token.d @ 126:c3b24e7e8cf8

Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
author Anders Johnsen <skabet@gmail.com>
date Tue, 27 May 2008 10:32:31 +0200
parents 6a5f745d351c
children 2be29b296081
line wrap: on
line diff
--- a/lexer/Token.d	Sun May 25 21:13:56 2008 +0200
+++ b/lexer/Token.d	Tue May 27 10:32:31 2008 +0200
@@ -64,7 +64,47 @@
      */
     bool isAssignment()
     {
-        return type == Tok.Assign;
+        return type >= Tok.Assign && type <= Tok.PercentAssign;
+    }
+
+    /**
+      Returns true for all attributes( public, static, private...)
+     */
+    bool isAttribute()
+    {
+        return type >= Tok.Public && type <= Tok.Auto;
+    }
+
+    /**
+      just a shortcut to avoid `token.type == tok.Switch`.
+     */
+    bool isSwitch()
+    {
+        return type == Tok.Switch;
+    }
+
+    /**
+      just a shortcut to avoid `token.type == tok.While`.
+     */
+    bool isWhile()
+    {
+        return type == Tok.While;
+    }
+
+    /**
+      just a shortcut to avoid `token.type == tok.If`.
+     */
+    bool isIf()
+    {
+        return type == Tok.If;
+    }
+
+    /**
+      just a shortcut to avoid `token.type == tok.Return`.
+     */
+    bool isReturn()
+    {
+        return type == Tok.Return;
     }
 
     /**
@@ -90,11 +130,20 @@
     /* Basic types */
     Identifier,
     Integer,
+    String,
 
     /* Basic operators */
     Assign,
-    Plus, Minus,
-    Star, Slash, Percent,
+    PlusAssign,
+    MinusAssign,
+    StarAssign,
+    SlashAssign,
+    PercentAssign,
+    Plus, 
+    Minus, 
+    Star, 
+    Slash, 
+    Percent, 
     LeftShift, RightShift, UnsignedRightShift,
     Comma,
 
@@ -130,17 +179,38 @@
 
     Void,
 
-    Struct,
+    Struct, Function, Delegate, Class,
+    Interface, Union, Typedef, Typeid,
+    Typeof, Sizeof, Alias,
 
     If, Else,
     While,
-    Switch, Case, Default,
-    Return, Cast,
-
-    String,
+    Switch, Case, Default, Break,
+    Return, Cast, 
 
     Module, Import,
 
+    /* Attributes */
+    Public, Private, Package, Protected, Export,
+    Static,
+    Final,
+    Const,
+    Abstract,
+    Override,
+    Depracted,
+    Auto,
+
+    Align,
+
+    Asm,
+
+    In, Out, Body, 
+    
+    Assert, Throw, Try, Catch, Finally,
+
+            
+
+
 }
 
 /**
@@ -180,10 +250,15 @@
         Tok.Dot:"Dot",
         Tok.Assign:"Assign",
         Tok.Plus:"Plus",
+        Tok.PlusAssign:"PlusAssign",
         Tok.Minus:"Minus",
+        Tok.MinusAssign:"MinusAssign",
         Tok.Star:"Star",
+        Tok.StarAssign:"StarAssign",
         Tok.Slash:"Slash",
+        Tok.SlashAssign:"SlashAssign",
         Tok.Percent:"Percent",
+        Tok.PercentAssign:"PercentAssign",
         Tok.LeftShift:"LeftShift",
         Tok.RightShift:"RightShift",
         Tok.UnsignedRightShift:"UnsignedRightShift",
@@ -201,6 +276,19 @@
         Tok.Cast:"Cast",
         Tok.Module:"Module",
         Tok.Import:"Import",
-        Tok.String:"String"
+        Tok.String:"String",
+        Tok.Public:"Public",
+        Tok.Private:"Private",
+        Tok.Protected:"Protected",
+        Tok.Package:"Package",
+        Tok.Export:"Export",
+        Tok.Static:"Static",
+        Tok.Final:"Finale",
+        Tok.Public:"Public",
+        Tok.Const:"Const",
+        Tok.Abstract:"Abstract",
+        Tok.Override:"Override",
+        Tok.Depracted:"Depracted",
+        Tok.Auto:"Auto"
     ];
 }