Skip to content
Snippets Groups Projects
Commit d0a52fb3 authored by ilor's avatar ilor
Browse files

MatchVector first_token and last_token

parent 80dcc6b3
Branches
No related merge requests found
......@@ -29,16 +29,34 @@ std::string MatchVector::var_repr(const std::string &var_name)
Position MatchVector::first_token() const
{
Position p;
// TODO
return p;
if (matches_.empty()) {
return Position(Position::Nowhere);
} else {
Position p = matches_.front()->first_token();
for (size_t i = 1; i < matches_.end(); ++i) {
Position c = matches_[i]->first_token();
if (c.get_value() < p.get_value()) {
p = c;
}
}
return p;
}
}
Position MatchVector::last_token() const
{
Position p;
// TODO
return p;
if (matches_.empty()) {
return Position(Position::Nowhere);
} else {
Position p = matches_.front()->last_token();
for (size_t i = 1; i < matches_.end(); ++i) {
Position c = matches_[i]->last_token();
if (c.get_value() > p.get_value()) {
p = c;
}
}
return p;
}
}
bool MatchVector::empty() const
......
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