2014-04-28 20:43:27 -07:00
|
|
|
#ifndef COMPILER_RULES_SYMBOL_H_
|
|
|
|
|
#define COMPILER_RULES_SYMBOL_H_
|
2014-04-22 23:38:26 -07:00
|
|
|
|
2014-04-28 21:46:43 -07:00
|
|
|
#include <string>
|
2014-04-28 20:15:49 -07:00
|
|
|
#include "compiler/rules/rule.h"
|
2014-04-22 23:38:26 -07:00
|
|
|
|
|
|
|
|
namespace tree_sitter {
|
|
|
|
|
namespace rules {
|
|
|
|
|
typedef enum {
|
|
|
|
|
SymbolOptionToken = 1 << 0,
|
|
|
|
|
SymbolOptionAuxiliary = 1 << 1,
|
|
|
|
|
} SymbolOption;
|
2014-04-25 22:17:23 -07:00
|
|
|
|
2014-04-28 20:43:27 -07:00
|
|
|
class Symbol : public Rule {
|
2014-04-22 23:38:26 -07:00
|
|
|
public:
|
2014-04-28 20:43:27 -07:00
|
|
|
explicit Symbol(int index);
|
|
|
|
|
Symbol(int index, SymbolOption options);
|
2014-04-25 22:17:23 -07:00
|
|
|
|
2014-04-28 20:43:27 -07:00
|
|
|
bool operator==(const Symbol &other) const;
|
2014-04-23 13:12:33 -07:00
|
|
|
bool operator==(const Rule &other) const;
|
2014-04-25 22:17:23 -07:00
|
|
|
|
2014-04-22 23:38:26 -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
|
|
|
|
2014-04-28 20:43:27 -07:00
|
|
|
bool operator<(const Symbol &other) const;
|
2014-04-22 23:38:26 -07:00
|
|
|
bool is_token() const;
|
|
|
|
|
bool is_built_in() const;
|
|
|
|
|
bool is_auxiliary() const;
|
2014-04-25 22:17:23 -07:00
|
|
|
|
2014-04-22 23:38:26 -07:00
|
|
|
int index;
|
|
|
|
|
SymbolOption options;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
|
template<>
|
2014-04-28 20:43:27 -07:00
|
|
|
struct hash<tree_sitter::rules::Symbol> {
|
|
|
|
|
size_t operator()(const tree_sitter::rules::Symbol &rule) const {
|
2014-04-22 23:38:26 -07:00
|
|
|
return rule.hash_code();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-28 20:43:27 -07:00
|
|
|
#endif // COMPILER_RULES_SYMBOL_H_
|