This commit is contained in:
Aleksey Kladov 2018-08-11 09:38:27 +03:00
parent 35b59bb438
commit 7581984601
3 changed files with 20 additions and 3 deletions

View file

@ -19,4 +19,15 @@ impl<R: TreeRoot> AstNode<R> for {{ Name }}<R> {
}
fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
}
impl<R: TreeRoot> {{ Name }}<R> {
{% for (method_name, kind) in node.opts %}
{% set ChildName = kind | camel %}
pub fn {{ method_name }}<'a>(&'a self) -> impl Iterator<Item = {{ ChildKind }}<R>> + 'a {
self.syntax()
.children()
.filter_map({{ ChildKind }}::cast)
}
{% endfor %}
}
{% endfor %}

View file

@ -215,10 +215,16 @@ Grammar(
],
ast: [
(
kind: "FILE"
kind: "FILE",
collections: [
("functions", "FUNCTION")
]
),
(
kind: "FUNCTION"
kind: "FUNCTION",
options: [
("name", "NAME")
]
),
(
kind: "NAME"

View file

@ -5,7 +5,7 @@ authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
publish = false
[dependencies]
ron = "0.1.7"
ron = "0.3.0"
walkdir = "2.1.3"
itertools = "0.7.8"
tera = "0.11"