# HG changeset patch # User Aziz K?ksal # Date 1197659533 -3600 # Node ID 7cb97346bc6fd1c7921744906506af733454a0c8 # Parent 6ddff941862aa0f08a5d0f78fab2edc3e44112cc Using class Module in SettingsLoader. diff -r 6ddff941862a -r 7cb97346bc6f trunk/src/dil/Module.d --- 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; diff -r 6ddff941862a -r 7cb97346bc6f trunk/src/dil/SettingsLoader.d --- 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)