This reverts commit 5cd07648fd.
The separators construct is useful as an optimization. It turns out that
constructing a node for every chunk of whitespace in a document causes a
significant performance regression.
Conflicts:
src/compiler/build_tables/build_lex_table.cc
src/compiler/grammar.cc
src/runtime/parser.c
36 lines
738 B
C++
36 lines
738 B
C++
#ifndef COMPILER_RULES_METADATA_H_
|
|
#define COMPILER_RULES_METADATA_H_
|
|
|
|
#include <string>
|
|
#include <map>
|
|
#include "compiler/rules/rule.h"
|
|
|
|
namespace tree_sitter {
|
|
namespace rules {
|
|
|
|
typedef enum {
|
|
START_TOKEN,
|
|
PRECEDENCE,
|
|
IS_TOKEN,
|
|
DESCRIPTION,
|
|
} MetadataKey;
|
|
|
|
class Metadata : public Rule {
|
|
public:
|
|
Metadata(rule_ptr rule, std::map<MetadataKey, int> value);
|
|
|
|
bool operator==(const Rule &other) const;
|
|
size_t hash_code() const;
|
|
rule_ptr copy() const;
|
|
std::string to_string() const;
|
|
void accept(Visitor *visitor) const;
|
|
int value_for(MetadataKey key) const;
|
|
|
|
const rule_ptr rule;
|
|
const std::map<MetadataKey, int> value;
|
|
};
|
|
|
|
} // namespace rules
|
|
} // namespace tree_sitter
|
|
|
|
#endif // COMPILER_RULES_METADATA_H_
|