1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). 4 ** Contact: http://www.qt-project.org/legal 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and Digia. For licensing terms and 13 ** conditions see http://qt.digia.com/licensing. For further information 14 ** use the contact form at http://qt.digia.com/contact-us. 15 ** 16 ** GNU Lesser General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU Lesser 18 ** General Public License version 2.1 as published by the Free Software 19 ** Foundation and appearing in the file LICENSE.LGPL included in the 20 ** packaging of this file. Please review the following information to 21 ** ensure the GNU Lesser General Public License version 2.1 requirements 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 23 ** 24 ** In addition, as a special exception, Digia gives you certain additional 25 ** rights. These rights are described in the Digia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 ** 28 ****************************************************************************/ 29 #ifndef CPLUSPLUS_SIMPLELEXER_H 30 #define CPLUSPLUS_SIMPLELEXER_H 31 32 #include "Token.h" 33 34 #include <QString> 35 #include <QList> 36 37 namespace CPlusPlus { 38 39 class SimpleLexer; 40 class Token; 41 42 class SimpleLexer 43 { 44 public: 45 SimpleLexer(); 46 ~SimpleLexer(); 47 48 bool skipComments() const; 49 void setSkipComments(bool skipComments); 50 languageFeatures()51 LanguageFeatures languageFeatures() const { return _languageFeatures; } setLanguageFeatures(LanguageFeatures features)52 void setLanguageFeatures(LanguageFeatures features) { _languageFeatures = features; } 53 54 bool endedJoined() const; 55 56 QList<Token> operator()(const QString &text, int state = 0); 57 state()58 int state() const 59 { return _lastState; } 60 61 static int tokenAt(const QList<Token> &tokens, unsigned offset); 62 static Token tokenAt(const QString &text, 63 unsigned offset, 64 int state, 65 bool qtMocRunEnabled = false); 66 67 static int tokenBefore(const QList<Token> &tokens, unsigned offset); 68 69 private: 70 int _lastState; 71 LanguageFeatures _languageFeatures; 72 bool _skipComments: 1; 73 bool _endedJoined: 1; 74 }; 75 76 } // namespace CPlusPlus 77 78 #endif // CPLUSPLUS_SIMPLELEXER_H 79