1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
33 // Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
35 // Permission is hereby granted, free of charge, to any person obtaining a copy
36 // of this software and associated documentation files (the "Software"), to deal
37 // in the Software without restriction, including without limitation the rights
38 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39 // copies of the Software, and to permit persons to whom the Software is
40 // furnished to do so, subject to the following conditions:
42 // The above copyright notice and this permission notice shall be included in
43 // all copies or substantial portions of the Software.
45 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
53 #ifndef CPLUSPLUS_TOKEN_H
54 #define CPLUSPLUS_TOKEN_H
56 #include "CPlusPlusForwardDeclarations.h"
71 T_NUMERIC_LITERAL = T_FIRST_LITERAL,
75 T_WIDE_STRING_LITERAL,
77 T_ANGLE_STRING_LITERAL,
78 T_LAST_LITERAL = T_ANGLE_STRING_LITERAL,
81 T_AMPER = T_FIRST_OPERATOR,
103 T_GREATER_GREATER_EQUAL,
133 T_LAST_OPERATOR = T_TILDE_EQUAL,
136 T_ASM = T_FIRST_KEYWORD,
203 // obj c++ @ keywords
204 T_FIRST_OBJC_AT_KEYWORD,
206 T_AT_CATCH = T_FIRST_OBJC_AT_KEYWORD,
208 T_AT_COMPATIBILITY_ALIAS,
231 T_LAST_OBJC_AT_KEYWORD = T_AT_TRY,
236 T_SIGNAL = T_FIRST_QT_KEYWORD,
247 T_Q_PRIVATE_PROPERTY,
252 T_Q_DECLARE_INTERFACE,
255 T_LAST_KEYWORD = T_Q_GADGET,
259 T_AND = T_AMPER_AMPER,
264 T_OR_EQ = T_PIPE_EQUAL,
265 T_AND_EQ = T_AMPER_EQUAL,
267 T_NOT_EQ = T_EXCLAIM_EQUAL,
268 T_XOR_EQ = T_CARET_EQUAL,
273 T_TYPEOF = T___TYPEOF__,
274 T___TYPEOF = T___TYPEOF__,
276 T___INLINE = T_INLINE,
277 T___INLINE__ = T_INLINE,
280 T___CONST__ = T_CONST,
282 T___VOLATILE = T_VOLATILE,
283 T___VOLATILE__ = T_VOLATILE,
285 T___ATTRIBUTE = T___ATTRIBUTE__
288 class CPLUSPLUS_EXPORT Token
294 inline bool is(unsigned k) const { return f.kind == k; }
295 inline bool isNot(unsigned k) const { return f.kind != k; }
296 const char *spell() const;
299 inline unsigned kind() const { return f.kind; }
300 inline bool newline() const { return f.newline; }
301 inline bool whitespace() const { return f.whitespace; }
302 inline bool joined() const { return f.joined; }
303 inline bool expanded() const { return f.expanded; }
304 inline bool generated() const { return f.generated; }
305 inline unsigned length() const { return f.length; }
307 inline unsigned begin() const
310 inline unsigned end() const
311 { return offset + f.length; }
313 inline bool isLiteral() const
314 { return f.kind >= T_FIRST_LITERAL && f.kind <= T_LAST_LITERAL; }
316 inline bool isOperator() const
317 { return f.kind >= T_FIRST_OPERATOR && f.kind <= T_LAST_OPERATOR; }
319 inline bool isKeyword() const
320 { return f.kind >= T_FIRST_KEYWORD && f.kind < T_FIRST_QT_KEYWORD; }
322 inline bool isComment() const
323 { return f.kind == T_COMMENT || f.kind == T_DOXY_COMMENT ||
324 f.kind == T_CPP_COMMENT || f.kind == T_CPP_DOXY_COMMENT; }
326 inline bool isObjCAtKeyword() const
327 { return f.kind >= T_FIRST_OBJC_AT_KEYWORD && f.kind <= T_LAST_OBJC_AT_KEYWORD; }
329 static const char *name(int kind);
334 unsigned newline : 1;
335 unsigned whitespace : 1;
337 unsigned expanded : 1;
338 unsigned generated : 1;
340 unsigned length : 16;
351 const Literal *literal;
352 const NumericLiteral *number;
353 const StringLiteral *string;
354 const Identifier *identifier;
355 unsigned close_brace;
360 } // end of namespace CPlusPlus
363 #endif // CPLUSPLUS_TOKEN_H