The branch, master, has been updated. - Log -----------------------------------------------------------------
commit 683050d4f9a2e9476ccf2313f8f72eb99fcf4a87 Author: Jean-Marc Lasgouttes <[email protected]> Date: Fri Feb 22 15:32:13 2013 +0100 Some fixes to parsing in tex2lyx * put_almost_back and putback are actually the same thing * add Parser::dropPosition * deparse on Parser::popPosition diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp index 11ecfe1..d87ff29 100644 --- a/src/tex2lyx/Parser.cpp +++ b/src/tex2lyx/Parser.cpp @@ -131,11 +131,11 @@ bool iparserdocstream::setEncoding(std::string const & e) void iparserdocstream::putback(char_type c) { - s_ += c; + s_ = c + s_; } -void iparserdocstream::put_almost_back(docstring s) +void iparserdocstream::putback(docstring s) { s_ = s + s_; } @@ -146,6 +146,7 @@ iparserdocstream & iparserdocstream::get(char_type &c) if (s_.empty()) is_.get(c); else { + //cerr << "unparsed: " << to_utf8(s_) <<endl; c = s_[0]; s_.erase(0,1); } @@ -186,7 +187,7 @@ void Parser::deparse() for(size_type i = pos_ ; i < tokens_.size() ; ++i) { s += tokens_[i].asInput(); } - is_.put_almost_back(from_utf8(s)); + is_.putback(from_utf8(s)); tokens_.erase(tokens_.begin() + pos_, tokens_.end()); // make sure that next token is read tokenize_one(); @@ -425,6 +426,13 @@ void Parser::popPosition() { pos_ = positions_.back(); positions_.pop_back(); + deparse(); +} + + +void Parser::dropPosition() +{ + positions_.pop_back(); } diff --git a/src/tex2lyx/Parser.h b/src/tex2lyx/Parser.h index 3d2bf56..42243c6 100644 --- a/src/tex2lyx/Parser.h +++ b/src/tex2lyx/Parser.h @@ -135,9 +135,9 @@ public: // the stream void putback(char_type c); - // add before the list of characters to read before actually reading + // add to the list of characters to read before actually reading // the stream - void put_almost_back(docstring s); + void putback(docstring s); /// Like std::istream::get() iparserdocstream & get(char_type &c); @@ -206,6 +206,8 @@ public: void pushPosition(); /// restore previous position void popPosition(); + /// forget last saved position + void dropPosition(); /// dump contents to screen void dump() const; ----------------------------------------------------------------------- Summary of changes: src/tex2lyx/Parser.cpp | 14 +++++++++++--- src/tex2lyx/Parser.h | 6 ++++-- 2 files changed, 15 insertions(+), 5 deletions(-) hooks/post-receive -- The LyX Source Repository
