-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathGrammar.cpp
More file actions
23 lines (18 loc) · 764 Bytes
/
Copy pathGrammar.cpp
File metadata and controls
23 lines (18 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "Grammar.h"
bool Grammar::allowsLeft(OperandType left) const {
return allowed_leftward_operands.find(left) != allowed_leftward_operands.end();
}
bool Grammar::allowsRight(OperandType right) const {
return allowed_rightward_operands.find(right) != allowed_rightward_operands.end();
}
void Grammar::addAllowedLeftwardOperands(const std::vector<OperandType>& operand_types) {
for (const auto& operand_type : operand_types) {
allowed_leftward_operands.insert(operand_type);
}
}
void Grammar::addAllowedRightwardOperands(const std::vector<OperandType>& operand_types) {
for (const auto& operand_type : operand_types) {
allowed_rightward_operands.insert(operand_type);
}
}
void Grammar::setReversed(bool reverse) { this->is_reversed = reverse; }