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:
Max Brunsfeld 2014-05-01 12:43:29 -07:00
parent d685edf015
commit 6d40dcf881
8 changed files with 59 additions and 12 deletions

View file

@ -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 {