changeset 574:ae8f58a13917

Added messages to struct MSG.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Mon, 31 Dec 2007 14:48:45 +0100
parents 87c4474a1295
children dd3fe62c8a96
files trunk/src/dil/Declarations.d trunk/src/dil/Messages.d trunk/src/dil/Scope.d
diffstat 3 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/Declarations.d	Sat Dec 29 23:37:18 2007 +0100
+++ b/trunk/src/dil/Declarations.d	Mon Dec 31 14:48:45 2007 +0100
@@ -15,6 +15,7 @@
 import dil.Semantics;
 import dil.Symbols;
 import dil.TypeSystem;
+import dil.Messages;
 import common;
 
 abstract class Declaration : Node
@@ -511,7 +512,7 @@
 
     // Check for interface.
     if (scop.isInterface)
-      return scop.error(begin, "an interface can't have member variables");
+      return scop.error(begin, MSG.InterfaceCantHaveVariables);
 
     // Iterate over variable identifiers in this declaration.
     foreach (i, ident; idents)
--- a/trunk/src/dil/Messages.d	Sat Dec 29 23:37:18 2007 +0100
+++ b/trunk/src/dil/Messages.d	Mon Dec 31 14:48:45 2007 +0100
@@ -133,13 +133,16 @@
   auto IllegalStatement = "illegal Statement found: ";
   auto ExpectedNonEmptyStatement = "didn't expect ';', use {{ } instead";
   auto ExpectedScopeIdentifier = "expected 'exit', 'success' or 'failure', not '{}'";
-  auto InvalidScopeIdentifier = "'exit', 'success', 'failure' are valid scope identifiers, but not '{}';";
+  auto InvalidScopeIdentifier = "'exit', 'success', 'failure' are valid scope identifiers, but not '{}'";
   auto ExpectedIntegerAfterAlign = "expected an integer after align, not '{}'";
   auto IllegalAsmInstructino = "illegal AsmInstruction found: ";
   auto ExpectedDeclaratorIdentifier = "expected declarator identifier, not '{}'";
-  auto ExpectedTemplateParameters = "expected one or more template parameters not ')'";
-  auto ExpectedTypeOrExpression = "expected a type or and expression not ')'";
+  auto ExpectedTemplateParameters = "expected one or more template parameters, not ')'";
+  auto ExpectedTypeOrExpression = "expected a type or and expression, not ')'";
   auto ExpectedAliasTemplateParam = "expected name for alias template parameter, not '{}'";
   auto ExpectedNameForThisTempParam = "expected name for 'this' template parameter, not '{}'";
   auto ExpectedIdentOrInt = "expected an identifier or an integer, not '{}'";
+  // Semantic analysis:
+  auto VariableConflictsWithDecl = "variable '{}' conflicts with declaration @{}";
+  auto InterfaceCantHaveVariables = "an interface can't have member variables";
 }
--- a/trunk/src/dil/Scope.d	Sat Dec 29 23:37:18 2007 +0100
+++ b/trunk/src/dil/Scope.d	Mon Dec 31 14:48:45 2007 +0100
@@ -46,7 +46,7 @@
     {
       auto loc = sym.node.begin.getLocation();
       auto locString = Format("{}({},{})", loc.filePath, loc.lineNum, loc.colNum);
-      error(var.node.begin, "variable '"~var.ident.str~"' conflicts with symbol @"~locString);
+      error(var.node.begin, MSG.VariableConflictsWithDecl, var.ident.str, locString);
     }
     else
       symbol.insert(var, var.ident);
@@ -113,9 +113,10 @@
     infoMan ~= new SemanticError(location, GetMsg(mid));
   }
 
-  void error(Token* token, char[] msg)
+  void error(Token* token, char[] formatMsg, ...)
   {
     auto location = token.getLocation();
+    auto msg = Format(_arguments, _argptr, formatMsg);
     infoMan ~= new SemanticError(location, msg);
   }
 }