comparison trunk/src/dil/Settings.d @ 391:33b566df6af4

Migrated project to Tango. Decremented the numbers of the format placeholders in the localized messages by one. Replaced all instances of writef/ln with Stdout. Added module common.d with string aliases and a global Layout!(char) instance. Replaced %s format specifiers with index placeholders in html/xml_tags. Changed member Information.arguments to string message. Copied std.metastring, std.uni and std.utf from Phobos.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 15 Sep 2007 17:12:26 +0200
parents 2adf808343d6
children 6440da4adb07
comparison
equal deleted inserted replaced
390:4d36eea1bbc9 391:33b566df6af4
4 +/ 4 +/
5 module dil.Settings; 5 module dil.Settings;
6 import dil.Messages; 6 import dil.Messages;
7 import dil.Parser, dil.SyntaxTree, dil.Declarations, dil.Expressions; 7 import dil.Parser, dil.SyntaxTree, dil.Declarations, dil.Expressions;
8 import dil.File; 8 import dil.File;
9 import std.metastrings; 9 import std.metastrings : FormatT = Format, ToString;
10 import common;
10 11
11 template Pad(char[] str, uint amount) 12 template Pad(char[] str, uint amount)
12 { 13 {
13 static if (str.length >= amount) 14 static if (str.length >= amount)
14 const char[] Pad = str; 15 const char[] Pad = str;
30 { 31 {
31 const VERSION_MAJOR = 1; 32 const VERSION_MAJOR = 1;
32 const VERSION_MINOR = 0; 33 const VERSION_MINOR = 0;
33 } 34 }
34 35
35 const string VERSION = Format!("%s.%s", VERSION_MAJOR, Pad!(VERSION_MINOR, 3)); 36 const string VERSION = FormatT!("%s.%s", VERSION_MAJOR, Pad!(VERSION_MINOR, 3));
36 const VENDOR = "dil"; 37 const VENDOR = "dil";
37 38
38 /// Used in main help message. 39 /// Used in main help message.
39 const COMPILED_WITH = __VENDOR__; 40 const COMPILED_WITH = __VENDOR__;
40 /// ditto 41 /// ditto
41 const COMPILED_VERSION = Format!("%s.%s", __VERSION__/1000, Pad!(__VERSION__%1000, 3)); 42 const COMPILED_VERSION = FormatT!("%s.%s", __VERSION__/1000, Pad!(__VERSION__%1000, 3));
42 /// ditto 43 /// ditto
43 const COMPILED_DATE = __TIMESTAMP__; 44 const COMPILED_DATE = __TIMESTAMP__;
44 45
45 struct GlobalSettings 46 struct GlobalSettings
46 { 47 {
47 static: 48 static:
48 string language; /// Language of messages catalogue to load. 49 string language; /// Language of loaded messages catalogue.
49 string[] messages; /// Table of localized compiler messages. 50 string[] messages; /// Table of localized compiler messages.
50 string[] importPaths; /// Array of import paths to look for modules. 51 string[] importPaths; /// Array of import paths to look for modules.
51 void load() 52 void load()
52 { 53 {
53 auto fileName = "config.d"[]; 54 auto fileName = "config.d"[];
132 if (auto str = Cast!(StringLiteralsExpression)(e)) 133 if (auto str = Cast!(StringLiteralsExpression)(e))
133 GlobalSettings.language = str.getString(); 134 GlobalSettings.language = str.getString();
134 } 135 }
135 } 136 }
136 if (messages.length != MID.max+1) 137 if (messages.length != MID.max+1)
137 throw new Exception(std.string.format("messages table in %s must exactly have %d entries, but %s were found.", fileName, MID.max+1, messages.length)); 138 throw new Exception(Format("messages table in {0} must exactly have {1} entries, but {2} were found.", fileName, MID.max+1, messages.length));
138 GlobalSettings.messages = messages; 139 GlobalSettings.messages = messages;
139 } 140 }
140 } 141 }