mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-28 06:49:43 +00:00
Some fixes to parsing in tex2lyx
* put_almost_back and putback are actually the same thing * add Parser::dropPosition * deparse on Parser::popPosition
This commit is contained in:
parent
0082d183b3
commit
683050d4f9
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user