2000-04-08 17:02:02 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file lyxlex_pimpl.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
|
|
|
|
#ifndef LYXLEX_PIMPL_H
|
|
|
|
|
#define LYXLEX_PIMPL_H
|
|
|
|
|
|
|
|
|
|
#include "lyxlex.h"
|
|
|
|
|
|
2005-01-20 21:34:23 +00:00
|
|
|
|
# include "support/gzstream.h"
|
2003-07-27 23:40:08 +00:00
|
|
|
|
|
2003-02-13 16:53:15 +00:00
|
|
|
|
#include <boost/utility.hpp>
|
|
|
|
|
|
2005-01-31 15:26:40 +00:00
|
|
|
|
#include <fstream>
|
2005-01-20 21:34:23 +00:00
|
|
|
|
#include <istream>
|
2003-02-13 16:53:15 +00:00
|
|
|
|
#include <stack>
|
2003-04-14 12:44:36 +00:00
|
|
|
|
#include <vector>
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
|
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class LyXLex::Pimpl : boost::noncopyable {
|
|
|
|
|
public:
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
Pimpl(keyword_item * tab, int num);
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const getString() const;
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void printError(std::string const & message) const;
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
void printTable(std::ostream & os);
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
void pushTable(keyword_item * tab, int num);
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
void popTable();
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool setFile(std::string const & filename);
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
void setStream(std::istream & i);
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2000-11-08 15:19:55 +00:00
|
|
|
|
void setCommentChar(char c);
|
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
bool next(bool esc = false);
|
|
|
|
|
///
|
|
|
|
|
int search_kw(char const * const tag) const;
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
int lex();
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2001-08-06 19:12:46 +00:00
|
|
|
|
bool eatLine();
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
bool nextToken();
|
2000-07-31 16:39:50 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void pushToken(std::string const &);
|
2003-12-02 12:02:39 +00:00
|
|
|
|
/// fb_ is only used to open files, the stream is accessed through is.
|
|
|
|
|
std::filebuf fb_;
|
2005-01-20 21:34:23 +00:00
|
|
|
|
|
2003-12-02 12:02:39 +00:00
|
|
|
|
/// gz_ is only used to open files, the stream is accessed through is.
|
|
|
|
|
gz::gzstreambuf gz_;
|
2003-07-27 23:40:08 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
/// the stream that we use.
|
|
|
|
|
std::istream is;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string name;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
///
|
|
|
|
|
keyword_item * table;
|
|
|
|
|
///
|
|
|
|
|
int no_items;
|
|
|
|
|
///
|
2003-04-14 12:44:36 +00:00
|
|
|
|
std::vector<char> buff;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
///
|
2001-10-01 15:31:59 +00:00
|
|
|
|
int status;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
///
|
|
|
|
|
int lineno;
|
2000-05-17 14:43:09 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string pushTok;
|
2000-11-08 15:19:55 +00:00
|
|
|
|
///
|
|
|
|
|
char commentChar;
|
2000-08-05 05:17:18 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
void verifyTable();
|
|
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class pushed_table {
|
|
|
|
|
public:
|
2000-08-05 05:17:18 +00:00
|
|
|
|
///
|
|
|
|
|
pushed_table()
|
|
|
|
|
: table_elem(0), table_siz(0) {}
|
|
|
|
|
///
|
|
|
|
|
pushed_table(keyword_item * ki, int siz)
|
|
|
|
|
: table_elem(ki), table_siz(siz) {}
|
|
|
|
|
///
|
|
|
|
|
keyword_item * table_elem;
|
|
|
|
|
///
|
|
|
|
|
int table_siz;
|
|
|
|
|
};
|
|
|
|
|
///
|
|
|
|
|
std::stack<pushed_table> pushed;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
};
|
|
|
|
|
#endif
|