changeset 65:6c21ae79fbb3

- Renamed function Token.span to Token.srcText. - Added Parser class stub.
author aziz
date Fri, 29 Jun 2007 19:14:05 +0000
parents dd4c5a0e47dd
children 8e84db78ad55
files trunk/src/Lexer.d trunk/src/Parser.d trunk/src/Token.d trunk/src/main.d
diffstat 4 files changed, 21 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/Lexer.d	Fri Jun 29 18:26:04 2007 +0000
+++ b/trunk/src/Lexer.d	Fri Jun 29 19:14:05 2007 +0000
@@ -125,7 +125,7 @@
 
         t.end = p;
 
-        string str = t.span;
+        string str = t.srcText;
         Identifier* id = str in idtable;
 
         if (!id)
@@ -1322,7 +1322,7 @@
     uint oldloc = this.loc, newloc;
 
     peek(t);
-    if (!(this.loc == oldloc && p == t.start && t.type == TOK.Identifier && t.span == "line"))
+    if (!(this.loc == oldloc && p == t.start && t.type == TOK.Identifier && t.srcText == "line"))
     {
       this.loc = oldloc; // reset this.loc because we took a peek at the next token
       mid = MID.ExpectedIdentifierSTLine;
@@ -1357,10 +1357,10 @@
         mid = MID.ExpectedNormalStringLiteral;
         goto Lerr;
       }
-      fileName = t.span[1..$-1]; // contents of "..."
+      fileName = t.srcText[1..$-1]; // contents of "..."
       p = t.end;
     }
-    else if (t.type == TOK.Identifier && t.span == "__FILE__")
+    else if (t.type == TOK.Identifier && t.srcText == "__FILE__")
     {
       p = t.end;
     }
--- a/trunk/src/Parser.d	Fri Jun 29 18:26:04 2007 +0000
+++ b/trunk/src/Parser.d	Fri Jun 29 19:14:05 2007 +0000
@@ -2,4 +2,9 @@
   Author: Aziz Köksal
   License: GPL2
 +/
-module Parser;
\ No newline at end of file
+module Parser;
+
+class Parser
+{
+
+}
--- a/trunk/src/Token.d	Fri Jun 29 18:26:04 2007 +0000
+++ b/trunk/src/Token.d	Fri Jun 29 19:14:05 2007 +0000
@@ -118,7 +118,7 @@
     real   real_;
   }
 
-  string span()
+  string srcText()
   {
     assert(start && end);
     return start[0 .. end - start];
--- a/trunk/src/main.d	Fri Jun 29 18:26:04 2007 +0000
+++ b/trunk/src/main.d	Fri Jun 29 19:14:05 2007 +0000
@@ -45,11 +45,11 @@
   {
     if (end != token.start)
       writef("%s", xmlescape(end[0 .. token.start - end]));
-    string span = xmlescape(token.span);
+    string srcText = xmlescape(token.srcText);
     switch(token.type)
     {
       case TOK.Identifier:
-        writef("<i>%s</i>", span);
+        writef("<i>%s</i>", srcText);
       break;
       case TOK.Comment:
         string c;
@@ -59,13 +59,13 @@
         case '*': c = "bc"; break;
         case '+': c = "nc"; break;
         }
-        writef(`<c c="%s">%s</c>`, c, span);
+        writef(`<c c="%s">%s</c>`, c, srcText);
       break;
       case TOK.String:
-        writef("<sl>%s</sl>", span);
+        writef("<sl>%s</sl>", srcText);
       break;
       case TOK.Character:
-        writef("<cl>%s</cl>", span);
+        writef("<cl>%s</cl>", srcText);
       break;
       case TOK.Assign, TOK.Equal,
         TOK.Less, TOK.Greater,
@@ -89,7 +89,7 @@
         TOK.UorL,
         TOK.UorLorE,
         TOK.LorEorG:
-        writef("<op>%s</op>", span);
+        writef("<op>%s</op>", srcText);
       break;
       case TOK.LorG:
         writef(`<op c="lg">&lt;&gt;</op>`);
@@ -115,18 +115,18 @@
       case TOK.Int32, TOK.Int64, TOK.Uint32, TOK.Uint64,
            TOK.Float32, TOK.Float64, TOK.Float80,
            TOK.Imaginary32, TOK.Imaginary64, TOK.Imaginary80:
-        writef("<n>%s</n>", span);
+        writef("<n>%s</n>", srcText);
       break;
       case TOK.LParen, TOK.RParen, TOK.LBracket,
            TOK.RBracket, TOK.LBrace, TOK.RBrace:
-        writef("<br>%s</br>", span);
+        writef("<br>%s</br>", srcText);
       break;
       case TOK.EOF: break;
       default:
         if (token.isKeyword())
-          writef("<k>%s</k>", span);
+          writef("<k>%s</k>", srcText);
         else
-          writef("%s", span);
+          writef("%s", srcText);
     }
     end = token.end;
   }