changeset 17:9bd0bac79479

- Removed Whitespace from enum list. - Added code to count current number of lines.
author aziz
date Sat, 23 Jun 2007 20:12:03 +0000
parents 476e8e55c1d4
children c48d2125f1e2
files trunk/src/Lexer.d trunk/src/Token.d trunk/src/main.d
diffstat 3 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/Lexer.d	Sat Jun 23 14:23:01 2007 +0000
+++ b/trunk/src/Lexer.d	Sat Jun 23 20:12:03 2007 +0000
@@ -89,6 +89,8 @@
   char* p;
   char* end;
 
+  uint loc = 1; /// line of code
+
   this(char[] text)
   {
     this.text = text;
@@ -111,11 +113,26 @@
 
       if (c == 0)
       {
+        ++p;
         t.type = TOK.EOF;
-        t.end = p+1;
+        t.end = p;
         return;
       }
 
+      if (c == '\n')
+      {
+        c = *++p;
+        ++loc;
+        continue;
+      }
+      else if (c == '\r')
+      {
+        c = *++p;
+        if (c != '\n')
+          ++loc;
+        continue;
+      }
+
       if (isidbeg(c))
       {
       Lidentifier:
--- a/trunk/src/Token.d	Sat Jun 23 14:23:01 2007 +0000
+++ b/trunk/src/Token.d	Sat Jun 23 20:12:03 2007 +0000
@@ -13,7 +13,6 @@
 enum TOK
 {
   Identifier,
-  Whitespace,
   Comment,
   String,
   Character,
--- a/trunk/src/main.d	Sat Jun 23 14:23:01 2007 +0000
+++ b/trunk/src/main.d	Sat Jun 23 20:12:03 2007 +0000
@@ -43,9 +43,6 @@
       case TOK.Identifier:
         writef("<i>%s</i>", span);
       break;
-      case TOK.Whitespace:
-        writef(span);
-      break;
       case TOK.Comment:
         writef("<c>%s</c>", span);
       break;