1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
32 // Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
34 // Permission is hereby granted, free of charge, to any person obtaining a copy
35 // of this software and associated documentation files (the "Software"), to deal
36 // in the Software without restriction, including without limitation the rights
37 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38 // copies of the Software, and to permit persons to whom the Software is
39 // furnished to do so, subject to the following conditions:
41 // The above copyright notice and this permission notice shall be included in
42 // all copies or substantial portions of the Software.
44 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
55 using namespace CPlusPlus;
57 static const char *token_names[] = {
60 ("<C++ comment>"), ("<C++ doxy comment>"),
61 ("<comment>"), ("<doxy comment>"),
63 ("<identifier>"), ("<numeric literal>"), ("<char literal>"),
64 ("<wide char literal>"), ("<string literal>"), ("<wide char literal>"),
65 ("<@string literal>"), ("<angle string literal>"),
67 ("&"), ("&&"), ("&="), ("->"), ("->*"), ("^"), ("^="), (":"), ("::"),
68 (","), ("/"), ("/="), ("."), ("..."), (".*"), ("="), ("=="), ("!"),
69 ("!="), (">"), (">="), (">>"), (">>="), ("{"), ("["), ("<"), ("<="),
70 ("<<"), ("<<="), ("("), ("-"), ("-="), ("--"), ("%"), ("%="), ("|"),
71 ("|="), ("||"), ("+"), ("+="), ("++"), ("#"), ("##"), ("?"), ("}"),
72 ("]"), (")"), (";"), ("*"), ("*="), ("~"), ("~="),
74 ("asm"), ("auto"), ("bool"), ("break"), ("case"), ("catch"), ("char"),
75 ("class"), ("const"), ("const_cast"), ("continue"), ("default"),
76 ("delete"), ("do"), ("double"), ("dynamic_cast"), ("else"), ("enum"),
77 ("explicit"), ("export"), ("extern"), ("false"), ("float"), ("for"),
78 ("friend"), ("goto"), ("if"), ("inline"), ("int"), ("long"),
79 ("mutable"), ("namespace"), ("new"), ("operator"), ("private"),
80 ("protected"), ("public"), ("register"), ("reinterpret_cast"),
81 ("return"), ("short"), ("signed"), ("sizeof"), ("static"),
82 ("static_cast"), ("struct"), ("switch"), ("template"), ("this"),
83 ("throw"), ("true"), ("try"), ("typedef"), ("typeid"), ("typename"),
84 ("union"), ("unsigned"), ("using"), ("virtual"), ("void"),
85 ("volatile"), ("wchar_t"), ("while"),
88 ("__attribute__"), ("__typeof__"),
91 ("@catch"), ("@class"), ("@compatibility_alias"), ("@defs"), ("@dynamic"),
92 ("@encode"), ("@end"), ("@finally"), ("@implementation"), ("@interface"),
93 ("@not_keyword"), ("@optional"), ("@package"), ("@private"), ("@property"),
94 ("@protected"), ("@protocol"), ("@public"), ("@required"), ("@selector"),
95 ("@synchronized"), ("@synthesize"), ("@throw"), ("@try"),
98 ("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"),
99 ("Q_FOREACH"), ("Q_D"), ("Q_Q"),
100 ("Q_INVOKABLE"), ("Q_PROPERTY"), ("Q_INTERFACES"), ("Q_ENUMS"), ("Q_FLAGS"),
101 ("Q_PRIVATE_SLOT"), ("Q_DECLARE_INTERFACE"), ("Q_OBJECT"), ("Q_GADGET"),
106 flags(0), offset(0), ptr(0)
121 const char *Token::name(int kind)
122 { return token_names[kind]; }
124 const char *Token::spell() const
128 return identifier->chars();
130 case T_NUMERIC_LITERAL:
132 case T_STRING_LITERAL:
133 case T_AT_STRING_LITERAL:
134 case T_ANGLE_STRING_LITERAL:
135 case T_WIDE_CHAR_LITERAL:
136 case T_WIDE_STRING_LITERAL:
137 return literal->chars();
140 return token_names[f.kind];