aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs31
-rw-r--r--crates/libsyntax2/src/grammar.ron6
2 files changed, 35 insertions, 2 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index b937fe5a2..1dd161f52 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -116,9 +116,13 @@ impl<'a> AstNode<'a> for Block<'a> {
116} 116}
117 117
118impl<'a> Block<'a> { 118impl<'a> Block<'a> {
119 pub fn let_stmts(self) -> impl Iterator<Item = LetStmt<'a>> + 'a { 119 pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a {
120 super::children(self) 120 super::children(self)
121 } 121 }
122
123 pub fn expr(self) -> Option<Expr<'a>> {
124 super::child_opt(self)
125 }
122} 126}
123 127
124// BlockExpr 128// BlockExpr
@@ -1370,6 +1374,31 @@ impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {}
1370impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} 1374impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {}
1371impl<'a> StaticDef<'a> {} 1375impl<'a> StaticDef<'a> {}
1372 1376
1377// Stmt
1378#[derive(Debug, Clone, Copy)]
1379pub enum Stmt<'a> {
1380 ExprStmt(ExprStmt<'a>),
1381 LetStmt(LetStmt<'a>),
1382}
1383
1384impl<'a> AstNode<'a> for Stmt<'a> {
1385 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1386 match syntax.kind() {
1387 EXPR_STMT => Some(Stmt::ExprStmt(ExprStmt { syntax })),
1388 LET_STMT => Some(Stmt::LetStmt(LetStmt { syntax })),
1389 _ => None,
1390 }
1391 }
1392 fn syntax(self) -> SyntaxNodeRef<'a> {
1393 match self {
1394 Stmt::ExprStmt(inner) => inner.syntax(),
1395 Stmt::LetStmt(inner) => inner.syntax(),
1396 }
1397 }
1398}
1399
1400impl<'a> Stmt<'a> {}
1401
1373// StructDef 1402// StructDef
1374#[derive(Debug, Clone, Copy)] 1403#[derive(Debug, Clone, Copy)]
1375pub struct StructDef<'a> { 1404pub struct StructDef<'a> {
diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron
index aa2742b3e..f3c3d3036 100644
--- a/crates/libsyntax2/src/grammar.ron
+++ b/crates/libsyntax2/src/grammar.ron
@@ -437,9 +437,13 @@ Grammar(
437 ["pat", "Pat"], 437 ["pat", "Pat"],
438 ["initializer", "Expr"], 438 ["initializer", "Expr"],
439 ]), 439 ]),
440 "Stmt": (
441 enum: ["ExprStmt", "LetStmt"],
442 ),
440 "Block": ( 443 "Block": (
444 options: [["expr", "Expr"]],
441 collections: [ 445 collections: [
442 ["let_stmts", "LetStmt"], 446 ["statements", "Stmt"],
443 ] 447 ]
444 ), 448 ),
445 "ParamList": ( 449 "ParamList": (