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

48 lines
1.2 KiB
C
Raw Normal View History

#ifndef COMPILER_RULES_SYMBOL_H_
#define COMPILER_RULES_SYMBOL_H_
2014-04-28 21:46:43 -07:00
#include <string>
2014-04-28 20:15:49 -07:00
#include "compiler/rules/rule.h"
namespace tree_sitter {
namespace rules {
typedef enum {
SymbolOptionToken = 1 << 0,
SymbolOptionAuxiliary = 1 << 1,
} SymbolOption;
2014-04-25 22:17:23 -07:00
class Symbol : public Rule {
public:
explicit Symbol(int index);
Symbol(int index, SymbolOption options);
2014-04-25 22:17:23 -07:00
bool operator==(const Symbol &other) const;
bool operator==(const Rule &other) const;
2014-04-25 22:17:23 -07:00
size_t hash_code() const;
rule_ptr copy() const;
std::string to_string() const;
void accept(Visitor *visitor) const;
2014-04-25 22:17:23 -07:00
bool operator<(const Symbol &other) const;
bool is_token() const;
bool is_built_in() const;
bool is_auxiliary() const;
2014-04-25 22:17:23 -07:00
int index;
SymbolOption options;
};
}
}
namespace std {
template<>
struct hash<tree_sitter::rules::Symbol> {
size_t operator()(const tree_sitter::rules::Symbol &rule) const {
return rule.hash_code();
}
};
}
#endif // COMPILER_RULES_SYMBOL_H_