comparison src/dil/Messages.d @ 806:bcb74c9b895c

Moved out files in the trunk folder to the root.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 09 Mar 2008 00:12:19 +0100
parents trunk/src/dil/Messages.d@9e6c6bb73e5f
children 525ee3f848d9
comparison
equal deleted inserted replaced
805:a3fab8b74a7d 806:bcb74c9b895c
1 /++
2 Author: Aziz Köksal
3 License: GPL3
4 +/
5 module dil.Messages;
6
7 import common;
8
9 /// Enumeration of indices into the table of compiler messages.
10 enum MID
11 {
12 // Lexer messages:
13 IllegalCharacter,
14 // InvalidUnicodeCharacter,
15 InvalidUTF8Sequence,
16 // ''
17 UnterminatedCharacterLiteral,
18 EmptyCharacterLiteral,
19 // #line
20 ExpectedIdentifierSTLine,
21 ExpectedIntegerAfterSTLine,
22 // ExpectedFilespec,
23 UnterminatedFilespec,
24 UnterminatedSpecialToken,
25 // ""
26 UnterminatedString,
27 // x""
28 NonHexCharInHexString,
29 OddNumberOfDigitsInHexString,
30 UnterminatedHexString,
31 // /* */ /+ +/
32 UnterminatedBlockComment,
33 UnterminatedNestedComment,
34 // `` r""
35 UnterminatedRawString,
36 UnterminatedBackQuoteString,
37 // \x \u \U
38 UndefinedEscapeSequence,
39 InvalidUnicodeEscapeSequence,
40 InsufficientHexDigits,
41 // \&[a-zA-Z][a-zA-Z0-9]+;
42 UndefinedHTMLEntity,
43 UnterminatedHTMLEntity,
44 InvalidBeginHTMLEntity,
45 // integer overflows
46 OverflowDecimalSign,
47 OverflowDecimalNumber,
48 OverflowHexNumber,
49 OverflowBinaryNumber,
50 OverflowOctalNumber,
51 OverflowFloatNumber,
52 OctalNumberHasDecimals,
53 NoDigitsInHexNumber,
54 NoDigitsInBinNumber,
55 HexFloatExponentRequired,
56 HexFloatExpMustStartWithDigit,
57 FloatExpMustStartWithDigit,
58
59 // Parser messages:
60 ExpectedButFound,
61 RedundantStorageClass,
62 TemplateTupleParameter,
63 InContract,
64 OutContract,
65 MissingLinkageType,
66 UnrecognizedLinkageType,
67 ExpectedBaseClasses,
68 BaseClassInForwardDeclaration,
69
70 // Help messages:
71 HelpMain,
72 HelpGenerate,
73 HelpImportGraph,
74 }
75
76 /// The table of compiler messages.
77 private string[] g_compilerMessages;
78
79 static this()
80 {
81 g_compilerMessages = new string[MID.max+1];
82 }
83
84 /// Sets the compiler messages.
85 void SetMessages(string[] msgs)
86 {
87 assert(MID.max+1 == msgs.length);
88 g_compilerMessages = msgs;
89 }
90
91 /// Returns the compiler message for mid.
92 string GetMsg(MID mid)
93 {
94 assert(mid < g_compilerMessages.length);
95 return g_compilerMessages[mid];
96 }
97
98 /// Returns a formatted string.
99 char[] FormatMsg(MID mid, ...)
100 {
101 return Format(_arguments, _argptr, GetMsg(mid));
102 }
103
104 /// Collection of error messages with no MID yet.
105 struct MSG
106 {
107 static:
108 // Converter:
109 auto InvalidUTF16Character = "invalid UTF-16 character '\\u{:X4}'.";
110 auto InvalidUTF32Character = "invalid UTF-32 character '\\U{:X8}'.";
111 auto UTF16FileMustBeDivisibleBy2 = "the byte length of a UTF-16 source file must be divisible by 2.";
112 auto UTF32FileMustBeDivisibleBy4 = "the byte length of a UTF-32 source file must be divisible by 4.";
113 // DDoc macros:
114 auto UndefinedDDocMacro = "DDoc macro '{}' is undefined";
115 auto UnterminatedDDocMacro = "DDoc macro '{}' has no closing ')'";
116 // Lexer messages:
117 auto InvalidOctalEscapeSequence = "value of octal escape sequence is greater than 0xFF: '{}'";
118 // Parser messages:
119 auto InvalidUTF8SequenceInString = "invalid UTF-8 sequence in string literal: '{0}'";
120 auto ModuleDeclarationNotFirst = "a module declaration is only allowed as the first declaration in a file";
121 auto StringPostfixMismatch = "string literal has mistmatching postfix character";
122 auto ExpectedIdAfterTypeDot = "expected identifier after '(Type).', not '{}'";
123 auto ExpectedModuleIdentifier = "expected module identifier, not '{}'";
124 auto IllegalDeclaration = "illegal declaration found: {}";
125 auto ExpectedFunctionName = "expected function name, not '{}'";
126 auto ExpectedVariableName = "expected variable name, not '{}'";
127 auto ExpectedFunctionBody = "expected function body, not '{}'";
128 auto RedundantLinkageType = "redundant linkage type: {}";
129 auto ExpectedPragmaIdentifier = "expected pragma identifier, not '{}'";
130 auto ExpectedAliasModuleName = "expected alias module name, not '{}'";
131 auto ExpectedAliasImportName = "expected alias name, not '{}'";
132 auto ExpectedImportName = "expected an identifier, not '{}'";
133 auto ExpectedEnumMember = "expected enum member, not '{}'";
134 auto ExpectedEnumBody = "expected enum body, not '{}'";
135 auto ExpectedClassName = "expected class name, not '{}'";
136 auto ExpectedClassBody = "expected class body, not '{}'";
137 auto ExpectedInterfaceName = "expected interface name, not '{}'";
138 auto ExpectedInterfaceBody = "expected interface body, not '{}'";
139 auto ExpectedStructBody = "expected struct body, not '{}'";
140 auto ExpectedUnionBody = "expected union body, not '{}'";
141 auto ExpectedTemplateName = "expected template name, not '{}'";
142 auto ExpectedAnIdentifier = "expected an identifier, not '{}'";
143 auto IllegalStatement = "illegal statement found: {}";
144 auto ExpectedNonEmptyStatement = "didn't expect ';', use {{ } instead";
145 auto ExpectedScopeIdentifier = "expected 'exit', 'success' or 'failure', not '{}'";
146 auto InvalidScopeIdentifier = "'exit', 'success', 'failure' are valid scope identifiers, but not '{}'";
147 auto ExpectedIntegerAfterAlign = "expected an integer after align, not '{}'";
148 auto IllegalAsmStatement = "illegal asm statement found: {}";
149 auto ExpectedDeclaratorIdentifier = "expected declarator identifier, not '{}'";
150 auto ExpectedTemplateParameters = "expected one or more template parameters, not ')'";
151 auto ExpectedTypeOrExpression = "expected a type or and expression, not ')'";
152 auto ExpectedAliasTemplateParam = "expected name for alias template parameter, not '{}'";
153 auto ExpectedNameForThisTempParam = "expected name for 'this' template parameter, not '{}'";
154 auto ExpectedIdentOrInt = "expected an identifier or an integer, not '{}'";
155 auto MissingCatchOrFinally = "try statement is missing a catch or finally body.";
156 // Semantic analysis:
157 auto UndefinedIdentifier = "undefined identifier '{}'";
158 auto DeclConflictsWithDecl = "declaration '{}' conflicts with declaration @{}";
159 auto VariableConflictsWithDecl = "variable '{}' conflicts with declaration @{}";
160 auto InterfaceCantHaveVariables = "an interface can't have member variables";
161 auto MixinArgumentMustBeString = "the mixin argument must evaluate to a string";
162 auto DebugSpecModuleLevel = "debug={} must be a module level";
163 auto VersionSpecModuleLevel = "version={} must be a module level";
164 }