X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLexer.h;h=02ec7470e18d8214a196588bf4fbede18114014f;hb=c9b1b46796923b0453ccaed022448b61b5be6d8a;hp=072bc6e20a5a6f9e39d83ff0a412d761a41d601e;hpb=e7645f24391648fb08cf6b6d808fcabec76be744;p=lyx.git diff --git a/src/Lexer.h b/src/Lexer.h index 072bc6e20a..02ec7470e1 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -5,7 +5,7 @@ * Licence details can be found in the file COPYING. * * \author Alejandro Aguilar Sierra - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * * Full author contact details are available in file CREDITS. */ @@ -18,16 +18,14 @@ #define LEXER_H #include "support/strfwd.h" - +#include namespace lyx { 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 + Usually used bundled in C style arrays and passed to the Lexer using a LexerKeywordTable object. */ struct LexerKeyword @@ -64,10 +62,10 @@ class Lexer { public: /// initialize Lexer with no special keywords. - Lexer(); + Lexer(); /// initialize Lexer with a bunch of keywords template Lexer(LexerKeyword (&table)[N]) - : pimpl_(0) { init(table, N); } + : pimpl_(0), lastReadOk_(false) { init(table, N); } /// ~Lexer(); @@ -110,16 +108,20 @@ public: /// returns a lex code int lex(); - /** Just read the next word. If esc is true remember that - some chars might be escaped: "\ atleast - */ + /// Read the next string, as delimited by double quotes or + /// whitespace. If esc is true, then we remember that some chars + /// might be escaped: \" at least. bool next(bool esc = false); - /** Read next token. This one is almost the same as next, - but it will consider " as a regular character and always - split a word if it contains a backslash. - */ + /// Read next token. This one is almost the same as next(), + /// but it will consider " as a regular character and always + /// split a word if it contains a backslash. bool nextToken(); + + /// Puts the rest of the line in the buffer, where it will + /// be available via getString() or getDocString(). + bool eatLine(); + /// Push a token, that next token got from lyxlex. void pushToken(std::string const &); @@ -133,22 +135,15 @@ public: /// double getFloat() const; /// - std::string const getString() const; - + std::string const getString(bool trim = false) const; /// - docstring const getDocString() const; - - /** Get a long string, ended by the tag `endtag'. - This string can span several lines. The first line - serves as a template for how many spaces the lines - are indented. This much white space is skipped from - each following line. This mechanism does not work - perfectly if you use tabs. + docstring const getDocString(bool trim = false) const; + /** Get a long string, ended by the tag `endtoken'. This string + can span several lines. The first line serves as a template + for what sequence of tabs and spaces make up the indentation. + This prefix is skipped from each following line. */ - std::string const getLongString(std::string const & endtag); - - /// - bool eatLine(); + docstring getLongString(docstring const & endtoken); /// Pushes a token list on a stack and replaces it with a new one. template void pushTable(LexerKeyword (&table)[N]) @@ -193,6 +188,9 @@ public: /// Quotes a string so that reading it again with Lexer::next(true) /// gets the original string static std::string quoteString(std::string const &); + /// Quotes a docstring so that reading it again with Lexer::next(true) + /// gets the original string + static docstring quoteString(docstring const &); private: /// noncopyable