]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/texparser.h
Add a Buffer::fully_loaded member function, returning true only when
[lyx.git] / src / tex2lyx / texparser.h
index d550e9d320b2d57a2eb967bf50a6e1bafb9e8ed5..aff580a8c3350301d1c3f8ee1b224e7152de03fe 100644 (file)
@@ -1,13 +1,24 @@
+// -*- C++ -*-
+/**
+ * \file texparser.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
 #ifndef PARSER_H
 #define PARSER_H
 
-#include "LString.h"
 #include <vector>
+#include <string>
 
-enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE};
 
-mode_type asMode(mode_type oldmode, string const & str);
+enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE, MATHTEXT_MODE, TABLE_MODE};
+
+mode_type asMode(mode_type oldmode, std::string const & str);
 
 
 // These are TeX's catcodes
@@ -46,7 +57,8 @@ enum {
        FLAG_EQUATION   = 1 << 9,  //  next \] leaves the loop
        FLAG_SIMPLE2    = 1 << 10, //  next \) leaves the loop
        FLAG_OPTION     = 1 << 11, //  read [...] style option
-       FLAG_BRACED     = 1 << 12  //  read {...} style argument
+       FLAG_BRACED     = 1 << 12, //  read {...} style argument
+       FLAG_CELL       = 1 << 13  //  read table cell
 };
 
 
@@ -62,27 +74,29 @@ public:
        ///
        Token(char c, CatCode cat) : cs_(), char_(c), cat_(cat) {}
        ///
-       Token(string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
+       Token(std::string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
 
        ///
-       string const & cs() const { return cs_; }
+       std::string const & cs() const { return cs_; }
        ///
        CatCode cat() const { return cat_; }
        ///
        char character() const { return char_; }
        ///
-       string asString() const { return cs_.size() ? cs_ : string(1, char_); }
+       std::string asString() const;
+       ///
+       std::string asInput() const;
 
 private:
        ///
-       string cs_;
+       std::string cs_;
        ///
        char char_;
        ///
        CatCode cat_;
 };
 
-ostream & operator<<(ostream & os, Token const & t);
+std::ostream & operator<<(std::ostream & os, Token const & t);
 
 
 //
@@ -93,7 +107,9 @@ class Parser {
 
 public:
        ///
-       Parser(istream & is);
+       Parser(std::istream & is);
+       ///
+       Parser(std::string const & s);
 
        ///
        int lineno() const { return lineno_; }
@@ -103,43 +119,49 @@ public:
        void dump() const;
 
        ///
-       string getArg(char left, char right);
+       std::string getArg(char left, char right);
+       /// getArg('[', ']') including the brackets
+       std::string getOpt();
        ///
        char getChar();
        ///
-       void error(string const & msg);
-       ///
-       void tokenize(istream & is);
+       void error(std::string const & msg);
        ///
-       void skipSpaceTokens(istream & is, char c);
+       void tokenize(std::istream & is);
        ///
        void push_back(Token const & t);
        ///
        void pop_back();
        ///
-       Token const & prevToken() const;
+       Token const & prev_token() const;
        ///
-       Token const & nextToken() const;
+       Token const & next_token() const;
        ///
-       Token const & getToken();
+       Token const & get_token();
        /// skips spaces if any
-       void skipSpaces();
+       void skip_spaces();
        ///
-       void lex(string const & s);
+       void lex(std::string const & s);
        ///
        bool good() const;
        ///
-       string verbatimItem();
+       std::string verbatim_item();
        ///
-       string verbatimOption();
+       std::string verbatimOption();
+
+       ///
+       void setCatCode(char c, CatCode cat);
+       ///
+       CatCode getCatCode(char c) const;
 
 //private:
        ///
        int lineno_;
        ///
-       vector<Token> tokens_;
+       std::vector<Token> tokens_;
        ///
        unsigned pos_;
 };
 
+
 #endif