File indexing completed on 2024-04-28 03:40:41

0001 
0002 #line 54 "exp.g"
0003 
0004 /*************************************************************************************
0005  *  Copyright (C) 2008 by Aleix Pol <aleixpol@kde.org>                               *
0006  *                                                                                   *
0007  *  This program is free software; you can redistribute it and/or                    *
0008  *  modify it under the terms of the GNU General Public License                      *
0009  *  as published by the Free Software Foundation; either version 2                   *
0010  *  of the License, or (at your option) any later version.                           *
0011  *                                                                                   *
0012  *  This program is distributed in the hope that it will be useful,                  *
0013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0015  *  GNU General Public License for more details.                                     *
0016  *                                                                                   *
0017  *  You should have received a copy of the GNU General Public License                *
0018  *  along with this program; if not, write to the Free Software                      *
0019  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0020  *************************************************************************************/
0021 
0022 #ifndef EXPRESSIONPARSER_H
0023 #define EXPRESSIONPARSER_H
0024 
0025 #include <QStringList>
0026 #include <QVector>
0027 #include "expressiontable_p.h"
0028 #include "analitzaexport.h"
0029 class AbstractLexer;
0030 
0031 class ANALITZA_EXPORT ExpressionParser : protected ExpressionTable
0032 {
0033     public:
0034         ExpressionParser();
0035         ~ExpressionParser();
0036 
0037         bool parse(AbstractLexer *lexer);
0038 
0039         bool isCorrect() const { return m_err.isEmpty(); }
0040         int errorLineNumber() const { return m_errorLineNumber; }
0041         QStringList error() const { return m_err; }
0042         QString mathML() const { return m_exp; }
0043         QStringList comments() const { return m_comments; }
0044 
0045     private:
0046         void reallocateStack();
0047 
0048         inline QString &sym(int index)
0049         { return m_symStack[m_tos + index - 1]; }
0050 
0051         int m_tos;
0052         QVector<int> m_stateStack;
0053         QVector<QString> m_symStack;
0054         int m_errorLineNumber;
0055         QStringList m_err;
0056         QString m_exp;
0057         QStringList m_comments;
0058 };
0059 
0060 #endif
0061