2 // Generalized simple lexical analizer.
3 // It can be used for simple syntax parsers, like lyxrc,
4 // texclass and others to come. [asierra30/03/96]
28 Generalized simple lexical analizer.
29 It can be used for simple syntax parsers, like lyxrc,
30 texclass and others to come.
31 See lyxrc.C for an example of usage.
36 LyXLex (keyword_item *, int);
50 /// file is open and end of file is not reached
52 /// return true if able to open file, else false
53 bool setFile(string const & filename);
55 void setStream(istream & i);
57 istream & getStream() { return is; }
58 /// Danger! Don't use it unless you know what you are doing.
59 void setLineNo(int l) { lineno = l; }
60 /// returns a lex code
63 /** Just read athe next word. If esc is true remember that
64 some chars might be escaped: "\ atleast */
65 bool next(bool esc = false);
67 /** Read next token. This one is almost the same as next,
68 but it will consider " as a regular character and always
69 split a word if it contains a backslash.
74 int GetLineNo() const { return lineno; }
76 int GetInteger() const;
80 float GetFloat() const;
82 string GetString() const;
84 /// get a long string, ended by the tag `endtag'
85 string getLongString(string const & endtoken);
90 int FindToken(char const * string[]);
92 int CheckToken(char const * string[], int print_error);
95 char const * text() const { return &buff[0]; }
97 /** Pushes a token list on a stack and replaces it with a new one.
99 void pushTable(keyword_item *, int);
101 /** Pops a token list into void and replaces it with the one now
106 /** Prints an error message with the corresponding line number
107 and file name. If message contains the substring `$$Token',
108 it is replaced with the value of GetString()
110 void printError(string const & message) const;
113 Prints the current token table on cerr.
124 struct pushed_table {
133 keyword_item * table_elem;
138 /// fb__ is only used to open files, the stream is accessed through is
140 /// the stream that we use.
147 keyword_item * table;
151 char buff[LEX_MAX_BUFF];
153 pushed_table * pushed;
155 int search_kw(char const * const) const;
162 bool LyXLex::IsOK() const
168 // This is needed to ensure that the pop is done upon exit from methods
169 // with more than one exit point or that can return as a response to
171 struct pushpophelper {
172 pushpophelper(LyXLex & lexrc, keyword_item * i, int s) : lex(lexrc) {