Add keyword helper for making higher-priority string tokens

This commit is contained in:
Max Brunsfeld 2014-05-01 13:25:20 -07:00
parent 60e2728acc
commit 93620b3ed1
13 changed files with 54 additions and 27 deletions

View file

@ -55,6 +55,10 @@ namespace tree_sitter {
return make_shared<String>(value);
}
rule_ptr keyword(const string &value) {
return metadata(make_shared<String>(value), { { PRECEDENCE, 100}, { IS_TOKEN, 1 } });
}
rule_ptr err(const rule_ptr &rule) {
return choice({ rule, ERROR().copy() });
}