Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep hold of offset in LocatedParseError #334

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/parser/parse_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ ParseError::~ParseError() {}

LocatedParseError::~LocatedParseError() {}

void LocatedParseError::locate(size_t offset) {
if (finalized) {
void LocatedParseError::locate(size_t offset_) {
if (hasOffset) {
return;
}
std::ostringstream str;
str << reason << " at index " << offset << ".";
str << reason << " at index " << offset_ << ".";
reason = str.str();
finalized = true;
offset = offset_;
hasOffset = true;
}

}
4 changes: 2 additions & 2 deletions src/parser/parse_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class LocatedParseError : public ParseError {
~LocatedParseError() override;

void locate(size_t offset);
private:
bool finalized = false; //!< true when locate() has been called.
bool hasOffset = false; //!< true when locate() has been called.
size_t offset;
};

} // namespace ue2
Expand Down