2013-12-18 20:58:05 -08:00
|
|
|
#include "rules.h"
|
2013-11-07 13:24:01 -08:00
|
|
|
#include "transition_map.h"
|
|
|
|
|
|
2013-12-19 23:05:54 -08:00
|
|
|
using std::string;
|
|
|
|
|
|
2013-11-07 13:24:01 -08:00
|
|
|
namespace tree_sitter {
|
|
|
|
|
namespace rules {
|
|
|
|
|
Choice::Choice(rule_ptr left, rule_ptr right) : left(left), right(right) {};
|
|
|
|
|
|
|
|
|
|
bool Choice::operator==(const Rule &rule) const {
|
|
|
|
|
const Choice *other = dynamic_cast<const Choice *>(&rule);
|
2013-11-14 21:25:58 -08:00
|
|
|
return other && (*other->left == *left) && (*other->right == *right);
|
2013-11-07 13:24:01 -08:00
|
|
|
}
|
|
|
|
|
|
2013-12-19 23:05:54 -08:00
|
|
|
string Choice::to_string() const {
|
|
|
|
|
return string("(choice ") + left->to_string() + " " + right->to_string() + ")";
|
2013-11-07 13:24:01 -08:00
|
|
|
}
|
2013-12-18 20:58:05 -08:00
|
|
|
|
2013-12-19 23:16:13 -08:00
|
|
|
void Choice::accept(Visitor &visitor) const {
|
2013-12-18 20:58:05 -08:00
|
|
|
visitor.visit(this);
|
|
|
|
|
}
|
2013-11-07 13:24:01 -08:00
|
|
|
}
|
|
|
|
|
}
|