Compute parse state group signature based on the item set
This commit is contained in:
parent
42d37656ea
commit
6cfd009503
5 changed files with 29 additions and 76 deletions
|
|
@ -5,7 +5,6 @@
|
|||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "compiler/util/hash_combine.h"
|
||||
#include "compiler/lex_table.h"
|
||||
#include "compiler/rules/symbol.h"
|
||||
#include "compiler/rules/metadata.h"
|
||||
|
|
@ -76,7 +75,6 @@ class ParseState {
|
|||
bool merge(const ParseState &);
|
||||
void each_referenced_state(std::function<void(ParseStateId *)>);
|
||||
bool has_shift_action() const;
|
||||
void compute_shift_actions_signature();
|
||||
|
||||
std::map<rules::Symbol::Index, ParseTableEntry> terminal_entries;
|
||||
std::map<rules::Symbol::Index, ParseStateId> nonterminal_entries;
|
||||
|
|
@ -106,38 +104,4 @@ class ParseTable {
|
|||
|
||||
} // namespace tree_sitter
|
||||
|
||||
namespace std {
|
||||
|
||||
using tree_sitter::util::hash_combine;
|
||||
|
||||
template <>
|
||||
struct hash<tree_sitter::ParseAction> {
|
||||
size_t operator()(const tree_sitter::ParseAction &action) const {
|
||||
size_t result = 0;
|
||||
hash_combine<int>(&result, action.type);
|
||||
hash_combine(&result, action.extra);
|
||||
hash_combine(&result, action.fragile);
|
||||
hash_combine(&result, action.symbol);
|
||||
hash_combine(&result, action.state_index);
|
||||
hash_combine(&result, action.consumed_symbol_count);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<tree_sitter::ParseTableEntry> {
|
||||
size_t operator()(const tree_sitter::ParseTableEntry &entry) const {
|
||||
size_t result = 0;
|
||||
hash_combine(&result, entry.actions.size());
|
||||
for (const tree_sitter::ParseAction &action : entry.actions) {
|
||||
hash_combine(&result, action);
|
||||
}
|
||||
hash_combine(&result, entry.reusable);
|
||||
hash_combine(&result, entry.depends_on_lookahead);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COMPILER_PARSE_TABLE_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue