-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSituation.cpp
More file actions
32 lines (26 loc) · 967 Bytes
/
Situation.cpp
File metadata and controls
32 lines (26 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "Situation.h"
#include <tuple>
bool Situation::CheckNextSymbolIsTerminal() const {
if (CheckRuleCompleted()) {
return false;
}
return rule_.right_part_[point_position_].is_terminal_;
}
char Situation::GetNextSymbol() const {
return rule_.right_part_[point_position_].symbol_;
}
bool Situation::CheckRuleCompleted() const {
return point_position_ == rule_.right_part_.size();
}
Situation Situation::MovePointRight() const {
return Situation(rule_, previous_level_position_, point_position_ + 1);
}
bool Situation::operator==(const Situation& other) const {
return (rule_ == other.rule_ &&
previous_level_position_ == other.previous_level_position_ &&
point_position_ == other.point_position_);
}
bool Situation::operator<(const Situation& other) const {
return std::make_tuple(rule_, previous_level_position_, point_position_)
< std::make_tuple(other.rule_, other.previous_level_position_, other.point_position_);
}