diff trunk/src/dil/Information.d @ 490:47be6bfe39cd

Refactored code and added new modules. Added ProtectionDeclaration and changed Parser to make use of it. Moved class Location to its own module. Moved some Lexer functions to new module LexerFuncs. Moved Lexer.getLocation() to struct Token. Added methods semantic() and error() to class Expression. Added method error() to class Scope.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Tue, 04 Dec 2007 23:31:20 +0100
parents bd176bc73e43
children 6ddff941862a
line wrap: on
line diff
--- a/trunk/src/dil/Information.d	Mon Dec 03 22:44:27 2007 +0100
+++ b/trunk/src/dil/Information.d	Tue Dec 04 23:31:20 2007 +0100
@@ -6,6 +6,8 @@
 import dil.Messages;
 import common;
 
+public import dil.Location;
+
 enum InfoType
 {
   Lexer,
@@ -57,87 +59,3 @@
 {
   Information[] info;
 }
-
-final class Location
-{
-  char[] filePath;
-  size_t lineNum;
-  char* lineBegin, to; // Used to calculate column.
-
-  this(char[] filePath, size_t lineNum)
-  {
-    set(filePath, lineNum);
-  }
-
-  this(char[] filePath, size_t lineNum, char* lineBegin, char* to)
-  {
-    set(filePath, lineNum, lineBegin, to);
-  }
-
-  Location clone()
-  {
-    return new Location(filePath, lineNum, lineBegin, to);
-  }
-
-  void set(char[] filePath, size_t lineNum)
-  {
-    set(filePath, lineNum, null, null);
-  }
-
-  void set(char[] filePath, size_t lineNum, char* lineBegin, char* to)
-  {
-    this.filePath  = filePath;
-    set(lineNum, lineBegin, to);
-  }
-
-  void set(size_t lineNum, char* lineBegin, char* to)
-  {
-    assert(lineBegin !is null && to !is null);
-    assert(lineBegin <= to);
-    this.lineNum   = lineNum;
-    this.lineBegin = lineBegin;
-    this.to        = to;
-  }
-
-  void setFilePath(char[] filePath)
-  {
-    this.filePath = filePath;
-  }
-
-  /++
-    This is a primitive method to count the number of characters in a string.
-    Unicode compound characters and other special characters are not
-    taken into account.
-  +/
-  uint calculateColumn()
-  {
-    uint col;
-    auto p = lineBegin;
-    for (; p <= to; ++p)
-    {
-      assert(delegate ()
-        {
-          const char[3] LS = \u2028;
-          const char[3] PS = \u2029;
-          // Check that there is no newline between p and to.
-          // But 'to' may point to a newline.
-          if (p != to && (*p == '\n' || *p == '\r'))
-            return false;
-          if (to-p >= 2)
-          {
-            if (*p == LS[0] && p[1] == LS[1] && (p[2] == LS[2] || p[2] == PS[2]))
-              return false;
-          }
-          return true;
-        }() == true
-      );
-
-      // Skip this byte if it is a trail byte of a UTF-8 sequence.
-      if ((*p & 0xC0) == 0x80)
-        continue; // *p == 0b10xx_xxxx
-      // Only count ASCII characters and the first byte of a UTF-8 sequence.
-      ++col;
-    }
-    return col;
-  }
-}