In LR(1) items, only store consumed symbols as booleans
the booleans represent the symbols point to auxiliary tokens or not. This is all we need to know for the purpose of building parse tables. Any other information just leads to redundant parse states.
This commit is contained in:
parent
0d3a941848
commit
5ed5ae7514
11 changed files with 660 additions and 993 deletions
|
|
@ -11,9 +11,13 @@ namespace tree_sitter {
|
|||
|
||||
bool Symbol::operator==(const Rule &rule) const {
|
||||
const Symbol *other = dynamic_cast<const Symbol *>(&rule);
|
||||
return other && (other->name == name) && (other->is_auxiliary == is_auxiliary);
|
||||
return other && this->operator==(*other);
|
||||
}
|
||||
|
||||
|
||||
bool Symbol::operator==(const Symbol &other) const {
|
||||
return (other.name == name) && (other.is_auxiliary == is_auxiliary);
|
||||
}
|
||||
|
||||
size_t Symbol::hash_code() const {
|
||||
return typeid(this).hash_code() ^ hash<string>()(name) ^ hash<bool>()(is_auxiliary);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue