Mercurial > projects > dil
comparison trunk/src/dil/SettingsLoader.d @ 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 | 6160ab7b1816 |
children | 433d51c18524 |
comparison
equal
deleted
inserted
replaced
514:6ddff941862a | 515:7cb97346bc6f |
---|---|
4 +/ | 4 +/ |
5 module dil.SettingsLoader; | 5 module dil.SettingsLoader; |
6 | 6 |
7 import dil.Settings; | 7 import dil.Settings; |
8 import dil.Messages; | 8 import dil.Messages; |
9 import dil.Parser, dil.SyntaxTree, dil.Declarations, dil.Expressions; | 9 import dil.Module, dil.SyntaxTree, dil.Declarations, dil.Expressions; |
10 import dil.File; | 10 import dil.File; |
11 import tango.io.FilePath; | 11 import tango.io.FilePath; |
12 import common; | 12 import common; |
13 | 13 |
14 void loadSettings() | 14 void loadSettings() |
15 { | 15 { |
16 scope execPath = new FilePath(GetExecutableFilePath()); | 16 scope execPath = new FilePath(GetExecutableFilePath()); |
17 | 17 |
18 // Load config.d | 18 // Load config.d |
19 auto filePath = execPath.file("config.d").toUtf8(); | 19 auto filePath = execPath.file("config.d").toUtf8(); |
20 auto sourceText = loadFile(filePath); | 20 auto modul = new Module(filePath); |
21 auto parser = new Parser(sourceText, filePath); | 21 modul.parse(); |
22 auto root = parser.start(); | |
23 | 22 |
24 if (parser.errors.length || parser.lx.errors.length) | 23 if (modul.hasErrors) |
25 throw new Exception("There are errors in " ~ filePath ~ "."); | 24 throw new Exception("There are errors in " ~ filePath ~ "."); |
26 | 25 |
27 foreach (decl; root.children) | 26 foreach (decl; modul.root.children) |
28 { | 27 { |
29 auto v = Cast!(VariableDeclaration)(decl); | 28 auto v = Cast!(VariableDeclaration)(decl); |
30 if (v is null) | 29 if (v is null) |
31 continue; | 30 continue; |
32 | 31 |
66 default: | 65 default: |
67 } | 66 } |
68 } | 67 } |
69 | 68 |
70 // Load language file. | 69 // Load language file. |
71 filePath = GlobalSettings.langFile; | 70 filePath = execPath.file(GlobalSettings.langFile).toUtf8(); |
72 sourceText = loadFile(execPath.file(filePath).toUtf8()); | 71 modul = new Module(filePath); |
73 parser = new Parser(sourceText, filePath); | 72 modul.parse(); |
74 root = parser.start(); | |
75 | 73 |
76 if (parser.errors.length || parser.lx.errors.length) | 74 if (modul.hasErrors) |
77 throw new Exception("There are errors in "~filePath~"."); | 75 throw new Exception("There are errors in "~filePath~"."); |
78 | 76 |
79 char[][] messages; | 77 char[][] messages; |
80 foreach (decl; root.children) | 78 foreach (decl; modul.root.children) |
81 { | 79 { |
82 auto v = Cast!(VariableDeclaration)(decl); | 80 auto v = Cast!(VariableDeclaration)(decl); |
83 if (v is null) | 81 if (v is null) |
84 continue; | 82 continue; |
85 | 83 |