Commit de08d209 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2428] Implement popping of sources

At least in the normal case. Error cases must still be handled.
parent 1b7273a3
...@@ -58,6 +58,7 @@ public: ...@@ -58,6 +58,7 @@ public:
initialized_(false), initialized_(false),
ok_(true), ok_(true),
many_errors_((options & MANY_ERRORS) != 0), many_errors_((options & MANY_ERRORS) != 0),
source_count_(0),
complete_(false), complete_(false),
seen_error_(false) seen_error_(false)
{} {}
...@@ -90,11 +91,18 @@ public: ...@@ -90,11 +91,18 @@ public:
} }
} }
initialized_ = true; initialized_ = true;
++source_count_;
}
bool popSource() {
lexer_.popSource();
return (--source_count_ != 0);
} }
void pushStreamSource(std::istream& stream) { void pushStreamSource(std::istream& stream) {
lexer_.pushSource(stream); lexer_.pushSource(stream);
initialized_ = true; initialized_ = true;
++source_count_;
} }
// Get a string token. Handle it as error if it is not string. // Get a string token. Handle it as error if it is not string.
...@@ -159,6 +167,7 @@ private: ...@@ -159,6 +167,7 @@ private:
bool ok_; // Is it OK to continue loading? bool ok_; // Is it OK to continue loading?
const bool many_errors_; // Are many errors allowed (or should we abort const bool many_errors_; // Are many errors allowed (or should we abort
// on the first) // on the first)
size_t source_count_; // How many sources are currently pushed.
public: public:
bool complete_; // All work done. bool complete_; // All work done.
bool seen_error_; // Was there at least one error during the bool seen_error_; // Was there at least one error during the
...@@ -185,8 +194,13 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) { ...@@ -185,8 +194,13 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
do { do {
const MasterToken& empty_token(lexer_.getNextToken()); const MasterToken& empty_token(lexer_.getNextToken());
if (empty_token.getType() == MasterToken::END_OF_FILE) { if (empty_token.getType() == MasterToken::END_OF_FILE) {
// TODO: Check if this is the last source, possibly pop if (!popSource()) {
return (true); return (true);
} else {
// We try to read a token from the popped source
// So retry the loop
continue;
}
} }
empty = empty_token.getType() == MasterToken::END_OF_LINE; empty = empty_token.getType() == MasterToken::END_OF_LINE;
} while (empty); } while (empty);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment