1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the tools applications of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** 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, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
58
Here come the C++ tokens we support. The first part contains
59
all-purpose tokens; then come keywords.
61
If you add a keyword, make sure to modify the keyword array in
62
tokenizer.cpp as well, and possibly adjust Tok_FirstKeyword and
65
enum { Tok_Eoi, Tok_Ampersand, Tok_Aster, Tok_Caret, Tok_LeftParen,
66
Tok_RightParen, Tok_LeftParenAster, Tok_Equal, Tok_LeftBrace,
67
Tok_RightBrace, Tok_Semicolon, Tok_Colon, Tok_LeftAngle,
68
Tok_RightAngle, Tok_Comma, Tok_Ellipsis, Tok_Gulbrandsen,
69
Tok_LeftBracket, Tok_RightBracket, Tok_Tilde, Tok_SomeOperator,
70
Tok_Number, Tok_String, Tok_Doc, Tok_Comment, Tok_Ident, Tok_At,
71
Tok_char, Tok_class, Tok_const, Tok_double, Tok_enum,
72
Tok_explicit, Tok_friend, Tok_inline, Tok_int, Tok_long,
73
Tok_namespace, Tok_operator, Tok_private, Tok_protected,
74
Tok_public, Tok_short, Tok_signals, Tok_signed, Tok_slots,
75
Tok_static, Tok_struct, Tok_template, Tok_typedef,
76
Tok_typename, Tok_union, Tok_unsigned, Tok_using, Tok_virtual,
77
Tok_void, Tok_volatile, Tok_int64, Tok_Q_OBJECT, Tok_Q_OVERRIDE,
78
Tok_Q_PROPERTY, Tok_Q_PRIVATE_PROPERTY, Tok_Q_DECLARE_SEQUENTIAL_ITERATOR,
79
Tok_Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR,
80
Tok_Q_DECLARE_ASSOCIATIVE_ITERATOR,
81
Tok_Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR,
82
Tok_Q_DECLARE_FLAGS, Tok_Q_SIGNALS, Tok_Q_SLOTS, Tok_QT_COMPAT,
83
Tok_QT_COMPAT_CONSTRUCTOR, Tok_QT_DEPRECATED, Tok_QT_MOC_COMPAT,
84
Tok_QT_MODULE, Tok_QT3_SUPPORT, Tok_QT3_SUPPORT_CONSTRUCTOR,
85
Tok_QT3_MOC_SUPPORT, Tok_QDOC_PROPERTY,
86
Tok_FirstKeyword = Tok_char, Tok_LastKeyword = Tok_QDOC_PROPERTY };
89
The Tokenizer class implements lexical analysis of C++ source
92
Not every operator or keyword of C++ is recognized; only those
93
that are interesting to us. Some Qt keywords or macros are also
100
Tokenizer(const Location& loc, const QByteArray &in);
101
Tokenizer(const Location& loc, QFile &file);
106
void setParsingFnOrMacro(bool macro) { parsingMacro = macro; }
107
bool parsingFnOrMacro() const { return parsingMacro; }
109
const Location &location() const { return yyTokLoc; }
110
QString previousLexeme() const;
111
QString lexeme() const;
112
QString version() const { return yyVersion; }
113
int braceDepth() const { return yyBraceDepth; }
114
int parenDepth() const { return yyParenDepth; }
115
int bracketDepth() const { return yyBracketDepth; }
117
static void initialize(const Config &config);
118
static void terminate();
119
static bool isTrue(const QString &condition);
123
void start(const Location& loc);
125
This limit on the length of a lexeme seems fairly high, but a
126
doc comment can be arbitrarily long. The previous 65,536 limit
127
was reached by Mark Summerfield.
129
enum { yyLexBufSize = 524288 };
133
return yyPos == yyIn.size() ? EOF : yyIn[yyPos++];
140
if (yyLexLen < yyLexBufSize - 1) {
141
yyLex[yyLexLen++] = (char) yyCh;
142
yyLex[yyLexLen] = '\0';
144
yyCurLoc.advance(yyCh);
148
// cast explicitly to make sure the value of ch
149
// is in range [0..255] to avoid assert messages
150
// when using debug CRT that checks its input.
151
return int(uint(uchar(ch)));
154
int getTokenAfterPreprocessor();
155
void pushSkipping(bool skip);
165
QStack<bool> yyPreprocessorSkipping;
166
int yyNumPreprocessorSkipping;