changeset 515:7cb97346bc6f

Using class Module in SettingsLoader.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 14 Dec 2007 20:12:13 +0100
parents 6ddff941862a
children 433d51c18524
files trunk/src/dil/Module.d trunk/src/dil/SettingsLoader.d
diffstat 2 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/Module.d	Fri Dec 14 19:32:07 2007 +0100
+++ b/trunk/src/dil/Module.d	Fri Dec 14 20:12:13 2007 +0100
@@ -76,6 +76,11 @@
     this.root.semantic(scop);
   }
 
+  bool hasErrors()
+  {
+    return parser.errors.length || parser.lx.errors.length;
+  }
+
   string[] getImports()
   {
     string[] result;
--- a/trunk/src/dil/SettingsLoader.d	Fri Dec 14 19:32:07 2007 +0100
+++ b/trunk/src/dil/SettingsLoader.d	Fri Dec 14 20:12:13 2007 +0100
@@ -6,7 +6,7 @@
 
 import dil.Settings;
 import dil.Messages;
-import dil.Parser, dil.SyntaxTree, dil.Declarations, dil.Expressions;
+import dil.Module, dil.SyntaxTree, dil.Declarations, dil.Expressions;
 import dil.File;
 import tango.io.FilePath;
 import common;
@@ -17,14 +17,13 @@
 
   // Load config.d
   auto filePath = execPath.file("config.d").toUtf8();
-  auto sourceText = loadFile(filePath);
-  auto parser = new Parser(sourceText, filePath);
-  auto root = parser.start();
+  auto modul = new Module(filePath);
+  modul.parse();
 
-  if (parser.errors.length || parser.lx.errors.length)
+  if (modul.hasErrors)
     throw new Exception("There are errors in " ~ filePath ~ ".");
 
-  foreach (decl; root.children)
+  foreach (decl; modul.root.children)
   {
     auto v = Cast!(VariableDeclaration)(decl);
     if (v is null)
@@ -68,16 +67,15 @@
   }
 
   // Load language file.
-  filePath = GlobalSettings.langFile;
-  sourceText = loadFile(execPath.file(filePath).toUtf8());
-  parser = new Parser(sourceText, filePath);
-  root = parser.start();
+  filePath = execPath.file(GlobalSettings.langFile).toUtf8();
+  modul = new Module(filePath);
+  modul.parse();
 
-  if (parser.errors.length || parser.lx.errors.length)
+  if (modul.hasErrors)
     throw new Exception("There are errors in "~filePath~".");
 
   char[][] messages;
-  foreach (decl; root.children)
+  foreach (decl; modul.root.children)
   {
     auto v = Cast!(VariableDeclaration)(decl);
     if (v is null)