File indexing completed on 2024-04-28 04:36:07
0001 /* 0002 * Copyright 2008 Niko Sams <niko.sams@gmail.com> 0003 * Based on QMake Parser Copyright 2006 Andreas Pakulat <apaku@gmx.de> 0004 * 0005 * This program is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU General Public License 0007 * as published by the Free Software Foundation; either version 2 0008 * of the License, or (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0018 * 02110-1301, USA. 0019 */ 0020 0021 0022 #include "factparser.h" 0023 0024 #include <QStack> 0025 #include <QString> 0026 0027 namespace fact 0028 { 0029 0030 class Parser; 0031 0032 class Lexer 0033 { 0034 public: 0035 Lexer( fact::Parser *parser, const QString& contents); 0036 0037 int nextTokenKind(); 0038 qint64 tokenBegin() const; 0039 qint64 tokenEnd() const; 0040 0041 private: 0042 QString m_content; 0043 Parser* m_parser; 0044 int m_curpos; 0045 int m_contentSize; 0046 qint64 m_tokenBegin; 0047 qint64 m_tokenEnd; 0048 0049 int state() const; 0050 void pushState(int state); 0051 void popState(); 0052 void createNewline( int pos ); 0053 0054 QStack<int> mState; 0055 enum State 0056 { 0057 ErrorState = -1, 0058 DefaultState = 0 0059 }; 0060 }; 0061 0062 } // end of namespace fact 0063 0064 // kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on