4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
19 enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE, MATHTEXT_MODE, TABLE_MODE};
21 mode_type asMode(mode_type oldmode, std::string const & str);
24 // These are TeX's catcodes
26 catEscape, // 0 backslash
37 catLetter, // 11 a-zA-Z
38 catOther, // 12 none of the above
41 catInvalid // 15 <delete>
45 CatCode catcode(unsigned char c);
49 FLAG_BRACE_LAST = 1 << 1, // last closing brace ends the parsing
50 FLAG_RIGHT = 1 << 2, // next \\right ends the parsing process
51 FLAG_END = 1 << 3, // next \\end ends the parsing process
52 FLAG_BRACK_LAST = 1 << 4, // next closing bracket ends the parsing
53 FLAG_TEXTMODE = 1 << 5, // we are in a box
54 FLAG_ITEM = 1 << 6, // read a (possibly braced token)
55 FLAG_LEAVE = 1 << 7, // leave the loop at the end
56 FLAG_SIMPLE = 1 << 8, // next $ leaves the loop
57 FLAG_EQUATION = 1 << 9, // next \] leaves the loop
58 FLAG_SIMPLE2 = 1 << 10, // next \) leaves the loop
59 FLAG_OPTION = 1 << 11, // read [...] style option
60 FLAG_BRACED = 1 << 12, // read {...} style argument
61 FLAG_CELL = 1 << 13 // read table cell
67 // Helper class for parsing
73 Token() : cs_(), char_(0), cat_(catIgnore) {}
75 Token(char c, CatCode cat) : cs_(), char_(c), cat_(cat) {}
77 Token(std::string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
80 std::string const & cs() const { return cs_; }
82 CatCode cat() const { return cat_; }
84 char character() const { return char_; }
86 std::string asString() const;
88 std::string asInput() const;
99 std::ostream & operator<<(std::ostream & os, Token const & t);
103 // Actual parser class
110 Parser(std::istream & is);
112 Parser(std::string const & s);
115 int lineno() const { return lineno_; }
118 /// dump contents to screen
122 std::string getArg(char left, char right);
123 /// getArg('[', ']') including the brackets
124 std::string getOpt();
128 void error(std::string const & msg);
130 void tokenize(std::istream & is);
132 void push_back(Token const & t);
136 Token const & prev_token() const;
138 Token const & next_token() const;
140 Token const & get_token();
141 /// skips spaces if any
144 void lex(std::string const & s);
148 std::string verbatim_item();
150 std::string verbatimOption();
153 void setCatCode(char c, CatCode cat);
155 CatCode getCatCode(char c) const;
161 std::vector<Token> tokens_;