Move public rule functions out of rule namespace

This way, there's only one public namespace: tree_sitter
This commit is contained in:
Max Brunsfeld 2015-09-03 17:49:20 -07:00
parent e386c634aa
commit bd77ab1ac9
66 changed files with 127 additions and 167 deletions

43
src/compiler/rule.h Normal file
View file

@ -0,0 +1,43 @@
#ifndef COMPILER_RULES_RULE_H_
#define COMPILER_RULES_RULE_H_
#include <string>
#include <memory>
namespace tree_sitter {
namespace rules {
class Visitor;
} // namespace rules
class Rule;
typedef std::shared_ptr<Rule> rule_ptr;
class Rule {
public:
virtual bool operator==(const Rule &other) const = 0;
bool operator!=(const Rule &other) const;
virtual size_t hash_code() const = 0;
virtual rule_ptr copy() const = 0;
virtual std::string to_string() const = 0;
virtual void accept(rules::Visitor *visitor) const = 0;
virtual ~Rule();
};
std::ostream &operator<<(std::ostream &stream, const Rule &rule);
std::ostream &operator<<(std::ostream &stream, const rule_ptr &rule);
} // namespace tree_sitter
namespace std {
template <>
struct hash<tree_sitter::rule_ptr> {
size_t operator()(const tree_sitter::rule_ptr &rule) const {
return typeid(*rule).hash_code() ^ rule->hash_code();
}
};
} // namespace std
#endif // COMPILER_RULES_RULE_H_