Add HIR Expr machinery

This commit is contained in:
Florian Diebold
2019-01-05 16:32:07 +01:00
parent a6f33b4ca5
commit 136aba1cf3
9 changed files with 542 additions and 4 deletions

View File

@@ -378,7 +378,11 @@ impl<R: TreeRoot<RaTypes>> BreakExprNode<R> {
}
impl<'a> BreakExpr<'a> {}
impl<'a> BreakExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
// Byte
#[derive(Debug, Clone, Copy,)]
@@ -3880,6 +3884,10 @@ impl<'a> StructLit<'a> {
pub fn named_field_list(self) -> Option<NamedFieldList<'a>> {
super::child_opt(self)
}
pub fn spread(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
// StructPat

View File

@@ -384,7 +384,7 @@ Grammar(
options: [ "Condition" ]
),
"ContinueExpr": (),
"BreakExpr": (),
"BreakExpr": (options: ["Expr"]),
"Label": (),
"BlockExpr": (
options: [ "Block" ]
@@ -404,7 +404,7 @@ Grammar(
collections: [ [ "pats", "Pat" ] ]
),
"MatchGuard": (),
"StructLit": (options: ["Path", "NamedFieldList"]),
"StructLit": (options: ["Path", "NamedFieldList", ["spread", "Expr"]]),
"NamedFieldList": (collections: [ ["fields", "NamedField"] ]),
"NamedField": (options: ["NameRef", "Expr"]),
"CallExpr": (