tree-sitter/src/compiler/build_tables/parse_conflict_manager.h
Max Brunsfeld 1d314d71c2 Separate functions for building parse and lex tables
Now, instead of adding states to the lex table as they are needed
by the parse states, we iterate over the parse states after the fact
and set up their corresponding lex states. This has the nice side
effect that the lex states are in a more readable order.
2014-05-04 22:07:52 -07:00

33 lines
1.1 KiB
C++

#ifndef COMPILER_BUILD_TABLES_PARSE_CONFLICT_MANAGER_H_
#define COMPILER_BUILD_TABLES_PARSE_CONFLICT_MANAGER_H_
#include <vector>
#include <map>
#include <string>
#include <set>
#include "tree_sitter/compiler.h"
#include "compiler/parse_table.h"
#include "compiler/rules/symbol.h"
#include "compiler/prepared_grammar.h"
namespace tree_sitter {
namespace build_tables {
class ParseConflictManager {
const PreparedGrammar parse_grammar;
const PreparedGrammar lex_grammar;
std::set<Conflict> conflicts_;
public:
ParseConflictManager(const PreparedGrammar &parse_grammar,
const PreparedGrammar &lex_grammar);
bool resolve_parse_action(const rules::Symbol &symbol,
const ParseAction &old_action,
const ParseAction &new_action);
void record_conflict(const rules::Symbol &symbol, const ParseAction &left, const ParseAction &right);
const std::vector<Conflict> conflicts() const;
};
}
}
#endif // COMPILER_BUILD_TABLES_PARSE_CONFLICT_MANAGER_H_