#ifndef COMPILER_SYNTAX_GRAMMAR_H_ #define COMPILER_SYNTAX_GRAMMAR_H_ #include #include #include #include #include "tree_sitter/compiler.h" #include "compiler/rules/symbol.h" namespace tree_sitter { struct ProductionEntry { rules::Symbol symbol; int precedence; int rule_id; bool operator==(const ProductionEntry &) const; }; struct Production { Production(); Production(const std::vector &); size_t symbol_count() const; const ProductionEntry &operator[](int) const; std::vector entries; }; std::ostream &operator<<(std::ostream &, const ProductionEntry &); std::ostream &operator<<(std::ostream &, const Production &); class SyntaxGrammar { public: SyntaxGrammar(); SyntaxGrammar( const std::vector>> &rules, const std::vector>> &aux_rules, const std::set &ubiquitous_tokens); const std::string &rule_name(const rules::Symbol &symbol) const; const std::vector &productions(const rules::Symbol &) const; std::vector>> rules; std::vector>> aux_rules; std::set ubiquitous_tokens; }; } // namespace tree_sitter #endif // COMPILER_SYNTAX_GRAMMAR_H_