1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the tools applications of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #ifndef TOKEN_H |
30 | #define TOKEN_H |
31 | |
32 | #include <QtCore/qglobal.h> |
33 | |
34 | QT_BEGIN_NAMESPACE |
35 | |
36 | #define FOR_ALL_TOKENS(F) \ |
37 | F(NOTOKEN) \ |
38 | F(IDENTIFIER) \ |
39 | F(INTEGER_LITERAL) \ |
40 | F(CHARACTER_LITERAL) \ |
41 | F(STRING_LITERAL) \ |
42 | F(BOOLEAN_LITERAL) \ |
43 | F() \ |
44 | F(LANGLE) \ |
45 | F(RANGLE) \ |
46 | F(LPAREN) \ |
47 | F(RPAREN) \ |
48 | F(ELIPSIS) \ |
49 | F(LBRACK) \ |
50 | F(RBRACK) \ |
51 | F(LBRACE) \ |
52 | F(RBRACE) \ |
53 | F(EQ) \ |
54 | F(SCOPE) \ |
55 | F(SEMIC) \ |
56 | F(COLON) \ |
57 | F(DOTSTAR) \ |
58 | F(QUESTION) \ |
59 | F(DOT) \ |
60 | F(DYNAMIC_CAST) \ |
61 | F(STATIC_CAST) \ |
62 | F(REINTERPRET_CAST) \ |
63 | F(CONST_CAST) \ |
64 | F(TYPEID) \ |
65 | F(THIS) \ |
66 | F(TEMPLATE) \ |
67 | F(THROW) \ |
68 | F(TRY) \ |
69 | F(CATCH) \ |
70 | F(TYPEDEF) \ |
71 | F(FRIEND) \ |
72 | F(CLASS) \ |
73 | F(NAMESPACE) \ |
74 | F(ENUM) \ |
75 | F(STRUCT) \ |
76 | F(UNION) \ |
77 | F(VIRTUAL) \ |
78 | F(PRIVATE) \ |
79 | F(PROTECTED) \ |
80 | F(PUBLIC) \ |
81 | F(EXPORT) \ |
82 | F(AUTO) \ |
83 | F(REGISTER) \ |
84 | F(EXTERN) \ |
85 | F(MUTABLE) \ |
86 | F(ASM) \ |
87 | F(USING) \ |
88 | F(INLINE) \ |
89 | F(EXPLICIT) \ |
90 | F(STATIC) \ |
91 | F(CONST) \ |
92 | F(VOLATILE) \ |
93 | F(OPERATOR) \ |
94 | F(SIZEOF) \ |
95 | F(NEW) \ |
96 | F(DELETE) \ |
97 | F(PLUS) \ |
98 | F(MINUS) \ |
99 | F(STAR) \ |
100 | F(SLASH) \ |
101 | F(PERCENT) \ |
102 | F(HAT) \ |
103 | F(AND) \ |
104 | F(OR) \ |
105 | F(TILDE) \ |
106 | F(NOT) \ |
107 | F(PLUS_EQ) \ |
108 | F(MINUS_EQ) \ |
109 | F(STAR_EQ) \ |
110 | F(SLASH_EQ) \ |
111 | F(PERCENT_EQ) \ |
112 | F(HAT_EQ) \ |
113 | F(AND_EQ) \ |
114 | F(OR_EQ) \ |
115 | F(LTLT) \ |
116 | F(GTGT) \ |
117 | F(GTGT_EQ) \ |
118 | F(LTLT_EQ) \ |
119 | F(EQEQ) \ |
120 | F(NE) \ |
121 | F(LE) \ |
122 | F(GE) \ |
123 | F(ANDAND) \ |
124 | F(OROR) \ |
125 | F(INCR) \ |
126 | F(DECR) \ |
127 | F(COMMA) \ |
128 | F(ARROW_STAR) \ |
129 | F(ARROW) \ |
130 | F(CHAR) \ |
131 | F(WCHAR) \ |
132 | F(BOOL) \ |
133 | F(SHORT) \ |
134 | F(INT) \ |
135 | F(LONG) \ |
136 | F(SIGNED) \ |
137 | F(UNSIGNED) \ |
138 | F(FLOAT) \ |
139 | F(DOUBLE) \ |
140 | F(VOID) \ |
141 | F(CASE) \ |
142 | F(DEFAULT) \ |
143 | F(IF) \ |
144 | F(ELSE) \ |
145 | F(SWITCH) \ |
146 | F(WHILE) \ |
147 | F(DO) \ |
148 | F(FOR) \ |
149 | F(BREAK) \ |
150 | F(CONTINUE) \ |
151 | F(GOTO) \ |
152 | F(SIGNALS) \ |
153 | F(SLOTS) \ |
154 | F(RETURN) \ |
155 | F(Q_OBJECT_TOKEN) \ |
156 | F(Q_GADGET_TOKEN) \ |
157 | F(Q_NAMESPACE_TOKEN) \ |
158 | F(Q_NAMESPACE_EXPORT_TOKEN) \ |
159 | F(Q_PROPERTY_TOKEN) \ |
160 | F(Q_PLUGIN_METADATA_TOKEN) \ |
161 | F(Q_ENUMS_TOKEN) \ |
162 | F(Q_ENUM_TOKEN) \ |
163 | F(Q_ENUM_NS_TOKEN) \ |
164 | F(Q_FLAGS_TOKEN) \ |
165 | F(Q_FLAG_TOKEN) \ |
166 | F(Q_FLAG_NS_TOKEN) \ |
167 | F(Q_DECLARE_FLAGS_TOKEN) \ |
168 | F(Q_DECLARE_INTERFACE_TOKEN) \ |
169 | F(Q_DECLARE_METATYPE_TOKEN) \ |
170 | F(Q_CLASSINFO_TOKEN) \ |
171 | F(Q_INTERFACES_TOKEN) \ |
172 | F(Q_SIGNALS_TOKEN) \ |
173 | F(Q_SLOTS_TOKEN) \ |
174 | F(Q_SIGNAL_TOKEN) \ |
175 | F(Q_SLOT_TOKEN) \ |
176 | F(Q_PRIVATE_SLOT_TOKEN) \ |
177 | F(Q_MOC_COMPAT_TOKEN) \ |
178 | F(Q_INVOKABLE_TOKEN) \ |
179 | F(Q_SCRIPTABLE_TOKEN) \ |
180 | F(Q_PRIVATE_PROPERTY_TOKEN) \ |
181 | F(Q_REVISION_TOKEN) \ |
182 | F(Q_MOC_INCLUDE_TOKEN) \ |
183 | F(SPECIAL_TREATMENT_MARK) \ |
184 | F(MOC_INCLUDE_BEGIN) \ |
185 | F(MOC_INCLUDE_END) \ |
186 | F() \ |
187 | F() \ |
188 | F(FLOATING_LITERAL) \ |
189 | F(HASH) \ |
190 | F(QUOTE) \ |
191 | F(SINGLEQUOTE) \ |
192 | F(LANGLE_SCOPE) \ |
193 | F(DIGIT) \ |
194 | F(CHARACTER) \ |
195 | F(NEWLINE) \ |
196 | F(WHITESPACE) \ |
197 | F(BACKSLASH) \ |
198 | F(INCOMPLETE) \ |
199 | F(PP_DEFINE) \ |
200 | F(PP_UNDEF) \ |
201 | F(PP_IF) \ |
202 | F(PP_IFDEF) \ |
203 | F(PP_IFNDEF) \ |
204 | F(PP_ELIF) \ |
205 | F(PP_ELSE) \ |
206 | F(PP_ENDIF) \ |
207 | F(PP_INCLUDE) \ |
208 | F(PP_HASHHASH) \ |
209 | F(PP_HASH) \ |
210 | F(PP_DEFINED) \ |
211 | F(PP_INCOMPLETE) \ |
212 | F(PP_MOC_TRUE) \ |
213 | F(PP_MOC_FALSE) |
214 | |
215 | |
216 | enum Token { |
217 | |
218 | #define CREATE_ENUM_VALUE(Name) Name, |
219 | FOR_ALL_TOKENS(CREATE_ENUM_VALUE) |
220 | #undef CREATE_ENUM_VALUE |
221 | |
222 | // aliases |
223 | PP_AND = AND, |
224 | PP_ANDAND = ANDAND, |
225 | PP_BACKSLASH = BACKSLASH, |
226 | PP_CHARACTER = CHARACTER, |
227 | PP_CHARACTER_LITERAL = CHARACTER_LITERAL, |
228 | PP_COLON = COLON, |
229 | PP_COMMA = COMMA, |
230 | = CPP_COMMENT, |
231 | = C_COMMENT, |
232 | PP_DIGIT = DIGIT, |
233 | PP_EQEQ = EQEQ, |
234 | PP_FLOATING_LITERAL = FLOATING_LITERAL, |
235 | PP_GE = GE, |
236 | PP_GTGT = GTGT, |
237 | PP_HAT = HAT, |
238 | PP_IDENTIFIER = IDENTIFIER, |
239 | PP_INTEGER_LITERAL = INTEGER_LITERAL, |
240 | PP_LANGLE = LANGLE, |
241 | PP_LE = LE, |
242 | PP_LPAREN = LPAREN, |
243 | PP_LTLT = LTLT, |
244 | PP_MINUS = MINUS, |
245 | PP_NE = NE, |
246 | PP_NEWLINE = NEWLINE, |
247 | PP_NOTOKEN = NOTOKEN, |
248 | PP_NOT = NOT, |
249 | PP_OR = OR, |
250 | PP_OROR = OROR, |
251 | PP_PERCENT = PERCENT, |
252 | PP_PLUS = PLUS, |
253 | PP_QUESTION = QUESTION, |
254 | PP_QUOTE = QUOTE, |
255 | PP_RANGLE = RANGLE, |
256 | PP_RPAREN = RPAREN, |
257 | PP_SINGLEQUOTE = SINGLEQUOTE, |
258 | PP_SLASH = SLASH, |
259 | PP_STAR = STAR, |
260 | PP_STRING_LITERAL = STRING_LITERAL, |
261 | PP_TILDE = TILDE, |
262 | PP_WHITESPACE = WHITESPACE, |
263 | Q_META_TOKEN_BEGIN = Q_OBJECT_TOKEN, |
264 | Q_META_TOKEN_END = SPECIAL_TREATMENT_MARK |
265 | }; |
266 | |
267 | // for debugging only |
268 | #if defined(DEBUG_MOC) |
269 | const char *tokenTypeName(Token t); |
270 | #endif |
271 | |
272 | typedef Token PP_Token; |
273 | |
274 | QT_END_NAMESPACE |
275 | |
276 | #endif // TOKEN_H |
277 | |