File indexing completed on 2024-04-28 16:26:27

0001 /**************************************************************************
0002 *   Copyright (C) 2011-2019 by Michel Ludwig (michel.ludwig@kdemail.net)       *
0003 ***************************************************************************/
0004 
0005 /***************************************************************************
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or modify  *
0008  *   it under the terms of the GNU General Public License as published by  *
0009  *   the Free Software Foundation; either version 2 of the License, or     *
0010  *   (at your option) any later version.                                   *
0011  *                                                                         *
0012  ***************************************************************************/
0013 
0014 #ifndef LATEXPARSER_H
0015 #define LATEXPARSER_H
0016 
0017 #include "documentinfo.h"
0018 #include "kileconstants.h"
0019 #include "kileextensions.h"
0020 #include "parser.h"
0021 
0022 namespace KileParser {
0023 
0024 struct BracketResult
0025 {
0026     BracketResult() : line(0), col(0) {}
0027     QString option, value;
0028     int line, col;
0029 };
0030 
0031 class LaTeXParserInput : public ParserInput
0032 {
0033 public:
0034     LaTeXParserInput(const QUrl &url, const QStringList &textLines,
0035                      KileDocument::Extensions *extensions,
0036                      const QMap<QString, KileStructData>& dictStructLevel,
0037                      bool showSectioningLabels,
0038                      bool showStructureTodo);
0039 
0040     QStringList textLines;
0041     KileDocument::Extensions *extensions;
0042     const QMap<QString, KileStructData> dictStructLevel;
0043     bool showSectioningLabels;
0044     bool showStructureTodo;
0045 };
0046 
0047 class LaTeXParserOutput : public ParserOutput {
0048 public:
0049     LaTeXParserOutput();
0050     virtual ~LaTeXParserOutput();
0051 
0052     QStringList labels;
0053     QStringList bibItems;
0054     QStringList deps;
0055     QStringList bibliography;
0056     QStringList packages;
0057     QStringList newCommands;
0058     QStringList asyFigures;
0059     QString preamble;
0060     bool bIsRoot;
0061 };
0062 
0063 
0064 class LaTeXParser : public Parser
0065 {
0066     Q_OBJECT
0067 
0068 public:
0069     LaTeXParser(ParserThread *parserThread, LaTeXParserInput *input,
0070                 QObject *parent = Q_NULLPTR);
0071     virtual ~LaTeXParser();
0072 
0073     ParserOutput* parse() override;
0074 
0075 protected:
0076     KileDocument::Extensions *m_extensions;
0077     QStringList m_textLines;
0078     const QMap<QString, KileStructData>& m_dictStructLevel;
0079     bool m_showSectioningLabels;
0080     bool m_showStructureTodo;
0081 
0082     BracketResult matchBracket(const QStringList& textLines, int &l, int &pos);
0083 };
0084 
0085 }
0086 
0087 #endif