Add accessor methods on Grammar

This commit is contained in:
Max Brunsfeld 2014-06-09 21:05:25 -07:00
parent b4a34dd7c2
commit 54a555168d
10 changed files with 47 additions and 44 deletions

View file

@ -3,14 +3,13 @@
namespace tree_sitter_examples {
using tree_sitter::Grammar;
using tree_sitter::GrammarOptions;
using namespace tree_sitter::rules;
static rule_ptr terminated(rule_ptr rule) {
return seq({ rule, sym("_terminator") });
}
extern const Grammar golang({
extern const Grammar golang = Grammar({
{ "program", seq({
sym("package_directive"),
repeat(sym("imports_block")),
@ -121,7 +120,5 @@ namespace tree_sitter_examples {
{ "_identifier", pattern("\\a[\\w_]*") },
{ "number", pattern("\\d+(\\.\\d+)?") },
{ "comment", pattern("//[^\n]*") },
}, GrammarOptions({
{ "comment" },
}));
}).ubiquitous_tokens({ "comment" });
}

View file

@ -5,7 +5,7 @@ namespace tree_sitter_examples {
using tree_sitter::Grammar;
using namespace tree_sitter::rules;
extern const Grammar javascript({
extern const Grammar javascript = Grammar({
{ "program", repeat(sym("statement")) },
// Statements
@ -181,8 +181,5 @@ namespace tree_sitter_examples {
{ "null", keyword("null") },
{ "true", keyword("true") },
{ "false", keyword("false") },
}, {
// ubiquitous_tokens
{ "comment" }
});
}).ubiquitous_tokens({ "comment" });
}