+// -*- 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
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
};
///
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);
//
public:
///
- Parser(istream & is);
+ Parser(std::istream & is);
+ ///
+ Parser(std::string const & s);
///
int lineno() const { return lineno_; }
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 tokenize(string const & s);
+ 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