changeset 69:24db7c5522d5

- Added module Information for compiler messages like warnings, info and errors to the user. - Renamed class Problem to Information.
author aziz
date Sun, 01 Jul 2007 13:53:00 +0000
parents 7eb83dd38901
children 0d3ef6daec04
files trunk/src/Information.d trunk/src/Lexer.d trunk/src/Parser.d trunk/src/main.d
diffstat 4 files changed, 51 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/Information.d	Sun Jul 01 13:53:00 2007 +0000
@@ -0,0 +1,44 @@
+/++
+  Author: Aziz Köksal
+  License: GPL2
++/
+module Information;
+import Messages;
+import std.string;
+
+enum Type
+{
+  Lexer,
+  Parser,
+  Semantic
+}
+
+class Information
+{
+  MID id;
+  Type type;
+  uint loc;
+  string[] arguments;
+
+  this(Type type, MID id, uint loc, string[] arguments)
+  {
+    this.id = id;
+    this.type = type;
+    this.loc = loc;
+    this.arguments = arguments;
+  }
+
+  string getMsg()
+  {
+    char[] msg = messages[id];
+
+    if (arguments.length == 0)
+      return msg;
+
+    foreach (i, arg; arguments)
+      msg = replace(msg, format("{%s}", i+1), arg);
+
+    return msg;
+  }
+}
+
--- a/trunk/src/Lexer.d	Sun Jul 01 12:18:02 2007 +0000
+++ b/trunk/src/Lexer.d	Sun Jul 01 13:53:00 2007 +0000
@@ -4,6 +4,7 @@
 +/
 module Lexer;
 import Token;
+import Information;
 import Keywords;
 import Identifier;
 import Messages;
@@ -22,49 +23,6 @@
 
 const uint _Z_ = 26; /// Control+Z
 
-class Problem
-{
-  enum Type
-  {
-    Lexer,
-    Parser,
-    Semantic
-  }
-
-  MID id;
-  Type type;
-  uint loc;
-  string[] arguments;
-/*
-  this(Type type, MID id, uint loc)
-  {
-    this.id = id;
-    this.type = type;
-    this.loc = loc;
-  }
-*/
-  this(Type type, MID id, uint loc, string[] arguments)
-  {
-    this.id = id;
-    this.type = type;
-    this.loc = loc;
-    this.arguments = arguments;
-  }
-
-  string getMsg()
-  {
-    char[] msg = messages[id];
-
-    if (arguments.length == 0)
-      return msg;
-
-    foreach (i, arg; arguments)
-      msg = replace(msg, format("{%s}", i+1), arg);
-
-    return msg;
-  }
-}
-
 class Lexer
 {
   Token token;
@@ -76,7 +34,7 @@
 
   char[] fileName;
 
-  Problem[] errors;
+  Information[] errors;
 
   Identifier[string] idtable;
 
@@ -1482,7 +1440,7 @@
       return args;
     }
 
-    errors ~= new Problem(Problem.Type.Lexer, id, loc, arguments(_arguments, _argptr));
+    errors ~= new Information(Information.Type.Lexer, id, loc, arguments(_arguments, _argptr));
   }
 
   public TOK nextToken()
--- a/trunk/src/Parser.d	Sun Jul 01 12:18:02 2007 +0000
+++ b/trunk/src/Parser.d	Sun Jul 01 13:53:00 2007 +0000
@@ -3,6 +3,7 @@
   License: GPL2
 +/
 module Parser;
+import Lexer;
 
 enum STC
 {
@@ -21,5 +22,6 @@
 
 class Parser
 {
-
+  private Lexer lx;
+  alias lx.nextToken nextToken;
 }
--- a/trunk/src/main.d	Sun Jul 01 12:18:02 2007 +0000
+++ b/trunk/src/main.d	Sun Jul 01 13:53:00 2007 +0000
@@ -3,6 +3,7 @@
   License: GPL2
 +/
 module dparser;
+import Parser;
 import Lexer;
 import Token;
 import Messages;