patch, but as this was rather largish...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24099
a592a061-630c-0410-9148-
cb99ea01b6c8
43 files changed:
// remove dummy empty par
paragraphs().clear();
// remove dummy empty par
paragraphs().clear();
istringstream is(s);
lex.setStream(is);
FileName const name = FileName::tempName();
istringstream is(s);
lex.setStream(is);
FileName const name = FileName::tempName();
// remove dummy empty par
paragraphs().clear();
// remove dummy empty par
paragraphs().clear();
lex.setFile(fname);
if (readFile(lex, fname) != success)
return false;
lex.setFile(fname);
if (readFile(lex, fname) != success)
return false;
-LexerKeyword cmdDefTags[] = {
+keyword_item cmdDefTags[] = {
{ "\\def_file", BN_DEFFILE },
{ "\\define", BN_DEFINE }
};
{ "\\def_file", BN_DEFFILE },
{ "\\define", BN_DEFINE }
};
bool CmdDef::read(string const & def_file)
{
bool CmdDef::read(string const & def_file)
{
- Lexer lexrc(cmdDefTags);
+ const int cmdDefCount = sizeof(cmdDefTags) / sizeof(keyword_item);
+
+ Lexer lexrc(cmdDefTags, cmdDefCount);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
time_t const now = current_time();
FileName const index(addName(cache_dir.absFilename(), "index"));
ifstream is(index.toFilesystemEncoding().c_str());
time_t const now = current_time();
FileName const index(addName(cache_dir.absFilename(), "index"));
ifstream is(index.toFilesystemEncoding().c_str());
lex.setStream(is);
while (lex.isOK()) {
if (!lex.next(true))
lex.setStream(is);
while (lex.isOK()) {
if (!lex.next(true))
{
// We must read the symbolsfile first, because the Encoding
// constructor depends on it.
{
// We must read the symbolsfile first, because the Encoding
// constructor depends on it.
+ Lexer symbolslex(0, 0);
symbolslex.setFile(symbolsfile);
while (symbolslex.isOK()) {
char_type symbol;
symbolslex.setFile(symbolsfile);
while (symbolslex.isOK()) {
char_type symbol;
enum Encodingtags {
et_encoding = 1,
et_end,
enum Encodingtags {
et_encoding = 1,
et_end,
- struct LexerKeyword encodingtags[] = {
+ struct keyword_item encodingtags[et_last - 1] = {
{ "encoding", et_encoding },
{ "end", et_end }
};
{ "encoding", et_encoding },
{ "end", et_end }
};
- Lexer lex(encodingtags);
+ Lexer lex(encodingtags, et_last - 1);
lex.setFile(encfile);
while (lex.isOK()) {
switch (lex.lex()) {
lex.setFile(encfile);
while (lex.isOK()) {
switch (lex.lex()) {
bool Font::fromString(string const & data, bool & toggle)
{
istringstream is(data);
bool Font::fromString(string const & data, bool & toggle)
{
istringstream is(data);
lex.setStream(is);
int nset = 0;
lex.setStream(is);
int nset = 0;
-LexerKeyword bindTags[] = {
+keyword_item bindTags[] = {
{ "\\bind", BN_BIND },
{ "\\bind_file", BN_BINDFILE },
{ "\\unbind", BN_UNBIND },
{ "\\bind", BN_BIND },
{ "\\bind_file", BN_BINDFILE },
{ "\\unbind", BN_UNBIND },
bool KeyMap::read(string const & bind_file, KeyMap * unbind_map)
{
bool KeyMap::read(string const & bind_file, KeyMap * unbind_map)
{
+ const int bindCount = sizeof(bindTags) / sizeof(keyword_item);
+
+ Lexer lexrc(bindTags, bindCount);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
FuncRequest func = lyxaction.lookupFunc(cmd);
if (func. action == LFUN_UNKNOWN_ACTION) {
FuncRequest func = lyxaction.lookupFunc(cmd);
if (func. action == LFUN_UNKNOWN_ACTION) {
- lexrc.printError("BN_BIND: Unknown LyX"
- " function `$$Token'");
+ lexrc.printError("BN_BIND: Unknown LyX function `$$Token'");
void LaTeXFeatures::getAvailable()
{
void LaTeXFeatures::getAvailable()
{
support::FileName const real_file = libFileSearch("", "packages.lst");
if (real_file.empty())
support::FileName const real_file = libFileSearch("", "packages.lst");
if (real_file.empty())
encodings.fromLyXName("iso8859-1"),
"latex", "");
encodings.fromLyXName("iso8859-1"),
"latex", "");
lex.setFile(filename);
while (lex.isOK()) {
string lang;
lex.setFile(filename);
while (lex.isOK()) {
string lang;
bool Layout::read(Lexer & lexrc, TextClass const & tclass)
{
// This table is sorted alphabetically [asierra 30March96]
bool Layout::read(Lexer & lexrc, TextClass const & tclass)
{
// This table is sorted alphabetically [asierra 30March96]
- LexerKeyword layoutTags[] = {
+ keyword_item layoutTags[] = {
{ "align", LT_ALIGN },
{ "alignpossible", LT_ALIGNPOSSIBLE },
{ "bottomsep", LT_BOTTOMSEP },
{ "align", LT_ALIGN },
{ "alignpossible", LT_ALIGNPOSSIBLE },
{ "bottomsep", LT_BOTTOMSEP },
bool error = false;
bool finished = false;
bool error = false;
bool finished = false;
- lexrc.pushTable(layoutTags);
+ lexrc.pushTable(layoutTags, LT_INTITLE);
// parse style section
while (!finished && lexrc.isOK() && !error) {
int le = lexrc.lex();
// parse style section
while (!finished && lexrc.isOK() && !error) {
int le = lexrc.lex();
void Layout::readAlign(Lexer & lexrc)
{
void Layout::readAlign(Lexer & lexrc)
{
- LexerKeyword alignTags[] = {
+ keyword_item alignTags[] = {
{ "block", AT_BLOCK },
{ "center", AT_CENTER },
{ "layout", AT_LAYOUT },
{ "block", AT_BLOCK },
{ "center", AT_CENTER },
{ "layout", AT_LAYOUT },
void Layout::readAlignPossible(Lexer & lexrc)
{
void Layout::readAlignPossible(Lexer & lexrc)
{
- LexerKeyword alignTags[] = {
+ keyword_item alignTags[] = {
{ "block", AT_BLOCK },
{ "center", AT_CENTER },
{ "layout", AT_LAYOUT },
{ "block", AT_BLOCK },
{ "center", AT_CENTER },
{ "layout", AT_LAYOUT },
- lexrc.pushTable(alignTags);
+ lexrc.pushTable(alignTags, AT_LAYOUT);
alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
alignpossible = LYX_ALIGN_NONE | LYX_ALIGN_LAYOUT;
- int lineno = lexrc.lineNumber();
+ int lineno = lexrc.getLineNo();
do {
int le = lexrc.lex();
switch (le) {
do {
int le = lexrc.lex();
switch (le) {
alignpossible |= LYX_ALIGN_LAYOUT;
break;
}
alignpossible |= LYX_ALIGN_LAYOUT;
break;
}
- } while (lineno == lexrc.lineNumber());
+ } while (lineno == lexrc.getLineNo());
void Layout::readLabelType(Lexer & lexrc)
{
void Layout::readLabelType(Lexer & lexrc)
{
- LexerKeyword labelTypeTags[] = {
+ keyword_item labelTypeTags[] = {
{ "bibliography", LA_BIBLIO },
{ "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
{ "counter", LA_COUNTER },
{ "bibliography", LA_BIBLIO },
{ "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
{ "counter", LA_COUNTER },
-static LexerKeyword endlabelTypeTags[] =
+static keyword_item endlabelTypeTags[] =
{
{ "box", END_LABEL_BOX },
{ "filled_box", END_LABEL_FILLED_BOX },
{
{ "box", END_LABEL_BOX },
{ "filled_box", END_LABEL_FILLED_BOX },
void Layout::readMargin(Lexer & lexrc)
{
void Layout::readMargin(Lexer & lexrc)
{
- LexerKeyword marginTags[] = {
+ keyword_item marginTags[] = {
{ "dynamic", MARGIN_DYNAMIC },
{ "first_dynamic", MARGIN_FIRST_DYNAMIC },
{ "manual", MARGIN_MANUAL },
{ "dynamic", MARGIN_DYNAMIC },
{ "first_dynamic", MARGIN_FIRST_DYNAMIC },
{ "manual", MARGIN_MANUAL },
void Layout::readLatexType(Lexer & lexrc)
{
void Layout::readLatexType(Lexer & lexrc)
{
- LexerKeyword latexTypeTags[] = {
+ keyword_item latexTypeTags[] = {
{ "bib_environment", LATEX_BIB_ENVIRONMENT },
{ "command", LATEX_COMMAND },
{ "environment", LATEX_ENVIRONMENT },
{ "bib_environment", LATEX_BIB_ENVIRONMENT },
{ "command", LATEX_COMMAND },
{ "environment", LATEX_ENVIRONMENT },
void Layout::readSpacing(Lexer & lexrc)
{
void Layout::readSpacing(Lexer & lexrc)
{
- LexerKeyword spacingTags[] = {
+ keyword_item spacingTags[] = {
{"double", ST_SPACING_DOUBLE },
{"onehalf", ST_SPACING_ONEHALF },
{"other", ST_OTHER },
{"double", ST_SPACING_DOUBLE },
{"onehalf", ST_SPACING_ONEHALF },
{"other", ST_OTHER },
// Reads LyX textclass definitions according to textclass config file
bool LayoutFileList::read()
{
// Reads LyX textclass definitions according to textclass config file
bool LayoutFileList::read()
{
FileName const real_file = libFileSearch("", "textclass.lst");
LYXERR(Debug::TCLASS, "Reading textclasses from `" << real_file << '\'');
FileName const real_file = libFileSearch("", "textclass.lst");
LYXERR(Debug::TCLASS, "Reading textclasses from `" << real_file << '\'');
class Lexer::Pimpl {
public:
///
class Lexer::Pimpl {
public:
///
- Pimpl(LexerKeyword * tab, int num);
+ Pimpl(keyword_item * tab, int num);
///
string const getString() const;
///
///
string const getString() const;
///
///
void printTable(ostream & os);
///
///
void printTable(ostream & os);
///
- void pushTable(LexerKeyword * tab, int num);
+ void pushTable(keyword_item * tab, int num);
PushedTable()
: table_elem(0), table_siz(0) {}
///
PushedTable()
: table_elem(0), table_siz(0) {}
///
- PushedTable(LexerKeyword * ki, int siz)
+ PushedTable(keyword_item * ki, int siz)
: table_elem(ki), table_siz(siz) {}
///
: table_elem(ki), table_siz(siz) {}
///
- LexerKeyword * table_elem;
+ keyword_item * table_elem;
namespace {
class CompareTags
namespace {
class CompareTags
- : public binary_function<LexerKeyword, LexerKeyword, bool> {
+ : public binary_function<keyword_item, keyword_item, bool> {
public:
// used by lower_bound, sort and sorted
public:
// used by lower_bound, sort and sorted
- bool operator()(LexerKeyword const & a, LexerKeyword const & b) const
+ bool operator()(keyword_item const & a, keyword_item const & b) const
{
// we use the ascii version, because in turkish, 'i'
// is not the lowercase version of 'I', and thus
{
// we use the ascii version, because in turkish, 'i'
// is not the lowercase version of 'I', and thus
} // end of anon namespace
} // end of anon namespace
-Lexer::Pimpl::Pimpl(LexerKeyword * tab, int num)
+Lexer::Pimpl::Pimpl(keyword_item * tab, int num)
: is(&fb_), table(tab), no_items(num),
status(0), lineno(0), commentChar('#')
{
: is(&fb_), table(tab), no_items(num),
status(0), lineno(0), commentChar('#')
{
-void Lexer::Pimpl::pushTable(LexerKeyword * tab, int num)
+void Lexer::Pimpl::pushTable(keyword_item * tab, int num)
{
PushedTable tmppu(table, no_items);
pushed.push(tmppu);
{
PushedTable tmppu(table, no_items);
pushed.push(tmppu);
int Lexer::Pimpl::search_kw(char const * const tag) const
{
int Lexer::Pimpl::search_kw(char const * const tag) const
{
- LexerKeyword search_tag = { tag, 0 };
- LexerKeyword * res =
+ keyword_item search_tag = { tag, 0 };
+ keyword_item * res =
lower_bound(table, table + no_items,
search_tag, CompareTags());
// use the compare_ascii_no_case instead of compare_no_case,
lower_bound(table, table + no_items,
search_tag, CompareTags());
// use the compare_ascii_no_case instead of compare_no_case,
//
//////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////
-Lexer::Lexer()
- : pimpl_(new Pimpl(0, 0))
+Lexer::Lexer(keyword_item * tab, int num)
+ : pimpl_(new Pimpl(tab, num))
-void Lexer::init(LexerKeyword * tab, int num)
-{
- pimpl_ = new Pimpl(tab, num);
-}
-
-
Lexer::~Lexer()
{
delete pimpl_;
Lexer::~Lexer()
{
delete pimpl_;
-void Lexer::setLineNumber(int l)
+void Lexer::setLineNo(int l)
-int Lexer::lineNumber() const
+int Lexer::getLineNo() const
{
return pimpl_->lineno;
}
{
return pimpl_->lineno;
}
-void Lexer::pushTable(LexerKeyword * tab, int num)
+void Lexer::pushTable(keyword_item * tab, int num)
{
pimpl_->pushTable(tab, num);
}
{
pimpl_->pushTable(tab, num);
}
namespace support { class FileName; }
namespace support { class FileName; }
-class PushPopHelper;
-
-/** A helper structure to describe a keyword for the Lexer.
- Usually used bundled in C style arrays and passed to the
- Lexer using a LexerKeywordTable object.
-*/
-struct LexerKeyword
-{
- /// the string to be recognized
+///
+struct keyword_item {
+ ///
- /// a corresponding numerical id
/** Generalized simple lexical analizer.
Use the method isOK() to check if there is still data available
for lexing. Use one of the the operators void* or ! to test if
/** Generalized simple lexical analizer.
Use the method isOK() to check if there is still data available
for lexing. Use one of the the operators void* or ! to test if
@see LyXRC.cpp for an example of usage.
*/
@see LyXRC.cpp for an example of usage.
*/
- /// initialize Lexer with no special keywords.
- Lexer();
- /// initialize Lexer with a bunch of keywords
- template<int N> Lexer(LexerKeyword (&table)[N])
- : pimpl_(0) { init(table, N); }
-
+ ///
+ Lexer(keyword_item *, int);
};
/// stream is open and end of stream is not reached
};
/// stream is open and end of stream is not reached
- /// FIXME: test also if pushToken is not empty
+ /// FIXME: test also if pushTok is not empty
/// FIXME: the method should be renamed to something like
/// dataAvailable(), in order to reflect the real behavior
bool isOK() const;
/// FIXME: the method should be renamed to something like
/// dataAvailable(), in order to reflect the real behavior
bool isOK() const;
///
std::istream & getStream();
/// Danger! Don't use it unless you know what you are doing.
///
std::istream & getStream();
/// Danger! Don't use it unless you know what you are doing.
- void setLineNumber(int l);
/// Change the character that begins a comment. Default is '#'
void setCommentChar(char c);
/// Change the character that begins a comment. Default is '#'
void setCommentChar(char c);
/// Push a token, that next token got from lyxlex.
void pushToken(std::string const &);
/// Push a token, that next token got from lyxlex.
void pushToken(std::string const &);
- /// return the current line number
- int lineNumber() const;
+ ///
+ int getLineNo() const;
///
int getInteger() const;
///
int getInteger() const;
bool eatLine();
/// Pushes a token list on a stack and replaces it with a new one.
bool eatLine();
/// Pushes a token list on a stack and replaces it with a new one.
- template<int N> void pushTable(LexerKeyword (&table)[N])
- { pushTable(table, N); }
+ void pushTable(keyword_item *, int);
/** Pops a token list into void and replaces it with the one now
on top of the stack.
/** Pops a token list into void and replaces it with the one now
on top of the stack.
static std::string const quoteString(std::string const &);
private:
static std::string const quoteString(std::string const &);
private:
Lexer(Lexer const &);
void operator=(Lexer const &);
Lexer(Lexer const &);
void operator=(Lexer const &);
- ///
- friend class PushPopHelper;
-
- ///
- void init(LexerKeyword *, int);
- void pushTable(LexerKeyword *, int);
-
exceptions.
@author Lgb
*/
exceptions.
@author Lgb
*/
- PushPopHelper(Lexer & lexrc, LexerKeyword * i, int s)
- : lex(lexrc)
- {
+ PushPopHelper(Lexer & lexrc, keyword_item * i, int s) : lex(lexrc) {
lex.pushTable(i, s);
}
///
lex.pushTable(i, s);
}
///
// Read the ui file `name'
bool LyX::readUIFile(string const & name, bool include)
{
// Read the ui file `name'
bool LyX::readUIFile(string const & name, bool include)
{
ui_menuset = 1,
ui_toolbars,
ui_toolbarset,
ui_menuset = 1,
ui_toolbars,
ui_toolbarset,
- struct LexerKeyword uitags[] = {
+ struct keyword_item uitags[ui_last - 1] = {
{ "include", ui_include },
{ "menuset", ui_menuset },
{ "toolbars", ui_toolbars },
{ "include", ui_include },
{ "menuset", ui_menuset },
{ "toolbars", ui_toolbars },
uifiles.push_back(name);
LYXERR(Debug::INIT, "Found " << name << " in " << ui_path);
uifiles.push_back(name);
LYXERR(Debug::INIT, "Found " << name << " in " << ui_path);
+ Lexer lex(uitags, ui_last - 1);
lex.setFile(ui_path);
if (!lex.isOK()) {
lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
lex.setFile(ui_path);
if (!lex.isOK()) {
lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
Buffer defaults(fname);
istringstream ss(argument);
Buffer defaults(fname);
istringstream ss(argument);
lex.setStream(ss);
int const unknown_tokens = defaults.readHeader(lex);
lex.setStream(ss);
int const unknown_tokens = defaults.readHeader(lex);
cur.recordUndoFullDocument();
istringstream ss(argument);
cur.recordUndoFullDocument();
istringstream ss(argument);
lex.setStream(ss);
int const unknown_tokens = buffer->readHeader(lex);
lex.setStream(ss);
int const unknown_tokens = buffer->readHeader(lex);
namespace {
// when adding something to this array keep it sorted!
namespace {
// when adding something to this array keep it sorted!
-LexerKeyword lyxrcTags[] = {
+keyword_item lyxrcTags[] = {
{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
{ "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
{ "\\alternate_language", LyXRC::RC_ALT_LANG },
{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
{ "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
{ "\\alternate_language", LyXRC::RC_ALT_LANG },
{ "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR}
};
{ "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR}
};
-const int lyxrcCount = sizeof(lyxrcTags) / sizeof(lyxrcTags[0]);
+const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
int LyXRC::read(FileName const & filename)
{
int LyXRC::read(FileName const & filename)
{
- Lexer lexrc(lyxrcTags);
+ Lexer lexrc(lyxrcTags, lyxrcCount);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
int LyXRC::read(istream & is)
{
int LyXRC::read(istream & is)
{
- Lexer lexrc(lyxrcTags);
+ Lexer lexrc(lyxrcTags, lyxrcCount);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
lexrc.setStream(is);
if (lyxerr.debugging(Debug::PARSER))
lexrc.printTable(lyxerr);
lexrc.setStream(is);
- if (!lexrc.isOK()) return -2;
+ if (!lexrc.isOK())
+ return -2;
LYXERR(Debug::LYXRC, "Reading istream...");
LYXERR(Debug::LYXRC, "Reading istream...");
AM_CPPFLAGS += $(PCH_FLAGS) -I$(top_srcdir)/src $(BOOST_INCLUDES)
AM_CPPFLAGS += $(PCH_FLAGS) -I$(top_srcdir)/src $(BOOST_INCLUDES)
-SUBDIRS = support frontends tex2lyx client lyxled .
+SUBDIRS = support frontends tex2lyx client .
EXTRA_DIST = config.h.in \
Section.h \
EXTRA_DIST = config.h.in \
Section.h \
if (!lex.setFile(real_file)) {
lyxerr << "ModuleList::load():"
"lyxlex was not able to set file: "
if (!lex.setFile(real_file)) {
lyxerr << "ModuleList::load():"
"lyxlex was not able to set file: "
void ParagraphParameters::read(string str, bool merge)
{
istringstream is(str);
void ParagraphParameters::read(string str, bool merge)
{
istringstream is(str);
lex.setStream(is);
read(lex, merge);
}
lex.setStream(is);
read(lex, merge);
}
par.params().read(lex);
} else if (token == "\\end_layout") {
par.params().read(lex);
} else if (token == "\\end_layout") {
- LYXERR0("Solitary \\end_layout in line " << lex.lineNumber() << "\n"
+ LYXERR0("Solitary \\end_layout in line " << lex.getLineNo() << "\n"
<< "Missing \\begin_layout ?");
} else if (token == "\\end_inset") {
<< "Missing \\begin_layout ?");
} else if (token == "\\end_inset") {
- LYXERR0("Solitary \\end_inset in line " << lex.lineNumber() << "\n"
+ LYXERR0("Solitary \\end_inset in line " << lex.getLineNo() << "\n"
<< "Missing \\begin_inset ?");
} else if (token == "\\begin_inset") {
Inset * inset = readInset(lex, buf);
<< "Missing \\begin_inset ?");
} else if (token == "\\begin_inset") {
Inset * inset = readInset(lex, buf);
|| token == "\\end_deeper") {
lex.pushToken(token);
lyxerr << "Paragraph ended in line "
|| token == "\\end_deeper") {
lex.pushToken(token);
lyxerr << "Paragraph ended in line "
- << lex.lineNumber() << "\n"
+ << lex.getLineNo() << "\n"
<< "Missing \\end_layout.\n";
break;
}
<< "Missing \\end_layout.\n";
break;
}
{
InsetMathHull * formula = new InsetMathHull;
istringstream is(to_utf8(sel));
{
InsetMathHull * formula = new InsetMathHull;
istringstream is(to_utf8(sel));
lex.setStream(is);
formula->read(lex);
if (formula->getType() == hullNone)
lex.setStream(is);
formula->read(lex);
if (formula->getType() == hullNone)
- LexerKeyword textClassTags[] = {
+ keyword_item textClassTags[] = {
{ "addtopreamble", TC_ADDTOPREAMBLE },
{ "classoptions", TC_CLASSOPTIONS },
{ "columns", TC_COLUMNS },
{ "addtopreamble", TC_ADDTOPREAMBLE },
{ "classoptions", TC_CLASSOPTIONS },
{ "columns", TC_COLUMNS },
"LabelType No_Label\n"
"End";
istringstream ss(s);
"LabelType No_Label\n"
"End";
istringstream ss(s);
- Lexer lex(textClassTags);
+ Lexer lex(textClassTags, sizeof(textClassTags) / sizeof(textClassTags[0]));
lex.setStream(ss);
Layout lay;
lay.setName(emptylayout_);
lex.setStream(ss);
Layout lay;
lay.setName(emptylayout_);
};
layoutlist_.push_back(lay);
}
};
layoutlist_.push_back(lay);
}
+ Lexer lexrc(textClassTags,
+ sizeof(textClassTags) / sizeof(textClassTags[0]));
- Lexer lexrc(textClassTags);
lexrc.setFile(filename);
ReturnValues retval = read(lexrc, rt);
lexrc.setFile(filename);
ReturnValues retval = read(lexrc, rt);
bool TextClass::read(std::string const & str, ReadType rt)
{
bool TextClass::read(std::string const & str, ReadType rt)
{
- Lexer lexrc(textClassTags);
+ Lexer lexrc(textClassTags,
+ sizeof(textClassTags) / sizeof(textClassTags[0]));
istringstream is(str);
lexrc.setStream(is);
ReturnValues retval = read(lexrc, rt);
istringstream is(str);
lexrc.setStream(is);
ReturnValues retval = read(lexrc, rt);
void TextClass::readTitleType(Lexer & lexrc)
{
void TextClass::readTitleType(Lexer & lexrc)
{
- LexerKeyword titleTypeTags[] = {
+ keyword_item titleTypeTags[] = {
{ "commandafter", TITLE_COMMAND_AFTER },
{ "environment", TITLE_ENVIRONMENT }
};
{ "commandafter", TITLE_COMMAND_AFTER },
{ "environment", TITLE_ENVIRONMENT }
};
void TextClass::readOutputType(Lexer & lexrc)
{
void TextClass::readOutputType(Lexer & lexrc)
{
- LexerKeyword outputTypeTags[] = {
+ keyword_item outputTypeTags[] = {
{ "docbook", DOCBOOK },
{ "latex", LATEX },
{ "literate", LITERATE }
{ "docbook", DOCBOOK },
{ "latex", LATEX },
{ "literate", LITERATE }
void TextClass::readClassOptions(Lexer & lexrc)
{
void TextClass::readClassOptions(Lexer & lexrc)
{
- LexerKeyword classOptionsTags[] = {
+ keyword_item classOptionsTags[] = {
{"end", CO_END },
{"fontsize", CO_FONTSIZE },
{"header", CO_HEADER },
{"end", CO_END },
{"fontsize", CO_FONTSIZE },
{"header", CO_HEADER },
{"pagestyle", CO_PAGESTYLE }
};
{"pagestyle", CO_PAGESTYLE }
};
- lexrc.pushTable(classOptionsTags);
+ lexrc.pushTable(classOptionsTags, CO_END);
bool getout = false;
while (!getout && lexrc.isOK()) {
int le = lexrc.lex();
bool getout = false;
while (!getout && lexrc.isOK()) {
int le = lexrc.lex();
void TextClass::readFloat(Lexer & lexrc)
{
void TextClass::readFloat(Lexer & lexrc)
{
- LexerKeyword floatTags[] = {
+ keyword_item floatTags[] = {
{ "end", FT_END },
{ "extension", FT_EXT },
{ "guiname", FT_NAME },
{ "end", FT_END },
{ "extension", FT_EXT },
{ "guiname", FT_NAME },
- lexrc.pushTable(floatTags);
+ lexrc.pushTable(floatTags, FT_END);
string type;
string placement;
string type;
string placement;
void TextClass::readCounter(Lexer & lexrc)
{
void TextClass::readCounter(Lexer & lexrc)
{
- LexerKeyword counterTags[] = {
+ keyword_item counterTags[] = {
{ "end", CT_END },
{ "labelstring", CT_LABELSTRING },
{ "labelstringappendix", CT_LABELSTRING_APPENDIX },
{ "end", CT_END },
{ "labelstring", CT_LABELSTRING },
{ "labelstringappendix", CT_LABELSTRING_APPENDIX },
{ "within", CT_WITHIN }
};
{ "within", CT_WITHIN }
};
- lexrc.pushTable(counterTags);
+ lexrc.pushTable(counterTags, CT_END);
docstring name;
docstring within;
docstring name;
docstring within;
ToolbarBackend toolbarbackend;
ToolbarBackend toolbarbackend;
-/////////////////////////////////////////////////////////////////////////
-//
-// ToolbarItem
-//
-/////////////////////////////////////////////////////////////////////////
-
ToolbarItem::ToolbarItem(Type type, FuncRequest const & func, docstring const & label)
: type_(type), func_(func), label_(label)
{
ToolbarItem::ToolbarItem(Type type, FuncRequest const & func, docstring const & label)
: type_(type), func_(func), label_(label)
{
ToolbarInfo & ToolbarInfo::read(Lexer & lex)
{
ToolbarInfo & ToolbarInfo::read(Lexer & lex)
{
TO_COMMAND = 1,
TO_ENDTOOLBAR,
TO_SEPARATOR,
TO_COMMAND = 1,
TO_ENDTOOLBAR,
TO_SEPARATOR,
TO_TABLEINSERT,
TO_POPUPMENU,
TO_ICONPALETTE,
TO_TABLEINSERT,
TO_POPUPMENU,
TO_ICONPALETTE,
- struct LexerKeyword toolTags[] = {
+ struct keyword_item toolTags[TO_LAST - 1] = {
{ "end", TO_ENDTOOLBAR },
{ "iconpalette", TO_ICONPALETTE },
{ "item", TO_COMMAND },
{ "end", TO_ENDTOOLBAR },
{ "iconpalette", TO_ICONPALETTE },
{ "item", TO_COMMAND },
- lex.pushTable(toolTags);
+ lex.pushTable(toolTags, TO_LAST - 1);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
-/////////////////////////////////////////////////////////////////////////
-//
-// ToolbarBackend
-//
-/////////////////////////////////////////////////////////////////////////
-
ToolbarBackend::ToolbarBackend()
{
ToolbarBackend::ToolbarBackend()
{
void ToolbarBackend::readToolbars(Lexer & lex)
{
void ToolbarBackend::readToolbars(Lexer & lex)
{
TO_TOOLBAR = 1,
TO_ENDTOOLBARSET,
TO_TOOLBAR = 1,
TO_ENDTOOLBARSET,
- struct LexerKeyword toolTags[] = {
+ struct keyword_item toolTags[TO_LAST - 1] = {
{ "end", TO_ENDTOOLBARSET },
{ "toolbar", TO_TOOLBAR }
};
{ "end", TO_ENDTOOLBARSET },
{ "toolbar", TO_TOOLBAR }
};
<< lex.getString() << '\'');
}
<< lex.getString() << '\'');
}
- lex.pushTable(toolTags);
+ lex.pushTable(toolTags, TO_LAST - 1);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
KCOMB = 1,
KMOD,
KMAP,
KXMOD,
KCOMB = 1,
KMOD,
KMAP,
KXMOD,
+ K_LAST
+};
+
+
+struct keyword_item kmapTags[K_LAST - 1] = {
+ {"\\kcomb", KCOMB },
+ { "\\kmap", KMAP },
+ { "\\kmod", KMOD },
+ { "\\kxmod", KXMOD }
int Trans::load(string const & language)
{
int Trans::load(string const & language)
{
- struct LexerKeyword kmapTags[] = {
- {"\\kcomb", KCOMB },
- { "\\kmap", KMAP },
- { "\\kmod", KMOD },
- { "\\kxmod", KXMOD }
- };
-
FileName const filename = libFileSearch("kbd", language, "kmap");
if (filename.empty())
return -1;
freeKeymap();
FileName const filename = libFileSearch("kbd", language, "kmap");
if (filename.empty())
return -1;
freeKeymap();
+ Lexer lex(kmapTags, K_LAST - 1);
lex.setFile(filename);
int const res = load(lex);
lex.setFile(filename);
int const res = load(lex);
bool GuiLog::initialiseParams(string const & data)
{
istringstream is(data);
bool GuiLog::initialiseParams(string const & data)
{
istringstream is(data);
lex.setStream(is);
string logtype, logfile;
lex.setStream(is);
string logtype, logfile;
md_floatlistinsert,
md_floatinsert,
md_pasterecent,
md_floatlistinsert,
md_floatinsert,
md_pasterecent,
- struct LexerKeyword menutags[] = {
+ struct keyword_item menutags[md_last - 1] = {
{ "bookmarks", md_bookmarks },
{ "branches", md_branches },
{ "charstyles", md_charstyles },
{ "bookmarks", md_bookmarks },
{ "branches", md_branches },
{ "charstyles", md_charstyles },
{ "viewformats", md_viewformats }
};
{ "viewformats", md_viewformats }
};
- lex.pushTable(menutags);
+ lex.pushTable(menutags, md_last - 1);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
-void Menus::Impl::expand(MenuDefinition const & frommenu,
- MenuDefinition & tomenu, Buffer const * buf) const
+void Menus::Impl::expand(MenuDefinition const & frommenu, MenuDefinition & tomenu,
+ Buffer const * buf) const
{
if (!tomenu.empty())
tomenu.clear();
{
if (!tomenu.empty())
tomenu.clear();
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
-Menus::Menus() : d(new Impl) {}
+Menus::Menus(): d(new Impl) {}
void Menus::read(Lexer & lex)
{
enum Menutags {
void Menus::read(Lexer & lex)
{
enum Menutags {
md_menubar,
md_endmenuset,
md_menubar,
md_endmenuset,
- struct LexerKeyword menutags[] = {
+ struct keyword_item menutags[md_last - 1] = {
{ "end", md_endmenuset },
{ "menu", md_menu },
{ "menubar", md_menubar }
{ "end", md_endmenuset },
{ "menu", md_menu },
{ "menubar", md_menubar }
<< lex.getString() << '\'' << endl;
}
<< lex.getString() << '\'' << endl;
}
- lex.pushTable(menutags);
+ lex.pushTable(menutags, md_last - 1);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
TM_PREAMBLEDEF = 1,
TM_PREAMBLEDEF_END,
TM_TEMPLATE,
TM_TEMPLATE_END
};
TM_PREAMBLEDEF = 1,
TM_PREAMBLEDEF_END,
TM_TEMPLATE,
TM_TEMPLATE_END
};
- LexerKeyword templatetags[] = {
+ keyword_item templatetags[] = {
{ "preambledef", TM_PREAMBLEDEF },
{ "preambledefend", TM_PREAMBLEDEF_END },
{ "template", TM_TEMPLATE },
{ "templateend", TM_TEMPLATE_END }
};
{ "preambledef", TM_PREAMBLEDEF },
{ "preambledefend", TM_PREAMBLEDEF_END },
{ "template", TM_TEMPLATE },
{ "templateend", TM_TEMPLATE_END }
};
- Lexer lex(templatetags);
+ Lexer lex(templatetags, TM_TEMPLATE_END);
FileName const filename = libFileSearch("", "external_templates");
if (filename.empty() || !lex.setFile(filename)) {
FileName const filename = libFileSearch("", "external_templates");
if (filename.empty() || !lex.setFile(filename)) {
void Template::readTemplate(Lexer & lex)
{
void Template::readTemplate(Lexer & lex)
{
+ enum TemplateOptionTags {
TO_GUINAME = 1,
TO_HELPTEXT,
TO_INPUTFORMAT,
TO_GUINAME = 1,
TO_HELPTEXT,
TO_INPUTFORMAT,
- LexerKeyword templateoptiontags[] = {
+ keyword_item templateoptiontags[] = {
{ "automaticproduction", TO_AUTOMATIC },
{ "filefilter", TO_FILTER },
{ "format", TO_FORMAT },
{ "automaticproduction", TO_AUTOMATIC },
{ "filefilter", TO_FILTER },
{ "format", TO_FORMAT },
- LexerKeyword formattags[] = {
+ keyword_item formattags[] = {
{ "formatend", FO_END },
{ "option", FO_OPTION },
{ "preamble", FO_PREAMBLE },
{ "formatend", FO_END },
{ "option", FO_OPTION },
{ "preamble", FO_PREAMBLE },
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
return false;
istringstream data(in);
return false;
istringstream data(in);
lex.setStream(data);
string n;
lex.setStream(data);
string n;
return status;
istringstream data(in);
return status;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
- LexerKeyword external_tags[] = {
+ keyword_item external_tags[] = {
{ "\\end_inset", EX_END },
{ "boundingBox", EX_BOUNDINGBOX },
{ "clip", EX_CLIP },
{ "\\end_inset", EX_END },
{ "boundingBox", EX_BOUNDINGBOX },
{ "clip", EX_CLIP },
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
IL_BGCOLOR,
IL_DECORATION,
IL_FREESPACING,
IL_BGCOLOR,
IL_DECORATION,
IL_FREESPACING,
{
name_ = support::subst(lexrc.getDocString(), '_', ' ');
{
name_ = support::subst(lexrc.getDocString(), '_', ' ');
- LexerKeyword elementTags[] = {
+ keyword_item elementTags[] = {
{ "bgcolor", IL_BGCOLOR },
{ "decoration", IL_DECORATION },
{ "end", IL_END },
{ "bgcolor", IL_BGCOLOR },
{ "decoration", IL_DECORATION },
{ "end", IL_END },
{ "requires", IL_REQUIRES }
};
{ "requires", IL_REQUIRES }
};
- lexrc.pushTable(elementTags);
+ lexrc.pushTable(elementTags, IL_END);
FontInfo font = inherit_font;
labelfont_ = inherit_font;
FontInfo font = inherit_font;
labelfont_ = inherit_font;
if (in.empty())
return;
istringstream data(in);
if (in.empty())
return;
istringstream data(in);
lex.setStream(data);
// discard "listings", which is only used to determine inset
lex.next();
lex.setStream(data);
// discard "listings", which is only used to determine inset
lex.next();
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
void InsetTabular::string2params(string const & in, InsetTabular & inset)
{
istringstream data(in);
void InsetTabular::string2params(string const & in, InsetTabular & inset)
{
istringstream data(in);
lex.setStream(data);
if (in.empty())
lex.setStream(data);
if (in.empty())
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
return;
istringstream data(in);
return;
istringstream data(in);
lex.setStream(data);
string name;
lex.setStream(data);
string name;
Parser::Parser(Lexer & lexer)
Parser::Parser(Lexer & lexer)
- : lineno_(lexer.lineNumber()), pos_(0)
+ : lineno_(lexer.getLineNo()), pos_(0)
{
tokenize(lexer.getStream());
lexer.eatLine();
{
tokenize(lexer.getStream());
lexer.eatLine();