]> git.lyx.org Git - lyx.git/commitdiff
Move Lexer to support/ directory (and lyx::support namespace)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 27 Apr 2024 22:24:46 +0000 (00:24 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 28 Apr 2024 10:23:13 +0000 (12:23 +0200)
This requires quite a bit of trivial code shuffling.

128 files changed:
src/Buffer.cpp
src/Buffer.h
src/BufferParams.cpp
src/BufferParams.h
src/BufferView.cpp
src/CiteEnginesList.cpp
src/CmdDef.cpp
src/ConverterCache.cpp
src/Counters.cpp
src/Counters.h
src/Encoding.cpp
src/Font.cpp
src/FontInfo.cpp
src/FontInfo.h
src/KeyMap.cpp
src/LaTeXFonts.cpp
src/LaTeXFonts.h
src/LaTeXPackages.cpp
src/Language.cpp
src/Language.h
src/Layout.cpp
src/Layout.h
src/LayoutFile.cpp
src/Lexer.cpp [deleted file]
src/Lexer.h [deleted file]
src/LyXRC.cpp
src/LyXRC.h
src/Makefile.am
src/ModuleList.cpp
src/PDFOptions.cpp
src/PDFOptions.h
src/ParagraphParameters.cpp
src/ParagraphParameters.h
src/Text.cpp
src/Text.h
src/TextClass.cpp
src/TextClass.h
src/Trans.cpp
src/Trans.h
src/factory.cpp
src/factory.h
src/frontends/qt/GuiApplication.cpp
src/frontends/qt/GuiLog.cpp
src/frontends/qt/GuiParagraph.cpp
src/frontends/qt/GuiView.cpp
src/frontends/qt/Menus.cpp
src/frontends/qt/Menus.h
src/frontends/qt/Toolbars.cpp
src/frontends/qt/Toolbars.h
src/insets/ExternalTemplate.cpp
src/insets/ExternalTemplate.h
src/insets/Inset.h
src/insets/InsetArgument.cpp
src/insets/InsetArgument.h
src/insets/InsetBibitem.cpp
src/insets/InsetBibitem.h
src/insets/InsetBox.cpp
src/insets/InsetBox.h
src/insets/InsetBranch.cpp
src/insets/InsetBranch.h
src/insets/InsetCollapsible.cpp
src/insets/InsetCollapsible.h
src/insets/InsetCommand.cpp
src/insets/InsetCommand.h
src/insets/InsetCommandParams.cpp
src/insets/InsetCommandParams.h
src/insets/InsetERT.cpp
src/insets/InsetExternal.cpp
src/insets/InsetExternal.h
src/insets/InsetFlex.cpp
src/insets/InsetFloat.cpp
src/insets/InsetFloat.h
src/insets/InsetFloatList.cpp
src/insets/InsetFloatList.h
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h
src/insets/InsetGraphicsParams.cpp
src/insets/InsetGraphicsParams.h
src/insets/InsetIPA.cpp
src/insets/InsetIPAMacro.cpp
src/insets/InsetIPAMacro.h
src/insets/InsetIndex.cpp
src/insets/InsetIndex.h
src/insets/InsetIndexMacro.cpp
src/insets/InsetIndexMacro.h
src/insets/InsetInfo.cpp
src/insets/InsetInfo.h
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h
src/insets/InsetListings.cpp
src/insets/InsetListings.h
src/insets/InsetListingsParams.cpp
src/insets/InsetListingsParams.h
src/insets/InsetNewline.cpp
src/insets/InsetNewline.h
src/insets/InsetNewpage.cpp
src/insets/InsetNewpage.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h
src/insets/InsetPhantom.cpp
src/insets/InsetPhantom.h
src/insets/InsetQuotes.cpp
src/insets/InsetQuotes.h
src/insets/InsetScript.cpp
src/insets/InsetScript.h
src/insets/InsetSeparator.cpp
src/insets/InsetSeparator.h
src/insets/InsetSpace.cpp
src/insets/InsetSpace.h
src/insets/InsetSpecialChar.cpp
src/insets/InsetSpecialChar.h
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
src/insets/InsetText.cpp
src/insets/InsetText.h
src/insets/InsetVSpace.cpp
src/insets/InsetVSpace.h
src/insets/InsetWrap.cpp
src/insets/InsetWrap.h
src/mathed/InsetMathHull.h
src/mathed/InsetMathMacroTemplate.cpp
src/mathed/InsetMathMacroTemplate.h
src/mathed/MathParser.cpp
src/mathed/MathParser.h
src/support/Lexer.cpp [new file with mode: 0644]
src/support/Lexer.h [new file with mode: 0644]
src/support/Makefile.am
src/tex2lyx/Preamble.cpp

index c9d6818df6d56eba46bb691a4c83a5f69e150ba5..f4a02ca4e521f35048b2026bc8c8d6719091841a 100644 (file)
@@ -41,7 +41,6 @@
 #include "LaTeXFeatures.h"
 #include "LaTeX.h"
 #include "Layout.h"
-#include "Lexer.h"
 #include "LyXAction.h"
 #include "LyX.h"
 #include "LyXRC.h"
@@ -95,6 +94,7 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/gzstream.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/mutex.h"
 #include "support/os.h"
index ee37098055a014dcd97e746f60c876fd464e841f..d9e7e325d4d9eae00e99a7d8b414a95b1fe4c25b 100644 (file)
@@ -39,7 +39,6 @@ class FuncRequest;
 class FuncStatus;
 class Inset;
 class InsetLabel;
-class Lexer;
 class Text;
 class LyXVC;
 class LaTeXFeatures;
@@ -67,6 +66,7 @@ namespace support {
 class DocFileName;
 class FileName;
 class FileNameList;
+class Lexer;
 } // namespace support
 
 namespace graphics {
@@ -226,7 +226,7 @@ public:
 //FIXME: The following function should be private
 //private:
        /// read the header, returns number of unknown tokens
-       int readHeader(Lexer & lex);
+       int readHeader(support::Lexer & lex);
 
        double fontScalingFactor() const;
        /// check for active synctex support:
@@ -247,14 +247,14 @@ private:
        /// Reads a file without header.
        /// \param par if != 0 insert the file.
        /// \return \c true if file is not completely read.
-       bool readDocument(Lexer &);
+       bool readDocument(support::Lexer &);
        /// Try to extract the file from a version control container
        /// before reading if the file cannot be found.
        /// \sa LyXVC::file_not_found_hook
        ReadStatus extractFromVC();
        /// Reads the first tag of a LyX File and
        /// returns the file format number.
-       ReadStatus parseLyXFormat(Lexer & lex, support::FileName const & fn,
+       ReadStatus parseLyXFormat(support::Lexer & lex, support::FileName const & fn,
                int & file_format) const;
        /// Convert the LyX file to the LYX_FORMAT using
        /// the lyx2lyx script and returns the filename
index 0d1600c5cf201f4efa3acf4d1f4f62bbfcf0ce6c..1324aaac9e1d55d030cc3019764a4639c60894cb 100644 (file)
@@ -33,7 +33,6 @@
 #include "LaTeXFeatures.h"
 #include "LaTeXFonts.h"
 #include "Font.h"
-#include "Lexer.h"
 #include "LyXRC.h"
 #include "OutputParams.h"
 #include "Spacing.h"
@@ -53,6 +52,7 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/Length.h"
+#include "support/Lexer.h"
 #include "support/Messages.h"
 #include "support/mutex.h"
 #include "support/Package.h"
index 489e0536868c65cf1289802e5b73b0ae82dafcc3..92c1418da1f2cb5e9c58ba2413a40e9c808b25a6 100644 (file)
 
 namespace lyx {
 
-namespace support { class FileName; }
+namespace support {
+class FileName;
+class Lexer;
+}
 
 class Author;
 class AuthorList;
@@ -48,7 +51,6 @@ class LaTeXFeatures;
 class LayoutFile;
 class LayoutFileIndex;
 class Length;
-class Lexer;
 class OutputParams;
 class otexstream;
 class PDFOptions;
@@ -79,7 +81,7 @@ public:
        docstring B_(std::string const & l10n) const;
 
        /// read a header token, if unrecognised, return it or an unknown class name
-       std::string readToken(Lexer & lex,
+       std::string readToken(support::Lexer & lex,
                std::string const & token, ///< token to read.
                support::FileName const & filename);
 
@@ -629,25 +631,25 @@ public:
 
 private:
        ///
-       void readPreamble(Lexer &);
+       void readPreamble(support::Lexer &);
        ///
-       void readDocumentMetadata(Lexer &);
+       void readDocumentMetadata(support::Lexer &);
        ///
-       void readLocalLayout(Lexer &, bool);
+       void readLocalLayout(support::Lexer &, bool);
        ///
-       void readLanguage(Lexer &);
+       void readLanguage(support::Lexer &);
        ///
-       void readGraphicsDriver(Lexer &);
+       void readGraphicsDriver(support::Lexer &);
        ///
-       void readBullets(Lexer &);
+       void readBullets(support::Lexer &);
        ///
-       void readBulletsLaTeX(Lexer &);
+       void readBulletsLaTeX(support::Lexer &);
        ///
-       void readModules(Lexer &);
+       void readModules(support::Lexer &);
        ///
-       void readRemovedModules(Lexer &);
+       void readRemovedModules(support::Lexer &);
        ///
-       void readIncludeonly(Lexer &);
+       void readIncludeonly(support::Lexer &);
        /// A cache for the default flavors
        typedef std::map<std::string, Flavor> DefaultFlavorCache;
        ///
index 006211c15a6a220cedfe953e235d31b7b7d24a38..292b0f6a014c11f392c74f777415a597eb7af161 100644 (file)
@@ -31,7 +31,6 @@
 #include "Intl.h"
 #include "Language.h"
 #include "LayoutFile.h"
-#include "Lexer.h"
 #include "LyX.h"
 #include "LyXAction.h"
 #include "lyxfind.h"
@@ -75,6 +74,7 @@
 #include "support/gettext.h"
 #include "support/lassert.h"
 #include "support/Length.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 #include "support/types.h"
index 6a1cef1a1185c97421f6a9750ad33003c74fafef..b12fa75edf280ce4dbdc96122a1e3569aa70672d 100644 (file)
 #include "CiteEnginesList.h"
 
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 
 #include "support/debug.h"
 #include "support/FileName.h"
 #include "support/gettext.h"
 #include "support/filetools.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
 
index 08cd7dd6a928e01812904f2eb4e854bbfc97f2e0..d813eba8e094c8c5fd651acd29894393e8117995 100644 (file)
 
 #include "FuncRequest.h"
 #include "LyXAction.h"
-#include "Lexer.h"
 
 #include "support/debug.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <string>
index 0f4d03efb9d42b9b1df356d9d8793cdf09df041c..86c5764801c5be1848201b4671230be6b922fdd0 100644 (file)
 #include "ConverterCache.h"
 
 #include "Format.h"
-#include "Lexer.h"
 #include "LyXRC.h"
 #include "Mover.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/filetools.h"
+#include "support/Lexer.h"
 #include "support/lyxtime.h"
 #include "support/Package.h"
 
index 114b18020b3d0b34690318f5046391f7e09314f3..703125f537f16d4a84723d16f0d40cb0f494906f 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "Counters.h"
 #include "Layout.h"
-#include "Lexer.h"
 
 #include "support/convert.h"
 #include "support/counter_reps.h"
@@ -23,6 +22,7 @@
 #include "support/docstring.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <algorithm>
index 5be4aca197b8df7b878f628f6d483452864da919..67a790fc0c93b3c5a96f6d6387cb0d5883dd2195 100644 (file)
@@ -26,7 +26,8 @@
 namespace lyx {
 
 class Layout;
-class Lexer;
+
+namespace support { class Lexer; }
 
 /// This represents a single counter.
 class Counter {
@@ -38,7 +39,7 @@ public:
                docstring const & lsa, docstring const & prettyformat,
                docstring const & guiname);
        /// \return true on success
-       bool read(Lexer & lex);
+       bool read(support::Lexer & lex);
        ///
        void set(int v);
        ///
@@ -142,7 +143,7 @@ public:
        /// \param makeNew whether to make a new counter if one
        ///        doesn't already exist
        /// \return true on success
-       bool read(Lexer & lex, docstring const & name, bool makenew);
+       bool read(support::Lexer & lex, docstring const & name, bool makenew);
        ///
        void set(docstring const & ctr, int val);
        ///
index dab24b72ddecf3c2c6eb0a8ba170cab1cf905e92..2dd3c9de8f6fd1e06c70657716a9ad593bfb6f5c 100644 (file)
 
 #include "Encoding.h"
 
-#include "Lexer.h"
-
 #include "support/debug.h"
 #include "support/docstring.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/mutex.h"
 #include "support/textutils.h"
index 7e0798d8ac59b123182b0b609b351d561c5f6db5..a4ae35727f344321e2d0bd4636f12c91c7503059 100644 (file)
@@ -21,7 +21,6 @@
 #include "Encoding.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "LyXRC.h"
 #include "output_latex.h"
 #include "OutputParams.h"
@@ -31,6 +30,7 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <cstring>
index 9f21bcc3d38e9c070c7433cd730d6d3b9fab93da..b6f45f88b5b49d6bf6bc2cafca0265e9ba0eb1ab 100644 (file)
 #include "FontInfo.h"
 
 #include "ColorSet.h"
-#include "Lexer.h"
 #include "LyXRC.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/docstring.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <algorithm>
index 3feefca662b562661ca8d626a3ddc737148e7735..bd0f125a7a594eb3285b2392b258fdfbc5fe05b3 100644 (file)
@@ -25,7 +25,7 @@
 
 namespace lyx {
 
-class Lexer;
+namespace support { class Lexer; }
 
 ///
 class FontInfo
@@ -257,7 +257,7 @@ void setLyXColor(std::string const &, FontInfo &);
 FontState setLyXMisc(std::string const &);
 
 /// Read a font specification from Lexer. Used for layout files.
-FontInfo lyxRead(Lexer &, FontInfo const & fi = sane_font);
+FontInfo lyxRead(support::Lexer &, FontInfo const & fi = sane_font);
 
 /// Write a font specification. Used for layout files.
 void lyxWrite(std::ostream &, FontInfo const &, std::string const &, int);
index c34fe7eefb9726afbc5d46bba821883e28895448..8552d7cd44e0c31fdd4de33d7ac6483ac0f8a257 100644 (file)
 
 #include "KeySequence.h"
 #include "LyXAction.h"
-#include "Lexer.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/TempFile.h"
 
index c9d030e8c343af500af6d0ac204da4c988bcbb43..655d4f17e18689670ebf9d50c08aea79d5787836 100644 (file)
@@ -13,7 +13,6 @@
 #include "LaTeXFonts.h"
 
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 
 #include "frontends/alert.h"
 
@@ -23,6 +22,7 @@
 #include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 
index 8aae4ae31c670291af0698a3a22e2dc77290add2..ce59b01d74b8b68c19ce7104be7fe4008c6201e1 100644 (file)
@@ -20,7 +20,7 @@
 
 namespace lyx {
 
-class Lexer;
+namespace support { class Lexer; }
 
 /// LaTeX Font definition
 class LaTeXFont {
@@ -96,9 +96,9 @@ public:
        /// Return the actually used package
        docstring const getUsedPackage(bool ot1, bool complete, bool nomath) const;
        ///
-       bool read(Lexer & lex);
+       bool read(support::Lexer & lex);
        ///
-       bool readFont(Lexer & lex);
+       bool readFont(support::Lexer & lex);
 private:
        /// Return the preferred available package
        std::string const getAvailablePackage(bool dryrun) const;
index 0f4129eabe2acd488cac1f70b284ffdabce988af..9e0ffe50241da2c27504a78ce44ee4049c1d9b37 100644 (file)
 
 #include "LaTeXPackages.h"
 
-#include "Lexer.h"
-
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Package.h"
 
index 884d1a039bb7078ba141013e693a6ba15b65843f..60b897c134c289f33225e1421dcef5e2e54d89d9 100644 (file)
@@ -18,7 +18,6 @@
 #include "BufferParams.h"
 #include "Encoding.h"
 #include "LaTeXFonts.h"
-#include "Lexer.h"
 #include "LyXRC.h"
 
 #include "support/debug.h"
@@ -26,6 +25,7 @@
 #include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/qstring_helpers.h"
 #include "support/Messages.h"
index ad8badffbc363ac05aaddd0eaf29b05b19da51d2..d8ef03a125fa325fcb2737d22367ddf35276283f 100644 (file)
 
 namespace lyx {
 
-namespace support { class FileName; }
+namespace support {
+class FileName;
+class Lexer;
+}
 
 class BufferParams;
 class Encoding;
-class Lexer;
 
 ///
 class Language {
@@ -99,9 +101,9 @@ public:
        /// This language corresponds to a translation of the GUI
        bool hasGuiSupport() const { return has_gui_support_; }
        ///
-       bool read(Lexer & lex);
+       bool read(support::Lexer & lex);
        ///
-       bool readLanguage(Lexer & lex);
+       bool readLanguage(support::Lexer & lex);
        ///
        typedef std::map<trivstring, trivdocstring> TranslationMap;
        ///
index 8e54891fb9b64d834d327d4fd92403a32b97b21f..50a4d05ac6b72b259071f82edc6c99f5edcd032a 100644 (file)
 #include <config.h>
 
 #include "Layout.h"
-#include "Lexer.h"
 #include "output_xhtml.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
index 6581155007860ce9dea4b0399cf69f49adb74d91..0c0b4ae0ef89f29a88c3ffafa16b6474077ecb9d 100644 (file)
@@ -26,7 +26,8 @@
 
 namespace lyx {
 
-class Lexer;
+namespace support { class Lexer; }
+
 class TextClass;
 
 /* Fixed labels are printed flushright, manual labels flushleft.
@@ -58,23 +59,23 @@ public:
        void setUnknown(bool unknown) { unknown_ = unknown; }
        /// Reads a layout definition from file
        /// \return true on success.
-       bool read(Lexer &, TextClass const &, bool validating = false);
+       bool read(support::Lexer &, TextClass const &, bool validating = false);
        ///
-       void readAlign(Lexer &);
+       void readAlign(support::Lexer &);
        ///
-       void readAlignPossible(Lexer &);
+       void readAlignPossible(support::Lexer &);
        ///
-       void readLabelType(Lexer &);
+       void readLabelType(support::Lexer &);
        ///
-       void readEndLabelType(Lexer &);
+       void readEndLabelType(support::Lexer &);
        ///
-       void readMargin(Lexer &);
+       void readMargin(support::Lexer &);
        ///
-       void readLatexType(Lexer &);
+       void readLatexType(support::Lexer &);
        ///
-       void readSpacing(Lexer &);
+       void readSpacing(support::Lexer &);
        ///
-       void readArgument(Lexer &, bool);
+       void readArgument(support::Lexer &, bool);
        /// Write a layout definition in utf8 encoding
        void write(std::ostream &) const;
        ///
@@ -439,7 +440,7 @@ public:
 private:
        /// Reads a layout definition from file
        /// \return true on success.
-       bool readIgnoreForcelocal(Lexer &, TextClass const &, bool validating);
+       bool readIgnoreForcelocal(support::Lexer &, TextClass const &, bool validating);
        /// generates the default CSS for this layout
        void makeDefaultCSS() const;
        ///
index 7944ad73a2731c2f00bdf94473c5b43a6ab9e8b0..3ed3676129fabe343e5c5242038b2dbe58dba560 100644 (file)
 #include <config.h>
 
 #include "LayoutFile.h"
-#include "Lexer.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/TempFile.h"
 
 #include <fstream>
diff --git a/src/Lexer.cpp b/src/Lexer.cpp
deleted file mode 100644 (file)
index b964eab..0000000
+++ /dev/null
@@ -1,927 +0,0 @@
-/**
- * \file Lexer.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author Lars Gullik Bjønnes
- * \author Jean-Marc Lasgouttes
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "Lexer.h"
-
-#include "support/convert.h"
-#include "support/debug.h"
-#include "support/FileName.h"
-#include "support/filetools.h"
-#include "support/gzstream.h"
-#include "support/lassert.h"
-#include "support/lstrings.h"
-#include "support/lyxalgo.h"
-
-#include <algorithm> // sort, lower_bound
-#include <functional>
-#include <fstream>
-#include <istream>
-#include <stack>
-#include <vector>
-
-using namespace std;
-using namespace lyx::support;
-
-namespace lyx {
-
-//////////////////////////////////////////////////////////////////////
-//
-// Lexer::Pimpl
-//
-//////////////////////////////////////////////////////////////////////
-
-
-///
-class Lexer::Pimpl {
-public:
-       ///
-       Pimpl(LexerKeyword * tab, int num);
-       ///
-       string const getString() const;
-       ///
-       docstring const getDocString() const;
-       ///
-       void printError(string const & message) const;
-       ///
-       void printTable(ostream & os);
-       ///
-       void pushTable(LexerKeyword * tab, int num);
-       ///
-       void popTable();
-       ///
-       bool setFile(FileName const & filename);
-       ///
-       void setStream(istream & i);
-       ///
-       void setCommentChar(char c);
-       ///
-       bool next(bool esc = false);
-       ///
-       int searchKeyword(char const * const tag) const;
-       ///
-       int lex();
-       ///
-       bool eatLine();
-       ///
-       bool nextToken();
-       /// test if there is a pushed token or the stream is ok
-       bool inputAvailable();
-       ///
-       void pushToken(string const &);
-       /// gz_ is only used to open files, the stream is accessed through is.
-       gz::gzstreambuf gz_;
-
-       /// the stream that we use.
-       istream is;
-       ///
-       string name;
-       ///
-       LexerKeyword * table;
-       ///
-       int no_items;
-       ///
-       string buff;
-       ///
-       int status;
-       ///
-       int lineno;
-       ///
-       string pushTok;
-       /// used for error messages
-       string context;
-       ///
-       char commentChar;
-private:
-       /// non-copyable
-       Pimpl(Pimpl const &);
-       void operator=(Pimpl const &);
-
-       ///
-       void verifyTable();
-       ///
-       class PushedTable {
-       public:
-               ///
-               PushedTable()
-                       : table_elem(nullptr), table_siz(0) {}
-               ///
-               PushedTable(LexerKeyword * ki, int siz)
-                       : table_elem(ki), table_siz(siz) {}
-               ///
-               LexerKeyword * table_elem;
-               ///
-               int table_siz;
-       };
-       ///
-       stack<PushedTable> pushed;
-};
-
-
-namespace {
-
-// used by lower_bound, sort and sorted
-bool compareTags(LexerKeyword const & a, LexerKeyword const & b)
-{
-       // we use the ascii version, because in turkish, 'i'
-       // is not the lowercase version of 'I', and thus
-       // turkish locale breaks parsing of tags.
-       return compare_ascii_no_case(a.tag, b.tag) < 0;
-}
-
-} // namespace
-
-
-
-Lexer::Pimpl::Pimpl(LexerKeyword * tab, int num)
-       : is(&gz_), table(tab), no_items(num),
-         status(0), lineno(0), commentChar('#')
-{
-       verifyTable();
-}
-
-
-string const Lexer::Pimpl::getString() const
-{
-       return buff;
-}
-
-
-docstring const Lexer::Pimpl::getDocString() const
-{
-       return from_utf8(buff);
-}
-
-
-void Lexer::Pimpl::printError(string const & message) const
-{
-       string const tmpmsg = subst(message, "$$Token", getString());
-       lyxerr << "LyX: " << tmpmsg << " [around line " << lineno
-               << " of file " << to_utf8(makeDisplayPath(name))
-               << " current token: '" << getString() << "'"
-               << " context: '" << context << "']" << endl;
-}
-
-
-void Lexer::Pimpl::printTable(ostream & os)
-{
-       os << "\nNumber of tags: " << no_items << endl;
-       for (int i= 0; i < no_items; ++i)
-               os << "table[" << i
-                  << "]:  tag: `" << table[i].tag
-                  << "'  code:" << table[i].code << '\n';
-       os.flush();
-}
-
-
-void Lexer::Pimpl::verifyTable()
-{
-       // Check if the table is sorted and if not, sort it.
-       if (table
-           && !lyx::sorted(table, table + no_items, &compareTags)) {
-               lyxerr << "The table passed to Lexer is not sorted!\n"
-                      << "Tell the developers to fix it!" << endl;
-               // We sort it anyway to avoid problems.
-               lyxerr << "\nUnsorted:" << endl;
-               printTable(lyxerr);
-
-               sort(table, table + no_items, &compareTags);
-               lyxerr << "\nSorted:" << endl;
-               printTable(lyxerr);
-       }
-}
-
-
-void Lexer::Pimpl::pushTable(LexerKeyword * tab, int num)
-{
-       PushedTable tmppu(table, no_items);
-       pushed.push(tmppu);
-
-       table = tab;
-       no_items = num;
-
-       verifyTable();
-}
-
-
-void Lexer::Pimpl::popTable()
-{
-       if (pushed.empty()) {
-               lyxerr << "Lexer error: nothing to pop!" << endl;
-               return;
-       }
-
-       PushedTable tmp = pushed.top();
-       pushed.pop();
-       table = tmp.table_elem;
-       no_items = tmp.table_siz;
-}
-
-
-bool Lexer::Pimpl::setFile(FileName const & filename)
-{
-               if (gz_.is_open() || istream::off_type(is.tellg()) > -1)
-                       LYXERR0("Error in LyXLex::setFile: file or stream already set.");
-               gz_.open(filename.toSafeFilesystemEncoding().c_str(), ios::in);
-               is.rdbuf(&gz_);
-               name = filename.absFileName();
-               lineno = 0;
-               if (!gz_.is_open() || !is.good())
-                       return false;
-
-       // Skip byte order mark.
-       if (is.peek() == 0xef) {
-               is.get();
-               if (is.peek() == 0xbb) {
-                       is.get();
-                       LASSERT(is.get() == 0xbf, /**/);
-               } else
-                       is.unget();
-       }
-
-       return true;
-}
-
-
-void Lexer::Pimpl::setStream(istream & i)
-{
-       if (gz_.is_open() || istream::off_type(is.tellg()) > 0)
-               LYXERR0("Error in Lexer::setStream: file or stream already set.");
-       is.rdbuf(i.rdbuf());
-       lineno = 0;
-}
-
-
-void Lexer::Pimpl::setCommentChar(char c)
-{
-       commentChar = c;
-}
-
-
-bool Lexer::Pimpl::next(bool esc /* = false */)
-{
-       if (!pushTok.empty()) {
-               // There can have been a whole line pushed so
-               // we extract the first word and leaves the rest
-               // in pushTok. (Lgb)
-               if (pushTok[0] == '\\' && pushTok.find(' ') != string::npos) {
-                       buff.clear();
-                       pushTok = split(pushTok, buff, ' ');
-               } else {
-                       buff = pushTok;
-                       pushTok.clear();
-               }
-               status = LEX_TOKEN;
-               return true;
-       }
-
-
-       char cc = 0;
-       status = 0;
-       while (is && !status) {
-               is.get(cc);
-               unsigned char c = cc;
-
-               if (c == commentChar) {
-                       // Read rest of line (fast :-)
-#if 1
-                       // That is not fast... (Lgb)
-                       string dummy;
-                       getline(is, dummy);
-
-                       LYXERR(Debug::LYXLEX, "Comment read: `" << string(1, c) << dummy << '\'');
-#else
-                       // unfortunately ignore is buggy (Lgb)
-                       is.ignore(100, '\n');
-#endif
-                       ++lineno;
-                       continue;
-               }
-
-               if (c == '\"') {
-                       buff.clear();
-
-                       if (esc) {
-
-                               do {
-                                       bool escaped = false;
-                                       is.get(cc);
-                                       c = cc;
-                                       if (c == '\r') continue;
-                                       if (c == '\\') {
-                                               // escape the next char
-                                               is.get(cc);
-                                               c = cc;
-                                               if (c == '\"' || c == '\\')
-                                                       escaped = true;
-                                               else
-                                                       buff.push_back('\\');
-                                       }
-                                       buff.push_back(c);
-
-                                       if (!escaped && c == '\"')
-                                               break;
-                               } while (c != '\n' && is);
-
-                       } else {
-
-                               do {
-                                       is.get(cc);
-                                       c = cc;
-                                       if (c != '\r')
-                                               buff.push_back(c);
-                               } while (c != '\"' && c != '\n' && is);
-
-                       }
-
-                       if (c != '\"') {
-                               printError("Missing quote");
-                               if (c == '\n')
-                                       ++lineno;
-                       }
-
-                       buff.resize(buff.size() - 1);
-                       status = LEX_DATA;
-                       break;
-               }
-
-               if (c == ',')
-                       continue;              /* Skip ','s */
-
-               // using relational operators with chars other
-               // than == and != is not safe. And if it is done
-               // the type _have_ to be unsigned. It usually a
-               // lot better to use the functions from cctype
-               if (c > ' ' && is)  {
-                       buff.clear();
-
-                       do {
-                               if (esc && c == '\\') {
-                                       // escape the next char
-                                       is.get(cc);
-                                       c = cc;
-                                       //escaped = true;
-                               }
-                               buff.push_back(c);
-                               is.get(cc);
-                               c = cc;
-                       } while (c > ' ' && c != ',' && is);
-                       status = LEX_TOKEN;
-               }
-
-               if (c == '\r' && is) {
-                       // The Windows support has lead to the
-                       // possibility of "\r\n" at the end of
-                       // a line.  This will stop LyX choking
-                       // when it expected to find a '\n'
-                       is.get(cc);
-                       c = cc;
-               }
-
-               if (c == '\n')
-                       ++lineno;
-
-       }
-       if (status)
-               return true;
-
-       status = is.eof() ? LEX_FEOF: LEX_UNDEF;
-       buff.clear();
-       return false;
-}
-
-
-int Lexer::Pimpl::searchKeyword(char const * const tag) const
-{
-       LexerKeyword search_tag = { tag, 0 };
-       LexerKeyword * res =
-               lower_bound(table, table + no_items,
-                           search_tag, &compareTags);
-       // use the compare_ascii_no_case instead of compare_no_case,
-       // because in turkish, 'i' is not the lowercase version of 'I',
-       // and thus turkish locale breaks parsing of tags.
-       if (res != table + no_items
-           && !compare_ascii_no_case(res->tag, tag))
-               return res->code;
-       return LEX_UNDEF;
-}
-
-
-int Lexer::Pimpl::lex()
-{
-       //NOTE: possible bug.
-       if (next() && status == LEX_TOKEN)
-               return searchKeyword(getString().c_str());
-       return status;
-}
-
-
-bool Lexer::Pimpl::eatLine()
-{
-       buff.clear();
-
-       unsigned char c = '\0';
-       char cc = 0;
-       while (is && c != '\n') {
-               is.get(cc);
-               c = cc;
-               //LYXERR(Debug::LYXLEX, "Lexer::EatLine read char: `" << c << '\'');
-               if (c != '\r' && is)
-                       buff.push_back(c);
-       }
-
-       if (c == '\n') {
-               ++lineno;
-               buff.resize(buff.size() - 1);
-               status = LEX_DATA;
-               return true;
-       } else if (buff.length() > 0) { // last line
-               status = LEX_DATA;
-               return true;
-       } else {
-               return false;
-       }
-}
-
-
-bool Lexer::Pimpl::nextToken()
-{
-       if (!pushTok.empty()) {
-               // There can have been a whole line pushed so
-               // we extract the first word and leaves the rest
-               // in pushTok. (Lgb)
-               if (pushTok[0] == '\\' && pushTok.find(' ') != string::npos) {
-                       buff.clear();
-                       pushTok = split(pushTok, buff, ' ');
-               } else {
-                       buff = pushTok;
-                       pushTok.clear();
-               }
-               status = LEX_TOKEN;
-               return true;
-       }
-
-       status = 0;
-       while (is && !status) {
-               unsigned char c = 0;
-               char cc = 0;
-               is.get(cc);
-               c = cc;
-               if ((c >= ' ' || c == '\t') && is) {
-                       buff.clear();
-
-                       if (c == '\\') { // first char == '\\'
-                               do {
-                                       buff.push_back(c);
-                                       is.get(cc);
-                                       c = cc;
-                               } while (c > ' ' && c != '\\' && is);
-                       } else {
-                               do {
-                                       buff.push_back(c);
-                                       is.get(cc);
-                                       c = cc;
-                               } while ((c >= ' ' || c == '\t') && c != '\\' && is);
-                       }
-
-                       if (c == '\\')
-                               is.putback(c); // put it back
-                       status = LEX_TOKEN;
-               }
-
-               if (c == '\n')
-                       ++lineno;
-
-       }
-       if (status)
-               return true;
-
-       status = is.eof() ? LEX_FEOF: LEX_UNDEF;
-       buff.clear();
-       return false;
-}
-
-
-bool Lexer::Pimpl::inputAvailable()
-{
-       return is.good();
-}
-
-
-void Lexer::Pimpl::pushToken(string const & pt)
-{
-       pushTok = pt;
-}
-
-
-
-
-//////////////////////////////////////////////////////////////////////
-//
-// Lexer
-//
-//////////////////////////////////////////////////////////////////////
-
-Lexer::Lexer()
-       : pimpl_(new Pimpl(nullptr, 0)), lastReadOk_(false)
-{}
-
-
-void Lexer::init(LexerKeyword * tab, int num)
-{
-        pimpl_ = new Pimpl(tab, num);
-}
-
-
-Lexer::~Lexer()
-{
-       delete pimpl_;
-}
-
-
-bool Lexer::isOK() const
-{
-       return pimpl_->inputAvailable();
-}
-
-
-void Lexer::setLineNumber(int l)
-{
-       pimpl_->lineno = l;
-}
-
-
-int Lexer::lineNumber() const
-{
-       return pimpl_->lineno;
-}
-
-
-istream & Lexer::getStream()
-{
-       return pimpl_->is;
-}
-
-
-void Lexer::pushTable(LexerKeyword * tab, int num)
-{
-       pimpl_->pushTable(tab, num);
-}
-
-
-void Lexer::popTable()
-{
-       pimpl_->popTable();
-}
-
-
-void Lexer::printTable(ostream & os)
-{
-       pimpl_->printTable(os);
-}
-
-
-void Lexer::printError(string const & message) const
-{
-       pimpl_->printError(message);
-}
-
-
-bool Lexer::setFile(FileName const & filename)
-{
-       return pimpl_->setFile(filename);
-}
-
-
-void Lexer::setStream(istream & i)
-{
-       pimpl_->setStream(i);
-}
-
-
-void Lexer::setCommentChar(char c)
-{
-       pimpl_->setCommentChar(c);
-}
-
-
-int Lexer::lex()
-{
-       return pimpl_->lex();
-}
-
-
-int Lexer::getInteger() const
-{
-       lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
-       if (!lastReadOk_) {
-               pimpl_->printError("integer token missing");
-               return -1;
-       }
-
-       if (isStrInt(pimpl_->getString()))
-               return convert<int>(pimpl_->getString());
-
-       lastReadOk_ = false;
-       pimpl_->printError("Bad integer `$$Token'");
-       return -1;
-}
-
-
-double Lexer::getFloat() const
-{
-       // replace comma with dot in case the file was written with
-       // the wrong locale (should be rare, but is easy enough to
-       // avoid).
-       lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
-       if (!lastReadOk_) {
-               pimpl_->printError("float token missing");
-               return -1;
-       }
-
-       string const str = subst(pimpl_->getString(), ",", ".");
-       if (isStrDbl(str))
-               return convert<double>(str);
-
-       lastReadOk_ = false;
-       pimpl_->printError("Bad float `$$Token'");
-       return -1;
-}
-
-
-string const Lexer::getString(bool trim) const
-{
-       lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
-
-       if (lastReadOk_)
-               return trim ? support::trim(pimpl_->getString(), "\t ") : pimpl_->getString();
-
-       return string();
-}
-
-
-docstring const Lexer::getDocString(bool trim) const
-{
-       lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
-
-       if (lastReadOk_)
-               return trim ? support::trim(pimpl_->getDocString(), "\t ") : pimpl_->getDocString();
-
-       return docstring();
-}
-
-
-// I would prefer to give a tag number instead of an explicit token
-// here, but it is not possible because Buffer::readDocument uses
-// explicit tokens (JMarc)
-docstring Lexer::getLongString(docstring const & endtoken)
-{
-       docstring str;
-       docstring prefix;
-       bool firstline = true;
-       bool foundend = false;
-
-       while (pimpl_->is) { //< eatLine only reads from is, not from pushTok
-               if (!eatLine())
-                       // blank line in the file being read
-                       continue;
-               docstring tmpstr = getDocString();
-               docstring const token = trim(tmpstr, " \t");
-
-               LYXERR(Debug::PARSER, "LongString: `" << tmpstr << '\'');
-
-               // We do a case independent comparison, like searchKeyword does.
-               if (compare_no_case(token, endtoken) == 0) {
-                       foundend = true;
-                       break;
-               }
-
-               if (firstline) {
-                       size_t i = tmpstr.find_first_not_of(from_ascii(" \t"));
-                       if (i != string::npos)
-                               prefix = tmpstr.substr(0, i);
-                       firstline = false;
-                       LYXERR(Debug::PARSER, "Prefix = `" << prefix << "\'");
-               }
-
-               // further lines in long strings may have the same
-               // whitespace prefix as the first line. Remove it.
-               if (!prefix.empty() && prefixIs(tmpstr, prefix))
-                       tmpstr.erase(0, prefix.length());
-
-               str += tmpstr + '\n';
-       }
-
-       if (!foundend)
-               printError("Long string not ended by `" + to_utf8(endtoken) + '\'');
-
-       return str;
-}
-
-
-bool Lexer::getBool() const
-{
-       string const s = pimpl_->getString();
-       if (s == "false" || s == "0") {
-               lastReadOk_ = true;
-               return false;
-       }
-       if (s == "true" || s == "1") {
-               lastReadOk_ = true;
-               return true;
-       }
-       pimpl_->printError("Bad boolean `$$Token'. "
-                                "Use \"false\" or \"true\"");
-       lastReadOk_ = false;
-       return false;
-}
-
-
-bool Lexer::eatLine()
-{
-       return pimpl_->eatLine();
-}
-
-
-bool Lexer::next(bool esc)
-{
-       return pimpl_->next(esc);
-}
-
-
-bool Lexer::nextToken()
-{
-       return pimpl_->nextToken();
-}
-
-
-void Lexer::pushToken(string const & pt)
-{
-       pimpl_->pushToken(pt);
-}
-
-
-Lexer::operator void const *() const
-{
-       // This behaviour is NOT the same as the streams which would
-       // use fail() here. However, our implementation of getString() et al.
-       // can cause the eof() and fail() bits to be set, even though we
-       // haven't tried to read 'em.
-       return lastReadOk_? this : nullptr;
-}
-
-
-bool Lexer::operator!() const
-{
-       return !lastReadOk_;
-}
-
-
-Lexer & Lexer::operator>>(string & s)
-{
-       if (isOK()) {
-               next();
-               s = getString();
-       } else {
-               lastReadOk_ = false;
-       }
-       return *this;
-}
-
-
-Lexer & Lexer::operator>>(docstring & s)
-{
-       if (isOK()) {
-               next();
-               s = getDocString();
-       } else {
-               lastReadOk_ = false;
-       }
-       return *this;
-}
-
-
-Lexer & Lexer::operator>>(double & s)
-{
-       if (isOK()) {
-               next();
-               s = getFloat();
-       } else {
-               lastReadOk_ = false;
-       }
-       return *this;
-}
-
-
-Lexer & Lexer::operator>>(int & s)
-{
-       if (isOK()) {
-               next();
-               s = getInteger();
-       } else {
-               lastReadOk_ = false;
-       }
-       return *this;
-}
-
-
-Lexer & Lexer::operator>>(unsigned int & s)
-{
-       if (isOK()) {
-               next();
-               s = getInteger();
-       } else {
-               lastReadOk_ = false;
-       }
-       return *this;
-}
-
-
-Lexer & Lexer::operator>>(bool & s)
-{
-       if (isOK()) {
-               next();
-               s = getBool();
-       } else {
-               lastReadOk_ = false;
-       }
-       return *this;
-}
-
-
-Lexer & Lexer::operator>>(char & c)
-{
-       string s;
-       operator>>(s);
-       if (!s.empty())
-               c = s[0];
-       return *this;
-}
-
-
-// quotes a string, e.g. for use in preferences files or as an argument
-// of the "log" dialog
-string Lexer::quoteString(string const & arg)
-{
-       string res;
-       res += '"';
-       res += subst(subst(arg, "\\", "\\\\"), "\"", "\\\"");
-       res += '"';
-       return res;
-}
-
-
-// same for docstring
-docstring Lexer::quoteString(docstring const & arg)
-{
-       docstring res;
-       res += '"';
-       res += subst(subst(arg, from_ascii("\\"), from_ascii("\\\\")),
-                    from_ascii("\""), from_ascii("\\\""));
-       res += '"';
-       return res;
-}
-
-
-Lexer & Lexer::operator>>(char const * required)
-{
-       string token;
-       *this >> token;
-       if (token != required) {
-               LYXERR0("Missing '" << required << "'-tag in " << pimpl_->context
-                       << ". Got " << token << " instead. Line: " << lineNumber());
-               pushToken(token);
-       }
-       return *this;
-}
-
-
-bool Lexer::checkFor(char const * required)
-{
-       string token;
-       *this >> token;
-       if (token == required)
-               return true;
-       pushToken(token);
-       return false;
-}
-
-
-void Lexer::setContext(std::string const & functionName)
-{
-       pimpl_->context = functionName;
-}
-
-
-} // namespace lyx
diff --git a/src/Lexer.h b/src/Lexer.h
deleted file mode 100644 (file)
index 02ec747..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-// -*- C++ -*-
-/**
- * \file Lexer.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-//  Generalized simple lexical analizer.
-//  It can be used for simple syntax parsers, like lyxrc,
-//  texclass and others to come.
-
-#ifndef LEXER_H
-#define LEXER_H
-
-#include "support/strfwd.h"
-#include <string>
-
-namespace lyx {
-
-namespace support { class FileName; }
-
-/** A helper structure to describe a keyword for the Lexer.
-       Usually used bundled in C style arrays and passed to the
-       Lexer using a LexerKeywordTable object.
-*/
-struct LexerKeyword
-{
-       /// the string to be recognized
-       char const * tag;
-       /// a corresponding numerical id
-       int code;
-};
-
-
-/** Generalized simple lexical analizer.
-       Use the method isOK() to check if there is still data available
-       for lexing. Use one of the the operators void* or ! to test if
-       the last reading operation was successful.
-
-       Example:
-
-       int readParam(LyxLex & lex)
-       {
-               int param = 1;    // default value
-               if (lex.isOK()) { // the lexer has data to read
-                       int p;          // temporary variable
-                       lex >> p;
-                       if (lex)
-                               param = p; // only use the input if reading was successful
-               }
-               return param;
-       }
-
-    @see LyXRC.cpp for an example of usage.
-  */
-class Lexer
-{
-public:
-       /// initialize Lexer with no special keywords.
-       Lexer();
-       /// initialize Lexer with a bunch of keywords
-       template<int N> Lexer(LexerKeyword (&table)[N])
-       : pimpl_(0), lastReadOk_(false) { init(table, N); }
-
-       ///
-       ~Lexer();
-
-       /// Lex basic codes
-       enum {
-               ///
-               LEX_UNDEF = -1,
-               ///
-               LEX_FEOF  = -2,
-               ///
-               LEX_DATA  = -3,
-               ///
-               LEX_TOKEN = -4
-       };
-
-       /// stream is open and end of stream is not reached
-       /// FIXME: test also if pushToken is not empty
-       /// FIXME: the method should be renamed to something like
-       ///        dataAvailable(), in order to reflect the real behavior
-       bool isOK() const;
-       /// FIXME: The next two operators should be replaced by one method
-       ///        called e.g. lastReadOk(), in order to reflect the real
-       ///        behavior
-       /// last read operation was successful.
-       operator void const *() const;
-       /// last read operation was not successful
-       bool operator!() const;
-       /// return true if able to open file, else false
-       bool setFile(support::FileName const & filename);
-       ///
-       void setStream(std::istream & is);
-       ///
-       std::istream & getStream();
-       /// Danger! Don't use it unless you know what you are doing.
-       void setLineNumber(int l);
-       /// Change the character that begins a comment. Default is '#'
-       void setCommentChar(char c);
-
-       /// returns a lex code
-       int lex();
-
-       /// Read the next string, as delimited by double quotes or
-       /// whitespace. If esc is true, then we remember that some chars
-       /// might be escaped: \" at least.
-       bool next(bool esc = false);
-
-       /// Read next token. This one is almost the same as next(),
-       /// but it will consider " as a regular character and always
-       /// split a word if it contains a backslash.
-       bool nextToken();
-
-       /// Puts the rest of the line in the buffer, where it will
-       /// be available via getString() or getDocString().
-       bool eatLine();
-
-       /// Push a token, that next token got from lyxlex.
-       void pushToken(std::string const &);
-
-       /// return the current line number
-       int lineNumber() const;
-
-       ///
-       int getInteger() const;
-       ///
-       bool getBool() const;
-       ///
-       double getFloat() const;
-       ///
-       std::string const getString(bool trim = false) const;
-       ///
-       docstring const getDocString(bool trim = false) const;
-       /** Get a long string, ended by the tag `endtoken'. This string
-           can span several lines. The first line serves as a template
-           for what sequence of tabs and spaces make up the indentation.
-           This prefix is skipped from each following line.
-       */
-       docstring getLongString(docstring const & endtoken);
-
-       /// Pushes a token list on a stack and replaces it with a new one.
-       template<int N> void pushTable(LexerKeyword (&table)[N])
-               { pushTable(table, N); }
-
-       /** Pops a token list into void and replaces it with the one now
-           on top of the stack.
-       */
-       void popTable();
-
-       /** Prints an error message with the corresponding line number
-           and file name. If message contains the substring `$$Token',
-           it is replaced with the value of GetString()
-       */
-       void printError(std::string const & message) const;
-
-       /// Prints the current token table on the supplied ostream.
-       void printTable(std::ostream &);
-       /// Used to dispaly context information in case of errors.
-       void setContext(std::string const & functionName);
-
-       /// extract string
-       Lexer & operator>>(std::string &);
-       /// extract docstring
-       Lexer & operator>>(docstring &);
-       /// extract double
-       Lexer & operator>>(double &);
-       /// extract integer
-       Lexer & operator>>(int &);
-       /// extract unsigned integer
-       Lexer & operator>>(unsigned int &);
-       /// extract bool
-       Lexer & operator>>(bool &);
-       /// extract first char of the string
-       Lexer & operator>>(char &);
-
-       /// read and check a required token
-       Lexer & operator>>(char const * required);
-       /// check for an optional token and swallow it if present.
-       bool checkFor(char const * required);
-
-       /// Quotes a string so that reading it again with Lexer::next(true)
-       /// gets the original string
-       static std::string quoteString(std::string const &);
-       /// Quotes a docstring so that reading it again with Lexer::next(true)
-       /// gets the original string
-       static docstring quoteString(docstring const &);
-
-private:
-       /// noncopyable
-       Lexer(Lexer const &);
-       void operator=(Lexer const &);
-
-       ///
-       friend class PushPopHelper;
-
-       ///
-       void init(LexerKeyword *, int);
-       void pushTable(LexerKeyword *, int);
-
-       ///
-       class Pimpl;
-       ///
-       Pimpl * pimpl_;
-       ///
-       mutable bool lastReadOk_;
-};
-
-
-/// extract something constructable from a string, i.e. a LaTeX length
-template <class T>
-Lexer & operator>>(Lexer & lex, T & t)
-{
-       if (lex.next())
-               t = T(lex.getString());
-       return lex;
-}
-
-
-/** Use to enable multiple exit points.
-    This is needed to ensure that the pop is done upon exit from methods
-    with more than one exit point or that can return as a response to
-    exceptions.
-    @author Lgb
-*/
-class PushPopHelper
-{
-public:
-       ///
-       template<int N>
-       PushPopHelper(Lexer & l, LexerKeyword (&table)[N])
-               : lex(l)
-       {
-               lex.pushTable(table, N);
-       }
-       ///
-       ~PushPopHelper()
-       {
-               lex.popTable();
-       }
-       ///
-       Lexer & lex;
-};
-/** Avoid wrong usage of PushPopHelper.
-    To avoid wrong usage:
-    PushPopHelper(...); // wrong
-    PushPopHelper pph(...); // right
-*/
-#define PushPopHelper(x, y, z) unnamed_PushPopHelper;
-// Tip gotten from Bobby Schmidt's column in C/C++ Users Journal
-
-
-} // namespace lyx
-
-#endif
index 73aec189f30cc38b6e7cb28e73167cbf85c4fd73..9c8decab43269f593fee3bd94fffa5ca2e9cf50b 100644 (file)
@@ -25,7 +25,6 @@
 #include "Format.h"
 #include "FuncCode.h"
 #include "FuncRequest.h"
-#include "Lexer.h"
 #include "LyX.h"
 #include "Mover.h"
 #include "SpellChecker.h"
@@ -36,6 +35,7 @@
 #include "support/environment.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Package.h"
index 039cf5658ce6a0a700b5d5b51ff96d8abcbe0730..c437021c068f9d40e6180d83f8ed69d54932d97e 100644 (file)
 
 namespace lyx {
 
-namespace support { class FileName; }
-
+namespace support {
+class FileName;
 class Lexer;
+}
 
 /// This contains the runtime configuration of LyX
 class LyXRC
@@ -212,7 +213,7 @@ private:
                FormatMismatch
        };
        ///
-       ReturnValues read(Lexer &, bool check_format);
+       ReturnValues read(support::Lexer &, bool check_format);
 public:
        ///
        typedef std::set<std::string> CommandSet;
index 86a90bb2bba225910c80d73020800167c981b4a5..47a8e1ead585fe562f46da1e7e91636e747d6a35 100644 (file)
@@ -147,7 +147,6 @@ SOURCEFILESCORE = \
        LaTeXPackages.cpp \
        LayoutFile.cpp \
        LayoutModuleList.cpp \
-       Lexer.cpp \
        LyX.cpp \
        LyXAction.cpp \
        lyxfind.cpp \
@@ -247,7 +246,6 @@ HEADERFILESCORE = \
        LayoutEnums.h \
        LayoutFile.h \
        LayoutModuleList.h \
-       Lexer.h \
        LyXAction.h \
        lyxfind.h \
        LyX.h \
index d8fd34cc729437bab7c7ef45eb0f6b5affbe27c0..83f5a759400e02f47662a5a77afba0337dad4d6a 100644 (file)
 #include "ModuleList.h"
 
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 
 #include "support/debug.h"
 #include "support/FileName.h"
 #include "support/gettext.h"
 #include "support/filetools.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <algorithm>
index dc638f544dafb3638f6ad020fd7cff93c3414fd2..c3d057eba8d17d882acded2da52382e600454b18 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "Encoding.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "OutputParams.h"
 #include "texstream.h"
 
@@ -23,6 +22,7 @@
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/docstring.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <sstream>
index 4ab0d9e3ad7488c52d8f1d0943b5533e992894e6..e013566c14b10e384c7c8f769cd4be1e574138ee 100644 (file)
 
 namespace lyx {
 
-class Lexer;
 class OutputParams;
 class otexstream;
 
+namespace support { class Lexer; }
+
 // FIXME UNICODE
 // Write functions need to use odostream instead of ostream before
 // we can use docstring instead of string.
@@ -37,7 +38,7 @@ public:
        void writeLaTeX(OutputParams &, otexstream &,
                        bool hyperref_already_provided) const;
        /// read tokens from lyx header
-       std::string readToken(Lexer &lex, std::string const & token);
+       std::string readToken(support::Lexer &lex, std::string const & token);
        /// set implicit settings for hyperref
        void clear();
 
index 72b2286b1284588385a5adaa924fa863dbae2f14..32dc44900b35b798c9e380f7e614588e1b51f489 100644 (file)
 #include "ParagraphParameters.h"
 
 #include "Layout.h"
-#include "Lexer.h"
 #include "Paragraph.h"
 
 #include "support/debug.h"
 #include "support/docstring.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <sstream>
index 07601e9e33faf415d75a3498f57a2239298315eb..6f5b4f1b3f0b8f114370f9bcc5a189decca89f98 100644 (file)
 namespace lyx {
 
 class Layout;
-class Lexer;
 class Paragraph;
 
+namespace support { class Lexer; }
+
 
 ///
 class ParagraphParameters {
@@ -79,7 +80,7 @@ public:
        void read (std::string const & str, bool merge = true);
 
        /// read the parameters from a lex
-       void read(Lexer & lex, bool merge = true);
+       void read(support::Lexer & lex, bool merge = true);
 
        ///
        void apply(ParagraphParameters const & params, Layout const & layout);
index 1f9696de0db4b82f691e41d04e8294a4a3f84cca..55e150d6ac263fa9c46f4714f73b56a0acbcf893 100644 (file)
@@ -45,7 +45,6 @@
 #include "Intl.h"
 #include "Language.h"
 #include "Layout.h"
-#include "Lexer.h"
 #include "LyX.h"
 #include "LyXAction.h"
 #include "lyxfind.h"
@@ -95,6 +94,7 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/limited_stack.h"
 #include "support/lstrings.h"
 #include "support/lyxtime.h"
index 8dc066a1613cf5c5b2bd539fc5a98a978109cdbc..9ef9c9626054274cbc1f962c23bbbc790a87e5f5 100644 (file)
@@ -33,10 +33,11 @@ class FuncRequest;
 class FuncStatus;
 class Inset;
 class InsetText;
-class Lexer;
 class Paragraph;
 class ParagraphParameters;
 
+namespace support { class Lexer; }
+
 /// This class encapsulates the main text data and operations in LyX.
 /// This is more or less the private implementation of InsetText.
 class Text {
@@ -299,7 +300,7 @@ public:
        void write(std::ostream & os) const;
        /// returns true if \end_document has not been read
        /// insetPtr is the containing Inset
-       bool read(Lexer & lex, ErrorList & errorList,
+       bool read(support::Lexer & lex, ErrorList & errorList,
                  InsetText * insetPtr);
 
        /// delete double spaces, leading spaces, and empty paragraphs around old cursor.
@@ -381,10 +382,10 @@ private:
        void pasteString(Cursor & cur, docstring const & str,
                        bool asParagraphs);
        ///
-       void readParToken(Paragraph & par, Lexer & lex, std::string const & token,
+       void readParToken(Paragraph & par, support::Lexer & lex, std::string const & token,
                Font & font, Change & change, ErrorList & errorList);
        ///
-       void readParagraph(Paragraph & par, Lexer & lex, ErrorList & errorList);
+       void readParagraph(Paragraph & par, support::Lexer & lex, ErrorList & errorList);
        /// Set Label Width string to all paragraphs of the same layout
        /// and depth in a sequence.
        void setLabelWidthStringToSequence(Cursor const & cur, docstring const & s);
index f6ec875167bec63b1b0186cbcdce79f05d840301..339d8c90cf860d308a60df693c8ca3fc79b5748b 100644 (file)
@@ -22,7 +22,6 @@
 #include "FloatList.h"
 #include "Layout.h"
 #include "LayoutFile.h"
-#include "Lexer.h"
 #include "ModuleList.h"
 
 #include "frontends/alert.h"
@@ -32,6 +31,7 @@
 #include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/TempFile.h"
index a4c758f3394569c6ccee89fadd6080e6ed3bee06..2f4213349172760e1b705dd858028934de367f4d 100644 (file)
 
 namespace lyx {
 
-namespace support { class FileName; }
+namespace support {
+class FileName;
+class Lexer;
+}
 
 class FloatList;
 class Layout;
 class LayoutFile;
-class Lexer;
 
 /// Based upon ideas in boost::noncopyable, inheriting from this
 /// class effectively makes the copy constructor protected but the
@@ -167,7 +169,7 @@ public:
        ///
        ReturnValues read(std::string const & str, ReadType rt = MODULE);
        ///
-       ReturnValues read(Lexer & lex, ReadType rt = BASECLASS);
+       ReturnValues read(support::Lexer & lex, ReadType rt = BASECLASS);
        /// validates the layout information passed in str
        static ReturnValues validate(std::string const & str);
        /// \return the conversion of \param str to the latest layout format
@@ -387,29 +389,29 @@ private:
        /// Reads the layout file without running layout2layout.
        ReturnValues readWithoutConv(support::FileName const & filename, ReadType rt);
        /// \return true for success.
-       bool readStyle(Lexer &, Layout &, ReadType) const;
+       bool readStyle(support::Lexer &, Layout &, ReadType) const;
        ///
-       void readOutputType(Lexer &);
+       void readOutputType(support::Lexer &);
        ///
-       void readTitleType(Lexer &);
+       void readTitleType(support::Lexer &);
        ///
-       void readMaxCounter(Lexer &);
+       void readMaxCounter(support::Lexer &);
        ///
-       void readClassOptions(Lexer &);
+       void readClassOptions(support::Lexer &);
        ///
-       void readCharStyle(Lexer &, std::string const &);
+       void readCharStyle(support::Lexer &, std::string const &);
        ///
-       bool readFloat(Lexer &);
+       bool readFloat(support::Lexer &);
        ///
        std::vector<CitationStyle> const & getCiteStyles(CiteEngineType const &) const;
        ///
-       bool readCiteEngine(Lexer &, ReadType, bool const add = false);
+       bool readCiteEngine(support::Lexer &, ReadType, bool const add = false);
        ///
-       int readCiteEngineType(Lexer &) const;
+       int readCiteEngineType(support::Lexer &) const;
        ///
-       bool readCiteFormat(Lexer &, ReadType);
+       bool readCiteFormat(support::Lexer &, ReadType);
        ///
-       bool readOutlinerName(Lexer &);
+       bool readOutlinerName(support::Lexer &);
 };
 
 
index 5a0366568481965f9e97ee95258f9a7363d18161..28a05f05f959ae2354870fa5835e578b054aa9b8 100644 (file)
 
 #include "Trans.h"
 
-#include "Lexer.h"
 #include "Text.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 using namespace std;
index c200bb9544b4c7714eaf7a04f3569ddbdbe75095..61a57b8e1ef32fe5669abd5c3bcba8fa95ddd493 100644 (file)
@@ -26,9 +26,10 @@ namespace lyx {
 
 class Cursor;
 class Text;
-class Lexer;
 class TransManager;
 
+namespace support { class Lexer; }
+
 ///
 enum tex_accent {
        ///
@@ -149,7 +150,7 @@ private:
        ///
        void freeKeymap();
        ///
-       int load(Lexer &);
+       int load(support::Lexer &);
        ///
        docstring const & match(char_type c);
        ///
index a465a55e86db268b622a9874f81a4bd3d011c943..0bea07b8131ef0dd974e7c99dddacb4a620890ff 100644 (file)
@@ -13,7 +13,6 @@
 #include "factory.h"
 
 #include "FuncRequest.h"
-#include "Lexer.h"
 #include "LyX.h"
 
 #include "insets/InsetBibitem.h"
@@ -65,6 +64,7 @@
 
 #include "support/debug.h"
 #include "support/ExceptionMessage.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/unique_ptr.h"
 
index ae2265e674571a04c3ff2868fde6e24f41cdce79..4ee9fb60f0576e08c70df4b5eaa0be5447fb20af 100644 (file)
@@ -17,14 +17,14 @@ namespace lyx {
 class Buffer;
 class FuncRequest;
 class Inset;
-class Lexer;
 
+namespace support { class Lexer; }
 
 /// creates inset according to 'cmd'
 Inset * createInset(Buffer * buf, FuncRequest const & cmd);
 
 /// read inset from a file
-Inset * readInset(Lexer & lex, Buffer * buf);
+Inset * readInset(support::Lexer & lex, Buffer * buf);
 
 
 } // namespace lyx
index a70ed358c5450c1fd63565eff6d346d38315e967..516c970e712c073ddaa9d8c50fd95cfa8a91d656 100644 (file)
@@ -46,7 +46,6 @@
 #include "KeyMap.h"
 #include "Language.h"
 #include "LaTeXPackages.h"
-#include "Lexer.h"
 #include "LyX.h"
 #include "LyXAction.h"
 #include "LyXRC.h"
@@ -69,6 +68,7 @@
 #include "support/ForkedCalls.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/lyxalgo.h" // sorted
 #include "support/mute_warning.h"
index 9ad1673de337159f35fef438c1498bf5c636bc4c..273dc25c9519ec4856813db53030c14cdb9ef197 100644 (file)
 
 #include "GuiApplication.h"
 #include "qt_helpers.h"
-#include "Lexer.h"
 
 #include "frontends/Clipboard.h"
 
 #include "support/docstring.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <QTextBrowser>
index b3c7349d201474dc48996dba7a4ba23d731031ac..d2fbd484f5cfcadc011b289c0dce34b0d22c2da4 100644 (file)
 #include "FuncRequest.h"
 #include "GuiView.h"
 #include "Layout.h"
-#include "Lexer.h"
 #include "Paragraph.h"
 #include "ParagraphParameters.h"
 #include "Spacing.h"
 
 #include "support/debug.h"
-#include "support/gettext.h"
+#include "support/Lexer.h"
 
 #include <QCheckBox>
 #include <QDialogButtonBox>
index c44fbb3ed14bb877cfb51c69d7d9c73100f160ac..94a0a84be2d378d0a46d5dc4a81faad4a4cc4b72 100644 (file)
@@ -34,7 +34,6 @@
 #include "TocModel.h"
 
 #include "qt_helpers.h"
-#include "support/filetools.h"
 
 #include "frontends/alert.h"
 #include "frontends/KeySymbol.h"
@@ -56,7 +55,6 @@
 #include "KeySymbol.h"
 #include "Language.h"
 #include "LayoutFile.h"
-#include "Lexer.h"
 #include "LyXAction.h"
 #include "LyX.h"
 #include "LyXRC.h"
 #include "support/debug.h"
 #include "support/ExceptionMessage.h"
 #include "support/FileName.h"
-#include "support/gettext.h"
+#include "support/filetools.h"
 #include "support/ForkedCalls.h"
+#include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Package.h"
index 193e2478fa4c66564397cc7096141707f4e81937..a191073935b60d0bd739f8d87f58433d26728d76 100644 (file)
@@ -42,7 +42,6 @@
 #include "KeyMap.h"
 #include "Language.h"
 #include "Layout.h"
-#include "Lexer.h"
 #include "LyXAction.h"
 #include "LyX.h"
 #include "LyXRC.h"
 #include "insets/InsetInfo.h"
 #include "insets/InsetQuotes.h"
 
-#include "support/lassert.h"
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/docstring_list.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <QCursor>
index 8166b4517892bde9becd5af32bf4b020d6cc318a..56875fb5cb40b7d836906b9bcc0e8e5b4133278a 100644 (file)
@@ -22,9 +22,10 @@ namespace lyx {
 
 class BufferView;
 class docstring_list;
-class Lexer;
 class FuncRequest;
 
+namespace support { class Lexer; }
+
 namespace frontend {
 
 class GuiView;
@@ -79,7 +80,7 @@ public:
        Menu * menu(QString const & name, GuiView & view, bool keyboard = false);
 
        ///
-       void read(Lexer &);
+       void read(support::Lexer &);
 
        ///
        void updateMenu(Menu * qmenu);
index cf184ae9e25273c7bb6abc0c482f9dc6dee50136..a22c5aa589c3320ee6cec250d47f1e3bdc3fcd4e 100644 (file)
 #include "Converter.h"
 #include "Format.h"
 #include "FuncRequest.h"
-#include "Lexer.h"
 #include "LyXAction.h"
 #include "qt_helpers.h"
 
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <algorithm>
index be621c9db8daa230f5c91c8959c694589459e03c..e6989b183d4398639035f8e07d28d56ff7183a9f 100644 (file)
@@ -23,7 +23,8 @@
 namespace lyx {
 
 class FuncRequest;
-class Lexer;
+
+namespace support { class Lexer; }
 
 namespace frontend {
 
@@ -92,7 +93,7 @@ public:
        Items items;
 
        /// read a toolbar from the file
-       ToolbarInfo & read(Lexer &);
+       ToolbarInfo & read(support::Lexer &);
 
 private:
        /// add toolbar item
@@ -140,10 +141,10 @@ public:
        Infos::iterator end() { return toolbar_info_.end(); }
 
        /// read toolbars from the file
-       void readToolbars(Lexer &);
+       void readToolbars(support::Lexer &);
 
        /// read ui toolbar settings
-       void readToolbarSettings(Lexer &);
+       void readToolbarSettings(support::Lexer &);
 
        ///
        ToolbarInfo const * info(std::string const & name) const;
index e7eca8b274fd303a4aef185c8e6ca75fbd95fc08..67ea027ccb098f0f77fe811fa54882bdc9f4e71c 100644 (file)
 
 #include "ExternalTemplate.h"
 
-#include "Lexer.h"
 
 #include "support/debug.h"
 #include "support/filetools.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Package.h"
 #include "support/PathChanger.h"
index e5b6755059700b009b756ea12edea6b70cc19a47..889dd563cecc6b2bbdfcbcea014deacf9ddceda0 100644 (file)
 
 namespace lyx {
 
-namespace support { class FileName; }
-
+namespace support {
+class FileName;
 class Lexer;
+}
 
 enum PreviewMode {
        PREVIEW_OFF = 0,
@@ -36,7 +37,7 @@ public:
        /// We have to have default commands for safety reasons!
        Template();
        ///
-       void readTemplate(Lexer &);
+       void readTemplate(support::Lexer &);
        ///
        void dumpFormats(std::ostream &) const;
 
@@ -72,7 +73,7 @@ public:
        public:
                Format();
                ///
-               void readFormat(Lexer &);
+               void readFormat(support::Lexer &);
 
                /// The text that should be inserted into the exported file
                std::string product;
index 2fa3e262341051e99a1a38a34c5cdfc9c3621779..04eb42ce73b4f90421bfc2912324635abbc75e27 100644 (file)
@@ -56,7 +56,6 @@ class InsetTabular;
 class InsetText;
 class Language;
 class LaTeXFeatures;
-class Lexer;
 class MathAtom;
 class MetricsInfo;
 class PainterInfo;
@@ -68,7 +67,10 @@ class otexstream;
 
 namespace graphics { class PreviewLoader; }
 
-namespace support {class FileNameList; }
+namespace support {
+class FileNameList;
+class Lexer;
+}
 
 /// returns the InsetCode corresponding to the \c name.
 /// Eg, insetCode("branch") == BRANCH_CODE
@@ -501,7 +503,7 @@ public:
        /// write inset in .lyx format
        virtual void write(std::ostream &) const {}
        /// read inset in .lyx format
-       virtual void read(Lexer &) {}
+       virtual void read(support::Lexer &) {}
        /** Export the inset to LaTeX.
         *  Don't use a temporary stringstream if the final output is
         *  supposed to go to a file.
index 89ed730b8328aacc4ce0f0afca0f9f299882298a..c4708c8d42f468be0222d07bd0249cc86942315f 100644 (file)
@@ -22,7 +22,6 @@
 #include "InsetList.h"
 #include "Language.h"
 #include "Layout.h"
-#include "Lexer.h"
 #include "ParIterator.h"
 #include "TexRow.h"
 #include "texstream.h"
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
 
 InsetArgument::InsetArgument(Buffer * buf, string const & name)
     : InsetCollapsible(buf), name_(name), labelstring_(docstring()),
index 34f4309cb0c5fefa842fe4033442a25d4a7817f1..a3dd7d05bf77a82245a09978b063cd1a1737f631 100644 (file)
@@ -68,7 +68,7 @@ public:
        ///
        void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        bool neverIndent() const override { return true; }
        ///
index 6336da32d40b620acc029bb1d822dc90ae07df48..343770e14d4b0f1ddb2edcc9ee11366a3e412b69 100644 (file)
@@ -26,7 +26,6 @@
 #include "InsetIterator.h"
 #include "InsetList.h"
 #include "Language.h"
-#include "Lexer.h"
 #include "output_xhtml.h"
 #include "Paragraph.h"
 #include "ParagraphList.h"
@@ -40,6 +39,7 @@
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/mutex.h"
 
index 2a210e8c907085a711a654c500af9803afc1df59..b9ce1aef817b6598e4972a8306985a6267502842 100644 (file)
@@ -51,7 +51,7 @@ public:
        ///
        bool isLabeled() const override { return true; }
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        int plaintext(odocstringstream &, OutputParams const &,
                      size_t max_length = INT_MAX) const override;
index edfa6a569c0cd06c7d75fb5dac518bcd28e8fe43..972ca20572b7cbb1120181d9b837b883709fc104 100644 (file)
@@ -24,7 +24,6 @@
 #include "FuncStatus.h"
 #include "FuncRequest.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "output_docbook.h"
 #include "output_xhtml.h"
@@ -36,6 +35,7 @@
 #include "support/docstream.h"
 #include "support/FileName.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
 
index f4a743667bbf9826c822df9443fb96efd41b637e..a5b71e5cda8024f870b1fd2dfb030d4c4e50cae4 100644 (file)
@@ -29,7 +29,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
 
        ///
        std::string type;
@@ -108,7 +108,7 @@ public:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void metrics(MetricsInfo &, Dimension &) const override;
        ///
index 229e1bc37e3a051769cc133fa36486155f70eecd..a86b9348267999b8b4c4846808ef352366ab1b38 100644 (file)
@@ -23,7 +23,6 @@
 #include "FuncStatus.h"
 #include "Inset.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "LyX.h"
 #include "output_docbook.h"
 #include "output_xhtml.h"
@@ -33,6 +32,7 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include "frontends/alert.h"
@@ -45,6 +45,8 @@ using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 InsetBranch::InsetBranch(Buffer * buf, InsetBranchParams const & params)
        : InsetCollapsible(buf, InsetText::DefaultLayout), params_(params)
 {}
index 5098e70afb795fe8441fb8d3134a3058f12f95b7..58154701e3bca26d4bacb146bc9df7ae3460579f 100644 (file)
@@ -26,7 +26,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        docstring branch;
        ///
@@ -65,7 +65,7 @@ private:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        docstring const buttonLabel(BufferView const &) const override;
        ///
index 519033e24a3fe0834a5b6f1e16e84dcb8fc9f74f..d6c04615437e0c5f6ca75f91a2ad8b31e6eb1dcd 100644 (file)
@@ -24,7 +24,6 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "InsetLayout.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "TextClass.h"
 #include "TocBackend.h"
@@ -37,6 +36,7 @@
 #include "support/FileName.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Changer.h"
 #include "support/TempFile.h"
@@ -46,6 +46,8 @@ using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 InsetCollapsible::InsetCollapsible(Buffer * buf, InsetText::UsePlain ltype)
        : InsetText(buf, ltype), status_(Open)
 {
index 0f2711afbae8dfe035a358652566aad512acb717..22f846b89a9fb61d13da9c9f3ce16f2e672e551b 100644 (file)
@@ -53,7 +53,7 @@ public:
        ///
        docstring layoutName() const override { return from_ascii("Collapsible"); }
        ///
-       void read(Lexer &) override;
+       void read(support::Lexer &) override;
        ///
        void write(std::ostream &) const override;
 
index 50db6ddcdba62ffa2a770155d9f6725ddbcb41ca..226d6193c954b06d0eefa624c39afd9b5615dcf2 100644 (file)
@@ -21,7 +21,6 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "InsetIterator.h"
-#include "Lexer.h"
 #include "LyX.h"
 #include "MetricsInfo.h"
 #include "texstream.h"
@@ -41,6 +40,7 @@
 #include "insets/InsetWrap.h"
 
 #include "support/debug.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include "frontends/Application.h"
index 16057644500678cdff9acbdb712022a4157c3458..d9ff9f8322dce29e728e2ec522321b4e68c9e2eb 100644 (file)
@@ -72,7 +72,7 @@ public:
        ///
        void write(std::ostream & os) const override { p_.write(os); }
        ///
-       void read(Lexer & lex) override { p_.Read(lex, &buffer()); }
+       void read(support::Lexer & lex) override { p_.Read(lex, &buffer()); }
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd) override;
        ///
index 9c3552a4b7262f4661003384e44ee7e7654aed80..523a4c81dc2d8b9417485072ad5fb1ba720b8f08 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "Buffer.h"
 #include "Encoding.h"
-#include "Lexer.h"
 
 #include "frontends/alert.h"
 
@@ -38,9 +37,9 @@
 #include "support/docstream.h"
 #include "support/ExceptionMessage.h"
 #include "support/gettext.h"
-#include "support/lstrings.h"
-
 #include "support/lassert.h"
+#include "support/Lexer.h"
+#include "support/lstrings.h"
 
 #include <algorithm>
 #include <functional>
index f05fb61ddc7233d53ee0436e5605bb509599650f..a7cdd841b6b3f3e18875ea6be56d617acaf9b94f 100644 (file)
 namespace lyx {
 
 class Buffer;
-class Lexer;
 class OutputParams;
 
+namespace support { class Lexer; }
+
 class ParamInfo {
 public:
        ///
@@ -128,9 +129,9 @@ public:
        ///
        InsetCode code() const { return insetCode_; }
        /// Parse the command
-       void read(Lexer &);
+       void read(support::Lexer &);
        ///
-       void Read(Lexer &, Buffer const *);
+       void Read(support::Lexer &, Buffer const *);
        ///
        void write(std::ostream &) const;
        ///
index 00f497f0319f258556ea3b6b77a2aabf2bcb958b..e4b0e88022a7eb7cc50471fcc9bfa9e7811166f7 100644 (file)
@@ -18,7 +18,6 @@
 #include "FuncStatus.h"
 #include "InsetLayout.h"
 #include "Language.h"
-#include "Lexer.h"
 #include "xml.h"
 #include "ParagraphParameters.h"
 #include "Paragraph.h"
@@ -26,6 +25,7 @@
 
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/TempFile.h"
 #include "Encoding.h"
index 0581d2e6fcc55f799f916d11037bbc0858ba37ab..04c4c0de94b867ea94f7471f352b6a200ae1e645 100644 (file)
@@ -25,8 +25,6 @@
 #include "FuncStatus.h"
 #include "FuncRequest.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
-#include "LyX.h" // use_gui
 #include "LyXRC.h"
 #include "MetricsInfo.h"
 #include "output_latex.h"
@@ -46,6 +44,7 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 #include "support/TempFile.h"
index ce71c94df344edf2f19681f139788dab892eff85..28316d3be1183520072dc17c933aa58d06126ec0 100644 (file)
@@ -51,7 +51,7 @@ public:
        InsetExternalParams();
 
        void write(Buffer const &, std::ostream &) const;
-       bool read(Buffer const &, Lexer &);
+       bool read(Buffer const &, support::Lexer &);
 
        /// The name of the tempfile used for manipulations.
        support::FileName tempname() const { return tempname_(); }
@@ -141,7 +141,7 @@ public:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        int plaintext(odocstringstream & ods, OutputParams const & op,
                      size_t max_length = INT_MAX) const override;
index 91c0b8cea1fd872eb4bf8cfe09811f5aed3744db..2a8af67faec9021422d2e0bb8cdd7f8c8fa01523 100644 (file)
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "Language.h"
-#include "Lexer.h"
 #include "ParIterator.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <ostream>
index 9bef3ab2589897291b5201578bbef30811580df9..8e024205e7a9aedaf8374b57c79eec47c443a919 100644 (file)
@@ -30,7 +30,6 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "xml.h"
 #include "output_docbook.h"
 #include "output_xhtml.h"
@@ -43,6 +42,7 @@
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include "frontends/Application.h"
index 50c698a43e1410b5b6ee8065ee5c69d84afaa6d8..ada6add04a0894d5e65e1dcb73adaa863cbc4e46 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        std::string type;
        ///
@@ -88,7 +88,7 @@ private:
        ///
        void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void validate(LaTeXFeatures & features) const override;
        ///
index 3315d3b8968a1748c88a3df2760b914b56a4dd6b..7075538f82ccb848df69579965b0a17d0e8bd6f2 100644 (file)
@@ -23,7 +23,6 @@
 #include "FuncRequest.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "Paragraph.h"
 #include "output_xhtml.h"
 #include "texstream.h"
@@ -32,6 +31,7 @@
 
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <ostream>
index ce6caa577097bd67c563e8eeb8975ab6a352704c..21477f520dc0b4ea6e02a0eb89198297b4cad293 100644 (file)
@@ -36,7 +36,7 @@ public:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer &) override;
+       void read(support::Lexer &) override;
        ///
        void latex(otexstream &, OutputParams const &) const override;
        ///
index 62577f07db9812441713007cfcce3fff1ecde303..b092ff44fff35fe9f47f3fe9476415a10f2b6d14 100644 (file)
@@ -63,7 +63,6 @@ TODO
 #include "InsetIterator.h"
 #include "LaTeX.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "Mover.h"
 #include "output_docbook.h"
@@ -86,6 +85,7 @@ TODO
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/Length.h"
+#include "support/Lexer.h"
 #include "support/lyxlib.h"
 #include "support/lstrings.h"
 #include "support/os.h"
index df2abc4b01cd17b959cec64a419a02e36b484639..73b5625b11f647e7bc375baeda86e0f82a785219 100644 (file)
@@ -68,7 +68,7 @@ public:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        /** returns the number of rows (\n's) of generated tex code.
         #fragile == true# means, that the inset should take care about
         fragile commands by adding a #\protect# before.
index 9f6ffbb901ecbca5e387869c83d887a247582622..ab2c9ff29c02a95e613ff5e510144420b10b9d31 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "Buffer.h"
 #include "LyX.h" // for use_gui
-#include "Lexer.h"
 #include "LyXRC.h"
 
 #include "graphics/epstools.h"
@@ -24,6 +23,7 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/lyxlib.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
 
index 1aa0b23d5b68cd8f742ca3aa9c6f0e443375558a..dc6fde7a66d3d3abc93309a2e471775ebe1725c0 100644 (file)
@@ -23,8 +23,8 @@
 namespace lyx {
 
 namespace graphics { class Params; }
+namespace support { class Lexer; }
 
-class Lexer;
 class Buffer;
 
 
@@ -77,7 +77,7 @@ public:
        /// Buffer is needed to figure out if a figure is embedded.
        void Write(std::ostream & os, Buffer const & buf) const;
        /// If the token belongs to our parameters, read it.
-       bool Read(Lexer & lex, std::string const & token, Buffer const & buf,
+       bool Read(support::Lexer & lex, std::string const & token, Buffer const & buf,
                  bool allowOrigin);
        /// convert
        // Only a subset of InsetGraphicsParams is needed for display purposes.
index 7745b8d946793362398726d128e13c0bb3bb61d1..a6ee44032cffe6cc0c80396547de4edc8dcbd8e6 100644 (file)
@@ -19,7 +19,6 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "RenderPreview.h"
 #include "texstream.h"
@@ -28,6 +27,8 @@
 
 #include "graphics/PreviewImage.h"
 
+#include "support/Lexer.h"
+
 #include <sstream>
 
 using namespace std;
index 2d4b1fb13c2d25e516f66fb462f5862c2dde3bd1..4c72e9b702ae34b22a52d034129de6b217ff8f00 100644 (file)
@@ -21,7 +21,6 @@
 #include "FuncStatus.h"
 #include "InsetLayout.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "xml.h"
 #include "texstream.h"
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/Translator.h"
 
 using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 namespace {
 
 typedef Translator<string, InsetIPADecoParams::Type> IPADecoTranslator;
index dc1977f977675ad39bc2eba7bae3b6c2ae4035b0..f871729c948c8942af97be47b894f19b54d31dbe 100644 (file)
@@ -33,7 +33,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        Type type;
 };
@@ -70,7 +70,7 @@ private:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        bool neverIndent() const override { return true; }
        ///
@@ -143,7 +143,7 @@ public:
        ///
        void write(std::ostream &) const override;
        /// Will not be used when lyxf3
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void latex(otexstream &, OutputParams const &) const override;
        ///
index 64bb398099113cc3f8532b9ca00b0c00267f74ed..eb16a543ceff45ef4984135661657387bd44a7ff 100644 (file)
@@ -30,7 +30,6 @@
 #include "Paragraph.h"
 #include "LaTeX.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "LyX.h"
 #include "output_latex.h"
 #include "output_xhtml.h"
@@ -43,6 +42,7 @@
 #include "support/docstream.h"
 #include "support/FileName.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
 
index 860281b97085e95bc8759dbfeb016ac911b87e17..a1b7507a2735e2cf97d5d54460274bb06f30e789 100644 (file)
@@ -34,7 +34,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        docstring index;
        ///
@@ -72,7 +72,7 @@ private:
        ///
        void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void docbook(XMLStream &, OutputParams const &) const override;
        ///
index 80ba766b538afdb6438b69521a7b03ffe6973aa4..cbd17a17e126d40dad14642c28bced4e865089c6 100644 (file)
@@ -25,7 +25,6 @@
 #include "InsetList.h"
 #include "LaTeX.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "xml.h"
 #include "texstream.h"
@@ -35,6 +34,7 @@
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
 
index 07109f8fafc66610fb97daadbc56bf397e0e82f6..b7ceed3fbac9f98920d0da210826d7cdcb1a0ab4 100644 (file)
@@ -35,7 +35,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        Type type;
 };
@@ -76,7 +76,7 @@ private:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        bool neverIndent() const override { return true; }
        /// We do not output anything directly to the stream
index df83f96b9830984a00dab86203f9620a0a18e7b5..cfb5b7eafc6869a2af6cad6eeb752b4ba6bf8fc9 100644 (file)
@@ -30,7 +30,6 @@
 #include "LyXAction.h"
 #include "LyXRC.h"
 #include "LyXVC.h"
-#include "Lexer.h"
 #include "output_docbook.h"
 #include "Paragraph.h"
 #include "ParIterator.h"
@@ -49,6 +48,7 @@
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/Length.h"
+#include "support/Lexer.h"
 #include "support/Messages.h"
 #include "support/lstrings.h"
 #include "support/qstring_helpers.h"
index 9af4d2fe4dc34f4f84ce8f03032c164915281cd1..e0cf7585b37246d12400f08be1cfed9cde78f81c 100644 (file)
@@ -178,7 +178,7 @@ public:
        ///
        bool hasSettings() const override { return true; }
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void write(std::ostream & os) const override;
        ///
index 8e5ed651cf4329dd90f1bb69a2536c7b2fde5f10..7a0c61211e8b7564fd30af5735e44c1e7e5fb274 100644 (file)
 #include "InsetLayout.h"
 
 #include "ColorSet.h"
-#include "Lexer.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
index 6700100252a24b3996938b5d5359c1ad4f407b18..1d25dea0462acc623f778e277ffc7212f1936a94 100644 (file)
@@ -24,9 +24,9 @@
 
 namespace lyx {
 
-class Lexer;
 class TextClass;
 
+namespace support { class Lexer; }
 
 enum class InsetDecoration : int {
        CLASSIC,
@@ -57,7 +57,7 @@ public:
        ///
        InsetLayout() { labelfont_.setColor(Color_insetlabel); }
        ///
-       bool read(Lexer & lexrc, TextClass const & tclass,
+       bool read(support::Lexer & lexrc, TextClass const & tclass,
                        bool validating = false);
        ///
        docstring name() const { return name_; }
@@ -266,7 +266,7 @@ private:
        ///
        std::string defaultCSSClass() const;
        ///
-       void readArgument(Lexer &);
+       void readArgument(support::Lexer &);
        ///
        docstring name_ = from_ascii("undefined");
        /**
index 8268cebd68c0d0d52748ada0c08aad4908ac1e69..24c8a21a633cbe724a0e5875381680e09e04f592 100644 (file)
@@ -25,7 +25,6 @@
 #include "InsetLayout.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "output_latex.h"
 #include "output_docbook.h"
 #include "output_xhtml.h"
@@ -35,6 +34,7 @@
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/lassert.h"
 
index c72865cd9038ef761a411ff23cce42c8d892e7a9..df4d1e422e6613d96b845bdc276cd481d253ae08 100644 (file)
@@ -52,7 +52,7 @@ private:
        ///
        void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void latex(otexstream &, OutputParams const &) const override;
        ///
index e017d523527f7a9b2b4d17a275e946c327a164f1..2ce8f2719a1ddc3d302e2dbfc2043231aba08954 100644 (file)
 
 #include "InsetListingsParams.h"
 
-#include "support/Length.h"
-#include "Lexer.h"
-
 #include "support/convert.h"
 #include "support/gettext.h"
+#include "support/Length.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
index 90c5adb763fa13d1c9ab8e96cefacc863abaedef..29240e8194b2ce35e43bdd76ffed3c878236610e 100644 (file)
@@ -31,7 +31,7 @@ public:
        void write(std::ostream &) const;
 
        /// read parameters from an ostream
-       void read(Lexer &);
+       void read(support::Lexer &);
 
        /// valid parameter string
        std::string params(std::string const & sep=",") const;
index ecfacf47cef19f8e8546454980fea97055021f85..38898c8ecde9d381db60d4cd375206f9078de2a7 100644 (file)
@@ -17,7 +17,6 @@
 #include "Dimension.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "output_docbook.h"
 #include "output_xhtml.h"
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/docstring.h"
+#include "support/Lexer.h"
 
 using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 InsetNewline::InsetNewline() : Inset(nullptr)
 {}
 
index c85a97df66ef6aea50add00f377a843f6ff32634..36cfe7390a32922c5bba7538960e44474fd0263c 100644 (file)
@@ -32,7 +32,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        Kind kind;
 };
@@ -69,7 +69,7 @@ private:
        ///
        docstring xhtml(XMLStream &, OutputParams const &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void write(std::ostream & os) const override;
        /// is this equivalent to a space (which is BTW different from
index da944526321eb299cca73cc096ca368541d13749..caac17e27c70774ccd5ac70dd28bea5ce7499ba6 100644 (file)
@@ -16,7 +16,6 @@
 #include "Cursor.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "xml.h"
 #include "texstream.h"
 #include "support/docstring.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 
 using namespace std;
 
-
 namespace lyx {
 
-       InsetNewpage::InsetNewpage() : Inset(nullptr)
+using support::Lexer;
+
+InsetNewpage::InsetNewpage() : Inset(nullptr)
 {}
 
 
index d086276df2d674e933b5f50752fb4848b0cccf8e..80fee2ffc92ae74715f359f5baf6772c19408be7 100644 (file)
@@ -38,7 +38,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        Kind kind;
 };
@@ -72,7 +72,7 @@ private:
        ///
        docstring xhtml(XMLStream &, OutputParams const &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void write(std::ostream & os) const override;
        ///
index b12b755fba9ed16e2a135c28a0286afb13720b81..7eed0ed9ccb521db0b80749475e39f5be3f2972b 100644 (file)
@@ -25,7 +25,6 @@
 #include "FuncStatus.h"
 #include "InsetLayout.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "LyXRC.h"
 #include "output_docbook.h"
 #include "output_latex.h"
@@ -33,6 +32,7 @@
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
 
@@ -45,6 +45,8 @@ using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 namespace {
 
 typedef Translator<string, InsetNoteParams::Type> NoteTranslator;
index 94a07906e5258e2631c85667ad937a126ca4597a..25e91f88eb929cbf76ead024fd60da67c44d05b0 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        Type type;
 };
@@ -71,7 +71,7 @@ private:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        /// show the note dialog
        bool showInsetDialog(BufferView * bv) const override;
        ///
index d1a25f6a70bc32cfcce4f32712c6112e7e37ca97..968d8f03373de4e893d1137e830c91d08e7f8788 100644 (file)
@@ -22,7 +22,6 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "texstream.h"
 #include "TextClass.h"
@@ -34,6 +33,7 @@
 
 #include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
+#include "support/Lexer.h"
 #include "frontends/Painter.h"
 
 #include <algorithm>
@@ -43,6 +43,8 @@ using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 namespace {
 
 typedef Translator<string, InsetPhantomParams::Type> PhantomTranslator;
index 72281df2ae26e7181c54927187275063ad9945d4..57f08102baea095f02d895b50a85fdfbc1506a5b 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        Type type;
 };
@@ -66,7 +66,7 @@ private:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void setButtonLabel() override;
        /// show the phantom dialog
index 46b8ef11ae6c87c261e36529c769d96c4447020d..8d6caf1e5ef958c5df2501082e040a2e75515592 100644 (file)
@@ -24,7 +24,6 @@
 #include "FuncRequest.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "LyXRC.h"
 #include "MetricsInfo.h"
 #include "Paragraph.h"
@@ -39,6 +38,7 @@
 #include "support/docstring.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
index 2eeb5fa866f157d8721ca7ccf639c40e45bff5ae..13bd8ea1249cbd9878c653b1c2b36bceea77ea3b 100644 (file)
@@ -143,7 +143,7 @@ public:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
        ///
index c1f8da1e828406a3966ed922a1a3c25a8a452059..b588f4283ef022f4c34445d279037b64134e3af0 100644 (file)
@@ -22,7 +22,6 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "LyXAction.h"
 #include "MetricsInfo.h"
 #include "output_docbook.h"
@@ -32,6 +31,7 @@
 
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
 
@@ -45,6 +45,8 @@ using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 namespace {
 
 typedef Translator<string, InsetScriptParams::Type> ScriptTranslator;
index 1a008a98882548fa1c36334dbcfd9010ef5cd942..eab074b1e2f41beb5095ac7fd058fd94de36ad51 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        int shift(FontInfo const & font) const;
        ///
@@ -87,7 +87,7 @@ public:
        ///
        void write(std::ostream &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        bool forcePlainLayout(idx_type = 0) const override { return true; }
        ///
index 218172c87af761e1ade1423b71720dc69e3f4ec9..765fa93933feff12fa2b440870cb30686b1e3caa 100644 (file)
@@ -16,7 +16,6 @@
 #include "Dimension.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "output_docbook.h"
 #include "output_xhtml.h"
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/docstring.h"
+#include "support/Lexer.h"
 
 using namespace std;
 using namespace lyx::frontend;
 
 namespace lyx {
 
+using support::Lexer;
+
 InsetSeparator::InsetSeparator() : Inset(nullptr)
 {}
 
index b824214ae7914e3e2e1b8fcfbab91d90cee39139..dba716c6aa55456f09785bcd6551c7bdfd326d21 100644 (file)
@@ -31,7 +31,7 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        Kind kind;
 };
@@ -85,7 +85,7 @@ private:
        ///
        docstring xhtml(XMLStream &, OutputParams const &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void write(std::ostream & os) const override;
        /// is this equivalent to a space (which is BTW different from
index 8ad6f7f5e081063ac5de707847c8a75f7af2cb15..8991c1166f44b32854d69dd13fe1863da74df84b 100644 (file)
@@ -22,7 +22,6 @@
 #include "FuncStatus.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "texstream.h"
 #include "xml.h"
 
 #include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
+#include "support/Lexer.h"
 #include "frontends/Painter.h"
 
 using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
 
 InsetSpace::InsetSpace(InsetSpaceParams const & params)
        : Inset(nullptr), params_(params)
index ceca1cfa06339c2836e05566f4392c14ec4ef308..719e09483dd21e77326f26461281ac5b9e9623bc 100644 (file)
@@ -79,7 +79,7 @@ struct InsetSpaceParams {
        ///
        void write(std::ostream & os) const;
        ///
-       void read(Lexer & lex);
+       void read(support::Lexer & lex);
        ///
        Kind kind;
        ///
@@ -123,7 +123,7 @@ public:
        ///
        void write(std::ostream &) const override;
        /// Will not be used when lyxf3
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void latex(otexstream &, OutputParams const &) const override;
        ///
index a1f7fec332837ad177fc99448c7d0fd0354c1f9d..0e5337f51dd86b6c0c6fd664857133fc061e2baa 100644 (file)
@@ -19,7 +19,6 @@
 #include "Font.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "output_xhtml.h"
 #include "xml.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
+#include "support/Lexer.h"
 
 using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 
 InsetSpecialChar::InsetSpecialChar(Kind k)
        : Inset(nullptr), kind_(k)
index 5f7338b8ddfd97a860fb16fe85367a62b44a3f72..dab1bc3da190eff55c65ae2103c2ff0e6eee4618 100644 (file)
@@ -71,7 +71,7 @@ public:
        ///
        void write(std::ostream &) const override;
        /// Will not be used when lyxf3
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void latex(otexstream &, OutputParams const &) const override;
        ///
index 5242775e7fe7dd9f7339228985a982bb3bfe9880..46b54486dea5cd64276e9ea16a42394b9a26408e 100644 (file)
@@ -38,7 +38,6 @@
 #include "InsetList.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "LyX.h"
 #include "LyXRC.h"
 #include "MetricsInfo.h"
@@ -64,6 +63,7 @@
 #include "support/FileName.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 #include "support/unique_ptr.h"
 
index c38fab03850b03360d6636c543343a6f63583f46..f6939c6effff643f4c22b3b48a2eb9840e5ac535 100644 (file)
@@ -45,10 +45,10 @@ class CompletionList;
 class Cursor;
 class CursorSlice;
 class FuncStatus;
-class Lexer;
 class OutputParams;
 class XMLStream;
 
+namespace support { class Lexer; }
 
 ///
 class InsetTableCell : public InsetText
@@ -603,7 +603,7 @@ public:
        ///
        void write(std::ostream &) const;
        ///
-       void read(Lexer &);
+       void read(support::Lexer &);
        ///
        void latex(otexstream &, OutputParams const &) const;
        /// serialise the table in DocBook, according to buffer parameters
@@ -1021,7 +1021,7 @@ public:
        ///
        static std::string params2string(InsetTabular const &);
        ///
-       void read(Lexer &) override;
+       void read(support::Lexer &) override;
        ///
        void write(std::ostream &) const override;
        ///
index b8e65709a12325dcf256efee445a5a518172a08c..084e41802707ce2e779ed9272235c435eb8d6948 100644 (file)
@@ -39,7 +39,7 @@
 #include "Language.h"
 #include "Layout.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
+#include "support/Lexer.h"
 #include "lyxfind.h"
 #include "LyXRC.h"
 #include "MetricsInfo.h"
index bce125bccaba6496aa176f5d228682f79257fc44..423735a032f3910de38a7da327640f56d4b4ea6e 100644 (file)
@@ -51,7 +51,7 @@ public:
        /// empty inset to empty par
        void clear();
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void write(std::ostream & os) const override;
        /// Let the inset compute and store its reference font from \c outer.
index 80fba4dd1d861270e25f1d730625aa5bfef0c8ab..d3c6012b3f4a04924161339764a6ffc0a5c932bf 100644 (file)
@@ -20,7 +20,6 @@
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "xml.h"
 #include "texstream.h"
@@ -29,6 +28,7 @@
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lassert.h"
 
 #include "frontends/Application.h"
@@ -41,6 +41,8 @@ using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 namespace {
 
 int const ADD_TO_VSPACE_WIDTH = 5;
index 51c2b5b8857bbf12fcf39abfea19da38ba3680d8..e43dc306aa19b460029ad5995b9e9fdaad48d7f5 100644 (file)
@@ -58,7 +58,7 @@ private:
        /// in fact, appear at all.
        docstring xhtml(XMLStream &, OutputParams const &) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void write(std::ostream & os) const override;
        ///
index 69e5b259e50a0f80269f4d1d0bc32b1501795efe..85d7ea229a434333d0859b69726137b2cd25d464 100644 (file)
@@ -25,7 +25,6 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "xml.h"
 #include "texstream.h"
 #include "TextClass.h"
@@ -33,6 +32,7 @@
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 
 #include "frontends/Application.h"
 
@@ -43,6 +43,8 @@ using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 InsetWrap::InsetWrap(Buffer * buf, string const & type)
        : InsetCaptionable(buf)
 {
index a44821e4281d3228fdbb75ac38b96bf8d3e72a1f..01541fdabfef14f63aa86105751f910666580d9b 100644 (file)
@@ -25,7 +25,7 @@ public:
        ///
        void write(std::ostream &) const;
        ///
-       void read(Lexer &);
+       void read(support::Lexer &);
 
        ///
        std::string type;
@@ -60,7 +60,7 @@ private:
        ///
        void write(std::ostream & os) const override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void validate(LaTeXFeatures & features) const override;
        ///
index 8e527c4d52340a5d30311595c460af923e90bc83..1875417d5d8c70811d341044fa24dd6dfb2a7356 100644 (file)
@@ -137,9 +137,9 @@ public:
        ///
        void footer_write(TeXMathStream &) const;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
-       bool readQuiet(Lexer & lex);
+       bool readQuiet(support::Lexer & lex);
        ///
        int plaintext(odocstringstream &, OutputParams const &,
                      size_t max_length = INT_MAX) const override;
index 2a2a87eb57e73cea1e59444f0c82e6d5ad8ddecc..9b2fd19dab0ecb24f53ac353679dcb970d09de69 100644 (file)
@@ -32,7 +32,6 @@
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "MetricsInfo.h"
 #include "TocBackend.h"
 
@@ -45,6 +44,7 @@
 #include "support/debug.h"
 #include "support/gettext.h"
 #include "support/docstream.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <set>
@@ -55,6 +55,7 @@ using namespace std;
 namespace lyx {
 
 using support::bformat;
+using support::Lexer;
 
 //////////////////////////////////////////////////////////////////////
 
index 1fa6d009894b4681f1b013220f85c811a2093dc5..785385a7db858adbdde7725e6a58dc0db6492a0e 100644 (file)
@@ -45,7 +45,7 @@ public:
        ///
        bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
        ///
-       void read(Lexer & lex) override;
+       void read(support::Lexer & lex) override;
        ///
        void write(std::ostream & os) const override;
        ///
index 79e0ec003d42a35e0ec47cab234ef207e79253e3..eb4339c8ea7552b8ba48e0f41e1fc889e0df86fd 100644 (file)
@@ -72,11 +72,11 @@ following hack as starting point to write some macros:
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "Encoding.h"
-#include "Lexer.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/docstream.h"
+#include "support/Lexer.h"
 
 #include <sstream>
 
@@ -86,6 +86,8 @@ using namespace std;
 
 namespace lyx {
 
+using support::Lexer;
+
 namespace {
 
 InsetMath::mode_type asMode(InsetMath::mode_type oldmode, docstring const & str)
index d69c78a11a5a2ba3370fd41e14ab855f15993de2..734a92f2f94ddc325eef64c0c5e6b5e44ae792ec 100644 (file)
@@ -24,8 +24,8 @@ class Buffer;
 class MathAtom;
 class MathData;
 class InsetMathGrid;
-class Lexer;
 
+namespace support { class Lexer; }
 
 ///
 class latexkeys {
@@ -75,7 +75,7 @@ bool mathed_parse_normal(Buffer * buf, MathAtom &, docstring const &,
                Parse::flags f = Parse::NORMAL);
 
 /// parse formula from the LyX lexxer
-bool mathed_parse_normal(Buffer * buf, MathAtom &, Lexer &,
+bool mathed_parse_normal(Buffer * buf, MathAtom &, support::Lexer &,
                Parse::flags f = Parse::NORMAL);
 
 /// parse formula from a string into a grid
diff --git a/src/support/Lexer.cpp b/src/support/Lexer.cpp
new file mode 100644 (file)
index 0000000..fd8840d
--- /dev/null
@@ -0,0 +1,929 @@
+/**
+ * \file Lexer.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "support/Lexer.h"
+
+#include "support/convert.h"
+#include "support/debug.h"
+#include "support/FileName.h"
+#include "support/filetools.h"
+#include "support/gzstream.h"
+#include "support/lassert.h"
+#include "support/lstrings.h"
+#include "support/lyxalgo.h"
+
+#include <algorithm> // sort, lower_bound
+#include <functional>
+#include <fstream>
+#include <istream>
+#include <stack>
+#include <vector>
+
+using namespace std;
+
+namespace lyx {
+
+namespace support {
+
+//////////////////////////////////////////////////////////////////////
+//
+// Lexer::Pimpl
+//
+//////////////////////////////////////////////////////////////////////
+
+
+///
+class Lexer::Pimpl {
+public:
+       ///
+       Pimpl(LexerKeyword * tab, int num);
+       ///
+       string const getString() const;
+       ///
+       docstring const getDocString() const;
+       ///
+       void printError(string const & message) const;
+       ///
+       void printTable(ostream & os);
+       ///
+       void pushTable(LexerKeyword * tab, int num);
+       ///
+       void popTable();
+       ///
+       bool setFile(FileName const & filename);
+       ///
+       void setStream(istream & i);
+       ///
+       void setCommentChar(char c);
+       ///
+       bool next(bool esc = false);
+       ///
+       int searchKeyword(char const * const tag) const;
+       ///
+       int lex();
+       ///
+       bool eatLine();
+       ///
+       bool nextToken();
+       /// test if there is a pushed token or the stream is ok
+       bool inputAvailable();
+       ///
+       void pushToken(string const &);
+       /// gz_ is only used to open files, the stream is accessed through is.
+       gz::gzstreambuf gz_;
+
+       /// the stream that we use.
+       istream is;
+       ///
+       string name;
+       ///
+       LexerKeyword * table;
+       ///
+       int no_items;
+       ///
+       string buff;
+       ///
+       int status;
+       ///
+       int lineno;
+       ///
+       string pushTok;
+       /// used for error messages
+       string context;
+       ///
+       char commentChar;
+private:
+       /// non-copyable
+       Pimpl(Pimpl const &);
+       void operator=(Pimpl const &);
+
+       ///
+       void verifyTable();
+       ///
+       class PushedTable {
+       public:
+               ///
+               PushedTable()
+                       : table_elem(nullptr), table_siz(0) {}
+               ///
+               PushedTable(LexerKeyword * ki, int siz)
+                       : table_elem(ki), table_siz(siz) {}
+               ///
+               LexerKeyword * table_elem;
+               ///
+               int table_siz;
+       };
+       ///
+       stack<PushedTable> pushed;
+};
+
+
+namespace {
+
+// used by lower_bound, sort and sorted
+bool compareTags(LexerKeyword const & a, LexerKeyword const & b)
+{
+       // we use the ascii version, because in turkish, 'i'
+       // is not the lowercase version of 'I', and thus
+       // turkish locale breaks parsing of tags.
+       return compare_ascii_no_case(a.tag, b.tag) < 0;
+}
+
+} // namespace
+
+
+
+Lexer::Pimpl::Pimpl(LexerKeyword * tab, int num)
+       : is(&gz_), table(tab), no_items(num),
+         status(0), lineno(0), commentChar('#')
+{
+       verifyTable();
+}
+
+
+string const Lexer::Pimpl::getString() const
+{
+       return buff;
+}
+
+
+docstring const Lexer::Pimpl::getDocString() const
+{
+       return from_utf8(buff);
+}
+
+
+void Lexer::Pimpl::printError(string const & message) const
+{
+       string const tmpmsg = subst(message, "$$Token", getString());
+       lyxerr << "LyX: " << tmpmsg << " [around line " << lineno
+               << " of file " << to_utf8(makeDisplayPath(name))
+               << " current token: '" << getString() << "'"
+               << " context: '" << context << "']" << endl;
+}
+
+
+void Lexer::Pimpl::printTable(ostream & os)
+{
+       os << "\nNumber of tags: " << no_items << endl;
+       for (int i= 0; i < no_items; ++i)
+               os << "table[" << i
+                  << "]:  tag: `" << table[i].tag
+                  << "'  code:" << table[i].code << '\n';
+       os.flush();
+}
+
+
+void Lexer::Pimpl::verifyTable()
+{
+       // Check if the table is sorted and if not, sort it.
+       if (table
+           && !lyx::sorted(table, table + no_items, &compareTags)) {
+               lyxerr << "The table passed to Lexer is not sorted!\n"
+                      << "Tell the developers to fix it!" << endl;
+               // We sort it anyway to avoid problems.
+               lyxerr << "\nUnsorted:" << endl;
+               printTable(lyxerr);
+
+               sort(table, table + no_items, &compareTags);
+               lyxerr << "\nSorted:" << endl;
+               printTable(lyxerr);
+       }
+}
+
+
+void Lexer::Pimpl::pushTable(LexerKeyword * tab, int num)
+{
+       PushedTable tmppu(table, no_items);
+       pushed.push(tmppu);
+
+       table = tab;
+       no_items = num;
+
+       verifyTable();
+}
+
+
+void Lexer::Pimpl::popTable()
+{
+       if (pushed.empty()) {
+               lyxerr << "Lexer error: nothing to pop!" << endl;
+               return;
+       }
+
+       PushedTable tmp = pushed.top();
+       pushed.pop();
+       table = tmp.table_elem;
+       no_items = tmp.table_siz;
+}
+
+
+bool Lexer::Pimpl::setFile(FileName const & filename)
+{
+               if (gz_.is_open() || istream::off_type(is.tellg()) > -1)
+                       LYXERR0("Error in LyXLex::setFile: file or stream already set.");
+               gz_.open(filename.toSafeFilesystemEncoding().c_str(), ios::in);
+               is.rdbuf(&gz_);
+               name = filename.absFileName();
+               lineno = 0;
+               if (!gz_.is_open() || !is.good())
+                       return false;
+
+       // Skip byte order mark.
+       if (is.peek() == 0xef) {
+               is.get();
+               if (is.peek() == 0xbb) {
+                       is.get();
+                       LASSERT(is.get() == 0xbf, /**/);
+               } else
+                       is.unget();
+       }
+
+       return true;
+}
+
+
+void Lexer::Pimpl::setStream(istream & i)
+{
+       if (gz_.is_open() || istream::off_type(is.tellg()) > 0)
+               LYXERR0("Error in Lexer::setStream: file or stream already set.");
+       is.rdbuf(i.rdbuf());
+       lineno = 0;
+}
+
+
+void Lexer::Pimpl::setCommentChar(char c)
+{
+       commentChar = c;
+}
+
+
+bool Lexer::Pimpl::next(bool esc /* = false */)
+{
+       if (!pushTok.empty()) {
+               // There can have been a whole line pushed so
+               // we extract the first word and leaves the rest
+               // in pushTok. (Lgb)
+               if (pushTok[0] == '\\' && pushTok.find(' ') != string::npos) {
+                       buff.clear();
+                       pushTok = split(pushTok, buff, ' ');
+               } else {
+                       buff = pushTok;
+                       pushTok.clear();
+               }
+               status = LEX_TOKEN;
+               return true;
+       }
+
+
+       char cc = 0;
+       status = 0;
+       while (is && !status) {
+               is.get(cc);
+               unsigned char c = cc;
+
+               if (c == commentChar) {
+                       // Read rest of line (fast :-)
+#if 1
+                       // That is not fast... (Lgb)
+                       string dummy;
+                       getline(is, dummy);
+
+                       LYXERR(Debug::LYXLEX, "Comment read: `" << string(1, c) << dummy << '\'');
+#else
+                       // unfortunately ignore is buggy (Lgb)
+                       is.ignore(100, '\n');
+#endif
+                       ++lineno;
+                       continue;
+               }
+
+               if (c == '\"') {
+                       buff.clear();
+
+                       if (esc) {
+
+                               do {
+                                       bool escaped = false;
+                                       is.get(cc);
+                                       c = cc;
+                                       if (c == '\r') continue;
+                                       if (c == '\\') {
+                                               // escape the next char
+                                               is.get(cc);
+                                               c = cc;
+                                               if (c == '\"' || c == '\\')
+                                                       escaped = true;
+                                               else
+                                                       buff.push_back('\\');
+                                       }
+                                       buff.push_back(c);
+
+                                       if (!escaped && c == '\"')
+                                               break;
+                               } while (c != '\n' && is);
+
+                       } else {
+
+                               do {
+                                       is.get(cc);
+                                       c = cc;
+                                       if (c != '\r')
+                                               buff.push_back(c);
+                               } while (c != '\"' && c != '\n' && is);
+
+                       }
+
+                       if (c != '\"') {
+                               printError("Missing quote");
+                               if (c == '\n')
+                                       ++lineno;
+                       }
+
+                       buff.resize(buff.size() - 1);
+                       status = LEX_DATA;
+                       break;
+               }
+
+               if (c == ',')
+                       continue;              /* Skip ','s */
+
+               // using relational operators with chars other
+               // than == and != is not safe. And if it is done
+               // the type _have_ to be unsigned. It usually a
+               // lot better to use the functions from cctype
+               if (c > ' ' && is)  {
+                       buff.clear();
+
+                       do {
+                               if (esc && c == '\\') {
+                                       // escape the next char
+                                       is.get(cc);
+                                       c = cc;
+                                       //escaped = true;
+                               }
+                               buff.push_back(c);
+                               is.get(cc);
+                               c = cc;
+                       } while (c > ' ' && c != ',' && is);
+                       status = LEX_TOKEN;
+               }
+
+               if (c == '\r' && is) {
+                       // The Windows support has lead to the
+                       // possibility of "\r\n" at the end of
+                       // a line.  This will stop LyX choking
+                       // when it expected to find a '\n'
+                       is.get(cc);
+                       c = cc;
+               }
+
+               if (c == '\n')
+                       ++lineno;
+
+       }
+       if (status)
+               return true;
+
+       status = is.eof() ? LEX_FEOF: LEX_UNDEF;
+       buff.clear();
+       return false;
+}
+
+
+int Lexer::Pimpl::searchKeyword(char const * const tag) const
+{
+       LexerKeyword search_tag = { tag, 0 };
+       LexerKeyword * res =
+               lower_bound(table, table + no_items,
+                           search_tag, &compareTags);
+       // use the compare_ascii_no_case instead of compare_no_case,
+       // because in turkish, 'i' is not the lowercase version of 'I',
+       // and thus turkish locale breaks parsing of tags.
+       if (res != table + no_items
+           && !compare_ascii_no_case(res->tag, tag))
+               return res->code;
+       return LEX_UNDEF;
+}
+
+
+int Lexer::Pimpl::lex()
+{
+       //NOTE: possible bug.
+       if (next() && status == LEX_TOKEN)
+               return searchKeyword(getString().c_str());
+       return status;
+}
+
+
+bool Lexer::Pimpl::eatLine()
+{
+       buff.clear();
+
+       unsigned char c = '\0';
+       char cc = 0;
+       while (is && c != '\n') {
+               is.get(cc);
+               c = cc;
+               //LYXERR(Debug::LYXLEX, "Lexer::EatLine read char: `" << c << '\'');
+               if (c != '\r' && is)
+                       buff.push_back(c);
+       }
+
+       if (c == '\n') {
+               ++lineno;
+               buff.resize(buff.size() - 1);
+               status = LEX_DATA;
+               return true;
+       } else if (buff.length() > 0) { // last line
+               status = LEX_DATA;
+               return true;
+       } else {
+               return false;
+       }
+}
+
+
+bool Lexer::Pimpl::nextToken()
+{
+       if (!pushTok.empty()) {
+               // There can have been a whole line pushed so
+               // we extract the first word and leaves the rest
+               // in pushTok. (Lgb)
+               if (pushTok[0] == '\\' && pushTok.find(' ') != string::npos) {
+                       buff.clear();
+                       pushTok = split(pushTok, buff, ' ');
+               } else {
+                       buff = pushTok;
+                       pushTok.clear();
+               }
+               status = LEX_TOKEN;
+               return true;
+       }
+
+       status = 0;
+       while (is && !status) {
+               unsigned char c = 0;
+               char cc = 0;
+               is.get(cc);
+               c = cc;
+               if ((c >= ' ' || c == '\t') && is) {
+                       buff.clear();
+
+                       if (c == '\\') { // first char == '\\'
+                               do {
+                                       buff.push_back(c);
+                                       is.get(cc);
+                                       c = cc;
+                               } while (c > ' ' && c != '\\' && is);
+                       } else {
+                               do {
+                                       buff.push_back(c);
+                                       is.get(cc);
+                                       c = cc;
+                               } while ((c >= ' ' || c == '\t') && c != '\\' && is);
+                       }
+
+                       if (c == '\\')
+                               is.putback(c); // put it back
+                       status = LEX_TOKEN;
+               }
+
+               if (c == '\n')
+                       ++lineno;
+
+       }
+       if (status)
+               return true;
+
+       status = is.eof() ? LEX_FEOF: LEX_UNDEF;
+       buff.clear();
+       return false;
+}
+
+
+bool Lexer::Pimpl::inputAvailable()
+{
+       return is.good();
+}
+
+
+void Lexer::Pimpl::pushToken(string const & pt)
+{
+       pushTok = pt;
+}
+
+
+
+
+//////////////////////////////////////////////////////////////////////
+//
+// Lexer
+//
+//////////////////////////////////////////////////////////////////////
+
+Lexer::Lexer()
+       : pimpl_(new Pimpl(nullptr, 0)), lastReadOk_(false)
+{}
+
+
+void Lexer::init(LexerKeyword * tab, int num)
+{
+        pimpl_ = new Pimpl(tab, num);
+}
+
+
+Lexer::~Lexer()
+{
+       delete pimpl_;
+}
+
+
+bool Lexer::isOK() const
+{
+       return pimpl_->inputAvailable();
+}
+
+
+void Lexer::setLineNumber(int l)
+{
+       pimpl_->lineno = l;
+}
+
+
+int Lexer::lineNumber() const
+{
+       return pimpl_->lineno;
+}
+
+
+istream & Lexer::getStream()
+{
+       return pimpl_->is;
+}
+
+
+void Lexer::pushTable(LexerKeyword * tab, int num)
+{
+       pimpl_->pushTable(tab, num);
+}
+
+
+void Lexer::popTable()
+{
+       pimpl_->popTable();
+}
+
+
+void Lexer::printTable(ostream & os)
+{
+       pimpl_->printTable(os);
+}
+
+
+void Lexer::printError(string const & message) const
+{
+       pimpl_->printError(message);
+}
+
+
+bool Lexer::setFile(FileName const & filename)
+{
+       return pimpl_->setFile(filename);
+}
+
+
+void Lexer::setStream(istream & i)
+{
+       pimpl_->setStream(i);
+}
+
+
+void Lexer::setCommentChar(char c)
+{
+       pimpl_->setCommentChar(c);
+}
+
+
+int Lexer::lex()
+{
+       return pimpl_->lex();
+}
+
+
+int Lexer::getInteger() const
+{
+       lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
+       if (!lastReadOk_) {
+               pimpl_->printError("integer token missing");
+               return -1;
+       }
+
+       if (isStrInt(pimpl_->getString()))
+               return convert<int>(pimpl_->getString());
+
+       lastReadOk_ = false;
+       pimpl_->printError("Bad integer `$$Token'");
+       return -1;
+}
+
+
+double Lexer::getFloat() const
+{
+       // replace comma with dot in case the file was written with
+       // the wrong locale (should be rare, but is easy enough to
+       // avoid).
+       lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
+       if (!lastReadOk_) {
+               pimpl_->printError("float token missing");
+               return -1;
+       }
+
+       string const str = subst(pimpl_->getString(), ",", ".");
+       if (isStrDbl(str))
+               return convert<double>(str);
+
+       lastReadOk_ = false;
+       pimpl_->printError("Bad float `$$Token'");
+       return -1;
+}
+
+
+string const Lexer::getString(bool trim) const
+{
+       lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
+
+       if (lastReadOk_)
+               return trim ? support::trim(pimpl_->getString(), "\t ") : pimpl_->getString();
+
+       return string();
+}
+
+
+docstring const Lexer::getDocString(bool trim) const
+{
+       lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
+
+       if (lastReadOk_)
+               return trim ? support::trim(pimpl_->getDocString(), "\t ") : pimpl_->getDocString();
+
+       return docstring();
+}
+
+
+// I would prefer to give a tag number instead of an explicit token
+// here, but it is not possible because Buffer::readDocument uses
+// explicit tokens (JMarc)
+docstring Lexer::getLongString(docstring const & endtoken)
+{
+       docstring str;
+       docstring prefix;
+       bool firstline = true;
+       bool foundend = false;
+
+       while (pimpl_->is) { //< eatLine only reads from is, not from pushTok
+               if (!eatLine())
+                       // blank line in the file being read
+                       continue;
+               docstring tmpstr = getDocString();
+               docstring const token = trim(tmpstr, " \t");
+
+               LYXERR(Debug::PARSER, "LongString: `" << tmpstr << '\'');
+
+               // We do a case independent comparison, like searchKeyword does.
+               if (compare_no_case(token, endtoken) == 0) {
+                       foundend = true;
+                       break;
+               }
+
+               if (firstline) {
+                       size_t i = tmpstr.find_first_not_of(from_ascii(" \t"));
+                       if (i != string::npos)
+                               prefix = tmpstr.substr(0, i);
+                       firstline = false;
+                       LYXERR(Debug::PARSER, "Prefix = `" << prefix << "\'");
+               }
+
+               // further lines in long strings may have the same
+               // whitespace prefix as the first line. Remove it.
+               if (!prefix.empty() && prefixIs(tmpstr, prefix))
+                       tmpstr.erase(0, prefix.length());
+
+               str += tmpstr + '\n';
+       }
+
+       if (!foundend)
+               printError("Long string not ended by `" + to_utf8(endtoken) + '\'');
+
+       return str;
+}
+
+
+bool Lexer::getBool() const
+{
+       string const s = pimpl_->getString();
+       if (s == "false" || s == "0") {
+               lastReadOk_ = true;
+               return false;
+       }
+       if (s == "true" || s == "1") {
+               lastReadOk_ = true;
+               return true;
+       }
+       pimpl_->printError("Bad boolean `$$Token'. "
+                                "Use \"false\" or \"true\"");
+       lastReadOk_ = false;
+       return false;
+}
+
+
+bool Lexer::eatLine()
+{
+       return pimpl_->eatLine();
+}
+
+
+bool Lexer::next(bool esc)
+{
+       return pimpl_->next(esc);
+}
+
+
+bool Lexer::nextToken()
+{
+       return pimpl_->nextToken();
+}
+
+
+void Lexer::pushToken(string const & pt)
+{
+       pimpl_->pushToken(pt);
+}
+
+
+Lexer::operator void const *() const
+{
+       // This behaviour is NOT the same as the streams which would
+       // use fail() here. However, our implementation of getString() et al.
+       // can cause the eof() and fail() bits to be set, even though we
+       // haven't tried to read 'em.
+       return lastReadOk_? this : nullptr;
+}
+
+
+bool Lexer::operator!() const
+{
+       return !lastReadOk_;
+}
+
+
+Lexer & Lexer::operator>>(string & s)
+{
+       if (isOK()) {
+               next();
+               s = getString();
+       } else {
+               lastReadOk_ = false;
+       }
+       return *this;
+}
+
+
+Lexer & Lexer::operator>>(docstring & s)
+{
+       if (isOK()) {
+               next();
+               s = getDocString();
+       } else {
+               lastReadOk_ = false;
+       }
+       return *this;
+}
+
+
+Lexer & Lexer::operator>>(double & s)
+{
+       if (isOK()) {
+               next();
+               s = getFloat();
+       } else {
+               lastReadOk_ = false;
+       }
+       return *this;
+}
+
+
+Lexer & Lexer::operator>>(int & s)
+{
+       if (isOK()) {
+               next();
+               s = getInteger();
+       } else {
+               lastReadOk_ = false;
+       }
+       return *this;
+}
+
+
+Lexer & Lexer::operator>>(unsigned int & s)
+{
+       if (isOK()) {
+               next();
+               s = getInteger();
+       } else {
+               lastReadOk_ = false;
+       }
+       return *this;
+}
+
+
+Lexer & Lexer::operator>>(bool & s)
+{
+       if (isOK()) {
+               next();
+               s = getBool();
+       } else {
+               lastReadOk_ = false;
+       }
+       return *this;
+}
+
+
+Lexer & Lexer::operator>>(char & c)
+{
+       string s;
+       operator>>(s);
+       if (!s.empty())
+               c = s[0];
+       return *this;
+}
+
+
+// quotes a string, e.g. for use in preferences files or as an argument
+// of the "log" dialog
+string Lexer::quoteString(string const & arg)
+{
+       string res;
+       res += '"';
+       res += subst(subst(arg, "\\", "\\\\"), "\"", "\\\"");
+       res += '"';
+       return res;
+}
+
+
+// same for docstring
+docstring Lexer::quoteString(docstring const & arg)
+{
+       docstring res;
+       res += '"';
+       res += subst(subst(arg, from_ascii("\\"), from_ascii("\\\\")),
+                    from_ascii("\""), from_ascii("\\\""));
+       res += '"';
+       return res;
+}
+
+
+Lexer & Lexer::operator>>(char const * required)
+{
+       string token;
+       *this >> token;
+       if (token != required) {
+               LYXERR0("Missing '" << required << "'-tag in " << pimpl_->context
+                       << ". Got " << token << " instead. Line: " << lineNumber());
+               pushToken(token);
+       }
+       return *this;
+}
+
+
+bool Lexer::checkFor(char const * required)
+{
+       string token;
+       *this >> token;
+       if (token == required)
+               return true;
+       pushToken(token);
+       return false;
+}
+
+
+void Lexer::setContext(std::string const & functionName)
+{
+       pimpl_->context = functionName;
+}
+
+} // namespace support
+
+} // namespace lyx
diff --git a/src/support/Lexer.h b/src/support/Lexer.h
new file mode 100644 (file)
index 0000000..96ac205
--- /dev/null
@@ -0,0 +1,264 @@
+// -*- C++ -*-
+/**
+ * \file Lexer.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+//  Generalized simple lexical analizer.
+//  It can be used for simple syntax parsers, like lyxrc,
+//  texclass and others to come.
+
+#ifndef LEXER_H
+#define LEXER_H
+
+#include "support/strfwd.h"
+#include <string>
+
+namespace lyx {
+
+namespace support {
+
+class FileName;
+
+/** A helper structure to describe a keyword for the Lexer.
+       Usually used bundled in C style arrays and passed to the
+       Lexer using a LexerKeywordTable object.
+*/
+struct LexerKeyword
+{
+       /// the string to be recognized
+       char const * tag;
+       /// a corresponding numerical id
+       int code;
+};
+
+
+/** Generalized simple lexical analyzer.
+       Use the method isOK() to check if there is still data available
+       for lexing. Use one of the the operators void* or ! to test if
+       the last reading operation was successful.
+
+       Example:
+
+       int readParam(LyxLex & lex)
+       {
+               int param = 1;    // default value
+               if (lex.isOK()) { // the lexer has data to read
+                       int p;          // temporary variable
+                       lex >> p;
+                       if (lex)
+                               param = p; // only use the input if reading was successful
+               }
+               return param;
+       }
+
+    @see LyXRC.cpp for an example of usage.
+  */
+class Lexer
+{
+public:
+       /// initialize Lexer with no special keywords.
+       Lexer();
+       /// initialize Lexer with a bunch of keywords
+       template<int N> Lexer(LexerKeyword (&table)[N])
+       : pimpl_(0), lastReadOk_(false) { init(table, N); }
+
+       ///
+       ~Lexer();
+
+       /// Lex basic codes
+       enum {
+               ///
+               LEX_UNDEF = -1,
+               ///
+               LEX_FEOF  = -2,
+               ///
+               LEX_DATA  = -3,
+               ///
+               LEX_TOKEN = -4
+       };
+
+       /// stream is open and end of stream is not reached
+       /// FIXME: test also if pushToken is not empty
+       /// FIXME: the method should be renamed to something like
+       ///        dataAvailable(), in order to reflect the real behavior
+       bool isOK() const;
+       /// FIXME: The next two operators should be replaced by one method
+       ///        called e.g. lastReadOk(), in order to reflect the real
+       ///        behavior
+       /// last read operation was successful.
+       operator void const *() const;
+       /// last read operation was not successful
+       bool operator!() const;
+       /// return true if able to open file, else false
+       bool setFile(support::FileName const & filename);
+       ///
+       void setStream(std::istream & is);
+       ///
+       std::istream & getStream();
+       /// Danger! Don't use it unless you know what you are doing.
+       void setLineNumber(int l);
+       /// Change the character that begins a comment. Default is '#'
+       void setCommentChar(char c);
+
+       /// returns a lex code
+       int lex();
+
+       /// Read the next string, as delimited by double quotes or
+       /// whitespace. If esc is true, then we remember that some chars
+       /// might be escaped: \" at least.
+       bool next(bool esc = false);
+
+       /// Read next token. This one is almost the same as next(),
+       /// but it will consider " as a regular character and always
+       /// split a word if it contains a backslash.
+       bool nextToken();
+
+       /// Puts the rest of the line in the buffer, where it will
+       /// be available via getString() or getDocString().
+       bool eatLine();
+
+       /// Push a token, that next token got from lyxlex.
+       void pushToken(std::string const &);
+
+       /// return the current line number
+       int lineNumber() const;
+
+       ///
+       int getInteger() const;
+       ///
+       bool getBool() const;
+       ///
+       double getFloat() const;
+       ///
+       std::string const getString(bool trim = false) const;
+       ///
+       docstring const getDocString(bool trim = false) const;
+       /** Get a long string, ended by the tag `endtoken'. This string
+           can span several lines. The first line serves as a template
+           for what sequence of tabs and spaces make up the indentation.
+           This prefix is skipped from each following line.
+       */
+       docstring getLongString(docstring const & endtoken);
+
+       /// Pushes a token list on a stack and replaces it with a new one.
+       template<int N> void pushTable(LexerKeyword (&table)[N])
+               { pushTable(table, N); }
+
+       /** Pops a token list into void and replaces it with the one now
+           on top of the stack.
+       */
+       void popTable();
+
+       /** Prints an error message with the corresponding line number
+           and file name. If message contains the substring `$$Token',
+           it is replaced with the value of GetString()
+       */
+       void printError(std::string const & message) const;
+
+       /// Prints the current token table on the supplied ostream.
+       void printTable(std::ostream &);
+       /// Used to dispaly context information in case of errors.
+       void setContext(std::string const & functionName);
+
+       /// extract string
+       Lexer & operator>>(std::string &);
+       /// extract docstring
+       Lexer & operator>>(docstring &);
+       /// extract double
+       Lexer & operator>>(double &);
+       /// extract integer
+       Lexer & operator>>(int &);
+       /// extract unsigned integer
+       Lexer & operator>>(unsigned int &);
+       /// extract bool
+       Lexer & operator>>(bool &);
+       /// extract first char of the string
+       Lexer & operator>>(char &);
+
+       /// read and check a required token
+       Lexer & operator>>(char const * required);
+       /// check for an optional token and swallow it if present.
+       bool checkFor(char const * required);
+
+       /// Quotes a string so that reading it again with Lexer::next(true)
+       /// gets the original string
+       static std::string quoteString(std::string const &);
+       /// Quotes a docstring so that reading it again with Lexer::next(true)
+       /// gets the original string
+       static docstring quoteString(docstring const &);
+
+private:
+       /// noncopyable
+       Lexer(Lexer const &);
+       void operator=(Lexer const &);
+
+       ///
+       friend class PushPopHelper;
+
+       ///
+       void init(LexerKeyword *, int);
+       void pushTable(LexerKeyword *, int);
+
+       ///
+       class Pimpl;
+       ///
+       Pimpl * pimpl_;
+       ///
+       mutable bool lastReadOk_;
+};
+
+
+/// extract something constructable from a string, i.e. a LaTeX length
+template <class T>
+Lexer & operator>>(Lexer & lex, T & t)
+{
+       if (lex.next())
+               t = T(lex.getString());
+       return lex;
+}
+
+
+/** Use to enable multiple exit points.
+    This is needed to ensure that the pop is done upon exit from methods
+    with more than one exit point or that can return as a response to
+    exceptions.
+    @author Lgb
+*/
+class PushPopHelper
+{
+public:
+       ///
+       template<int N>
+       PushPopHelper(Lexer & l, LexerKeyword (&table)[N])
+               : lex(l)
+       {
+               lex.pushTable(table, N);
+       }
+       ///
+       ~PushPopHelper()
+       {
+               lex.popTable();
+       }
+       ///
+       Lexer & lex;
+};
+/** Avoid wrong usage of PushPopHelper.
+    To avoid wrong usage:
+    PushPopHelper(...); // wrong
+    PushPopHelper pph(...); // right
+*/
+#define PushPopHelper(x, y, z) unnamed_PushPopHelper;
+// Tip gotten from Bobby Schmidt's column in C/C++ Users Journal
+
+} // namespace support
+
+} // namespace lyx
+
+#endif
index 2c2fce5f46a8d072d1c93a408bd72cbac87ff25f..5c181d6852fe4b2b16acb4754901e206d5def331 100644 (file)
@@ -77,6 +77,8 @@ liblyxsupport_a_SOURCES = \
        Length.cpp \
        Length.h \
        lengthcommon.cpp \
+       Lexer.cpp \
+       Lexer.h \
        limited_stack.h \
        lstrings.cpp \
        lstrings.h \
index 3226b0f0a5f5cfeeac64cd92e5f09bdc823de63f..33885556b5a1b183f42239b91f4addfa07a2f663 100644 (file)
 #include "Encoding.h"
 #include "LaTeXPackages.h"
 #include "LayoutFile.h"
-#include "Lexer.h"
 #include "TextClass.h"
 #include "version.h"
 
 #include "support/convert.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <algorithm>