Add token helper for building token rules
Now you can specify the structure of tokens using all of the rule functions, not just `str` and `pattern`
This commit is contained in:
parent
d685edf015
commit
6d40dcf881
8 changed files with 59 additions and 12 deletions
|
|
@ -26,7 +26,14 @@ namespace tree_sitter {
|
|||
}
|
||||
|
||||
rule_ptr Metadata::copy() const {
|
||||
return make_shared<Metadata>(rule, value);
|
||||
return make_shared<Metadata>(rule->copy(), value);
|
||||
}
|
||||
|
||||
int Metadata::value_for(MetadataKey key) const {
|
||||
auto pair = value.find(key);
|
||||
return (pair != value.end()) ?
|
||||
pair->second :
|
||||
0;
|
||||
}
|
||||
|
||||
std::string Metadata::to_string() const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue