tree-sitter/src/compiler/rules/rule.h

36 lines
924 B
C
Raw Normal View History

2013-11-07 13:24:01 -08:00
#ifndef __TreeSitter__rule__
#define __TreeSitter__rule__
#include <string>
namespace tree_sitter {
namespace rules {
2013-12-19 23:16:13 -08:00
class Visitor;
2014-01-02 13:04:41 -08:00
class Rule;
typedef std::shared_ptr<const Rule> rule_ptr;
2013-11-07 13:24:01 -08:00
class Rule {
public:
virtual bool operator==(const Rule& other) const = 0;
2013-12-30 23:52:38 -08:00
virtual size_t hash_code() const = 0;
2014-01-02 13:04:41 -08:00
virtual rule_ptr copy() const = 0;
2013-11-07 13:24:01 -08:00
virtual std::string to_string() const = 0;
2013-12-19 23:16:13 -08:00
virtual void accept(Visitor &visitor) const = 0;
2013-11-07 13:24:01 -08:00
};
2013-11-12 08:17:19 -08:00
std::ostream& operator<<(std::ostream& stream, const Rule &rule);
std::ostream& operator<<(std::ostream& stream, const rule_ptr &rule);
2013-11-07 13:24:01 -08:00
}
}
2013-12-15 14:41:51 -08:00
namespace std {
template<>
struct hash<tree_sitter::rules::Rule> {
size_t operator()(const tree_sitter::rules::Rule &rule) {
2013-12-30 23:52:38 -08:00
return rule.hash_code();
2013-12-15 14:41:51 -08:00
}
};
}
2013-11-07 13:24:01 -08:00
#endif