diff lexer/Token.d @ 88:eb5b2c719a39 new_gen

Major change to locations, tokens and expressions. A location (now SourceLocation or SLoc) is only 32 bit in size - disadvantage is that it can't find its own text. You have to go through the new SourceManager to do that. This has caused changes to a lot of stuff and removal of DataSource and the old Location Additionally Exp has gotten some location stuff, so we can give proper error messages. Not in Decl and Stmt yet, but thats coming too.
author Anders Halager <halager@gmail.com>
date Sun, 04 May 2008 18:13:46 +0200
parents 192da4976daa
children 48bb2287c035
line wrap: on
line diff
--- a/lexer/Token.d	Sun May 04 12:58:02 2008 +0200
+++ b/lexer/Token.d	Sun May 04 18:13:46 2008 +0200
@@ -1,7 +1,7 @@
 module lexer.Token;
 
 public 
-import misc.Location;
+import basic.SourceLocation;
 
 import Integer = tango.text.convert.Integer;
 
@@ -15,14 +15,14 @@
 struct Token
 {
     Tok type;
-    Location location;
+    SLoc location;
     uint length;
 
     /**
       Create a new token with a Tok type, Location in source and a 
       length of how many chars the Token span in the source
       */
-    static Token opCall (Tok type, Location location, uint length)
+    static Token opCall (Tok type, SLoc location, uint length)
     {
         Token t;
         t.type = type;
@@ -44,18 +44,11 @@
       */
     char[] toString ()
     {
-        return this.getType()~": Len: "~Integer.toString(this.length)
-            ~", Loc: "~location.toString;
+        return this.getType()~": Len: "~Integer.toString(this.length);
     }
 
-    /**
-      Get the string in the source that matches what this Token is 
-      covering.
-      */
-    char[] get ()
-    {
-        return location.get(length);
-    }
+    /// Get the range of this token
+    SourceRange asRange() { return SourceRange(location, location + length); }
 
     /**
       Returns true if the type of this token is a basic type (int, float, ...).