#endif
+//
+// Wrapper
+//
+
+void iparserdocstream::putback(char_type c)
+{
+ s_ += c;
+}
+
+
+void iparserdocstream::put_almost_back(docstring s)
+{
+ s_ = s + s_;
+}
+
+
+iparserdocstream & iparserdocstream::get(char_type &c)
+{
+ if (s_.empty())
+ is_.get(c);
+ else {
+ c = s_[0];
+ s_.erase(0,1);
+ }
+ return *this;
+}
+
+
//
// Parser
//
void Parser::deparse()
{
+ string s;
for(size_type i = pos_ ; i < tokens_.size() ; ++i) {
- docstring const s = from_utf8(tokens_[i].asInput());
- //cerr << "deparsing [" << to_utf8(s) << "]" <<endl;
- foreach(char_type c, s)
- is_.putback(c);
+ s += tokens_[i].asInput();
}
+ is_.put_almost_back(from_utf8(s));
tokens_.erase(tokens_.begin() + pos_, tokens_.end());
// make sure that next token is read
tokenize_one();
idocstream & docstream() { return is_; };
- void putback(char_type c) { s_ += c; };
-
- iparserdocstream & get(char_type &c)
- {
- if (s_.empty())
- is_.get(c);
- else {
- c = s_[0];
- s_.erase(0,1);
- }
- return *this;
- };
+ // add to the list of characters to read before actually reading
+ // the stream
+ void putback(char_type c);
+
+ // add before the list of characters to read before actually reading
+ // the stream
+ void put_almost_back(docstring s);
+
+ iparserdocstream & get(char_type &c);
private:
///
idocstream & is_;
- ///
+ /// characters to read before actually reading the stream
docstring s_;
};