annotate trunk/src/dil/Messages.d @ 524:39b497c76e2b

Moved struct MSG from dil.Parser to dil.Messages.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 16 Dec 2007 19:34:36 +0100
parents 3ead178e0662
children 135e9e6933a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
1 /++
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
2 Author: Aziz Köksal
249
32d354584b28 - Upgraded license notices to GPL3.
aziz
parents: 238
diff changeset
3 License: GPL3
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
4 +/
326
4a7359b88c11 - Added package 'dil' to module declarations.
aziz
parents: 325
diff changeset
5 module dil.Messages;
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
6 import common;
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
7
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
8 /// Index into table of compiler messages.
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
9 enum MID
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
10 {
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
11 // Lexer messages:
390
4d36eea1bbc9 Refactored Lexer.scan().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 389
diff changeset
12 IllegalCharacter,
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
13 InvalidUnicodeCharacter,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
14 InvalidUTF8Sequence,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
15 // ''
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
16 UnterminatedCharacterLiteral,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
17 EmptyCharacterLiteral,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
18 // #line
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
19 ExpectedIdentifierSTLine,
388
ae154eceba65 Applied some fixes to scanning and printing #line tokens.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
20 ExpectedIntegerAfterSTLine,
323
6259fb93e3dd - Rewrote scanSpecialToken().
aziz
parents: 309
diff changeset
21 ExpectedFilespec,
6259fb93e3dd - Rewrote scanSpecialToken().
aziz
parents: 309
diff changeset
22 UnterminatedFilespec,
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
23 UnterminatedSpecialToken,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
24 // ""
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
25 UnterminatedString,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
26 // x""
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
27 NonHexCharInHexString,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
28 OddNumberOfDigitsInHexString,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
29 UnterminatedHexString,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
30 // /* */ /+ +/
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
31 UnterminatedBlockComment,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
32 UnterminatedNestedComment,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
33 // `` r""
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
34 UnterminatedRawString,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
35 UnterminatedBackQuoteString,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
36 // \x \u \U
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
37 UndefinedEscapeSequence,
432
3ead178e0662 Added message MID.InvalidUnicodeEscapeSequence.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 405
diff changeset
38 InvalidUnicodeEscapeSequence,
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
39 InsufficientHexDigits,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
40 // \&[a-zA-Z][a-zA-Z0-9]+;
272
0bde32503976 - Added module HtmlEntities. It contains a table for converting HTML entities to Unicode characters.
aziz
parents: 249
diff changeset
41 UndefinedHTMLEntity,
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
42 UnterminatedHTMLEntity,
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
43 InvalidBeginHTMLEntity,
56
63af7ddf52e1 - Started properly implementing number scanner. Added stub for real numbers.
aziz
parents: 54
diff changeset
44 // integer overflows
58
50bb7fc9db44 - The types of integers are recognized now.
aziz
parents: 56
diff changeset
45 OverflowDecimalSign,
56
63af7ddf52e1 - Started properly implementing number scanner. Added stub for real numbers.
aziz
parents: 54
diff changeset
46 OverflowDecimalNumber,
63af7ddf52e1 - Started properly implementing number scanner. Added stub for real numbers.
aziz
parents: 54
diff changeset
47 OverflowHexNumber,
63af7ddf52e1 - Started properly implementing number scanner. Added stub for real numbers.
aziz
parents: 54
diff changeset
48 OverflowBinaryNumber,
63af7ddf52e1 - Started properly implementing number scanner. Added stub for real numbers.
aziz
parents: 54
diff changeset
49 OverflowOctalNumber,
63
c29229fbf2f7 - Recognizing floats that start with a dot.
aziz
parents: 62
diff changeset
50 OverflowFloatNumber,
c29229fbf2f7 - Recognizing floats that start with a dot.
aziz
parents: 62
diff changeset
51 OctalNumberHasDecimals,
59
3e594725899a - Issuing error when no digits were found in hex and binary numbers.
aziz
parents: 58
diff changeset
52 NoDigitsInHexNumber,
3e594725899a - Issuing error when no digits were found in hex and binary numbers.
aziz
parents: 58
diff changeset
53 NoDigitsInBinNumber,
62
96af5653acef - Fixed loop of hex number scanner. Moved checks under the switch block.
aziz
parents: 59
diff changeset
54 HexFloatExponentRequired,
389
c4bfceab7246 Applied fixes and improvements to hex float scanner.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 388
diff changeset
55 HexFloatExpMustStartWithDigit,
c4bfceab7246 Applied fixes and improvements to hex float scanner.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 388
diff changeset
56 FloatExpMustStartWithDigit,
86
0459c902a370 - Added code for parsing Assert-, Mixin-, Import-, Typeid- and TypeDotIdExpressions.
aziz
parents: 81
diff changeset
57
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
58 // Parser messages:
86
0459c902a370 - Added code for parsing Assert-, Mixin-, Import-, Typeid- and TypeDotIdExpressions.
aziz
parents: 81
diff changeset
59 ExpectedButFound,
238
f3c6c15961bb - Added method peekNext(). Replaced code that used lx.peek() with peekNext().
aziz
parents: 86
diff changeset
60 RedundantStorageClass,
341
3ac651ea83fb - Fix: created TemplateAliasParameter instead of TemplateTypeParameter.
aziz
parents: 329
diff changeset
61 TemplateTupleParameter,
342
f13d551d7c4f - Added error messages MID.InContract and MID.OutContract.
aziz
parents: 341
diff changeset
62 InContract,
f13d551d7c4f - Added error messages MID.InContract and MID.OutContract.
aziz
parents: 341
diff changeset
63 OutContract,
359
511c14950cac - Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents: 342
diff changeset
64 MissingLinkageType,
511c14950cac - Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents: 342
diff changeset
65 UnrecognizedLinkageType,
405
e2529923a0cb Added two error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 394
diff changeset
66 ExpectedBaseClasses,
e2529923a0cb Added two error messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 394
diff changeset
67 BaseClassInForwardDeclaration,
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
68
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
69 // Help messages:
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
70 HelpMain,
329
17f43b0d6106 - Renamed command highlight to generate.
aziz
parents: 327
diff changeset
71 HelpGenerate,
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 359
diff changeset
72 HelpImportGraph,
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
73 }
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
74
394
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
75 private string[] messages;
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
76
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
77 package void SetMessages(string[] msgs)
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
78 {
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
79 assert(MID.max+1 == msgs.length);
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
80 messages = msgs;
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
81 }
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
82
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
83 string GetMsg(MID mid)
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
84 {
394
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
85 assert(mid < messages.length);
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
86 return messages[mid];
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
87 }
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
88
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
89 char[] FormatMsg(MID mid, ...)
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
90 {
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
91 return Format(_arguments, _argptr, GetMsg(mid));
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
92 }
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents:
diff changeset
93
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
94 /+
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
95 char[] FormatArray(char[] format_str, char[][] args)
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
96 {
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
97 auto tiinfos = new TypeInfo[args.length];
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
98 foreach (ref tiinfo; tiinfos)
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
99 tiinfo = typeid(char[]);
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
100 return Format(tiinfos, args.ptr, format_str);
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 272
diff changeset
101 }
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 390
diff changeset
102 +/
524
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
103
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
104 /// Collection of error messages with no MID yet.
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
105 struct MSG
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
106 {
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
107 static:
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
108 // Parser messages:
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
109 auto ExpectedIdAfterTypeDot = "expected identifier after '(Type).', not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
110 auto ExpectedModuleIdentifier = "expected module identifier, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
111 auto IllegalDeclaration = "illegal Declaration found: ";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
112 auto ExpectedFunctionName = "expected function name, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
113 auto ExpectedVariableName = "expected variable name, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
114 auto ExpectedFunctionBody = "expected function body, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
115 auto RedundantLinkageType = "redundant linkage type: ";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
116 auto ExpectedPragmaIdentifier = "expected pragma identifier, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
117 auto ExpectedAliasModuleName = "expected alias module name, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
118 auto ExpectedAliasImportName = "expected alias name, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
119 auto ExpectedImportName = "expected an identifier, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
120 auto ExpectedEnumMember = "expected enum member, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
121 auto ExpectedEnumBody = "expected enum body, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
122 auto ExpectedClassName = "expected class name, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
123 auto ExpectedClassBody = "expected class body, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
124 auto ExpectedInterfaceName = "expected interface name, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
125 auto ExpectedInterfaceBody = "expected interface body, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
126 auto ExpectedTemplateName = "expected template name, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
127 auto ExpectedAnIdentifier = "expected an identifier, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
128 auto IllegalStatement = "illegal Statement found: ";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
129 auto ExpectedNonEmptyStatement = "didn't expect ';', use {{ }} instead";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
130 auto ExpectedScopeIdentifier = "expected 'exit', 'success' or 'failure', not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
131 auto InvalidScopeIdentifier = "'exit', 'success', 'failure' are valid scope identifiers, but not '{}';";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
132 auto ExpectedIntegerAfterAlign = "expected an integer after align, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
133 auto IllegalAsmInstructino = "illegal AsmInstruction found: ";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
134 auto ExpectedDeclaratorIdentifier = "expected declarator identifier, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
135 auto ExpectedTemplateParameters = "expected one or more template parameters not ')'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
136 auto ExpectedTypeOrExpression = "expected a type or and expression not ')'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
137 auto ExpectedAliasTemplateParam = "expected name for alias template parameter, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
138 auto ExpectedNameForThisTempParam = "expected name for 'this' template parameter, not '{}'";
39b497c76e2b Moved struct MSG from dil.Parser to dil.Messages.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 432
diff changeset
139 }