11use crate :: parse:: {
22 cst:: Kind as TreeKind ,
33 error:: ErrorKind ,
4- parser:: { MarkClosed , Parser } ,
4+ parser:: { MarkClosed , MarkOpened , Parser } ,
55 tokenizer:: TokenKind ,
66} ;
77
@@ -24,16 +24,16 @@ pub fn stmt_or_list_item(p: &mut Parser) -> (MarkClosed, TreeKind) {
2424 ( Name | HexLit , LCurly , _) => {
2525 let m = p. open ( ) ;
2626 p. advance ( ) ;
27- block ( p) ;
27+ let block = block ( p) ;
28+ p. close ( block, TreeKind :: Block ) ;
2829 res = ( p. close ( m, TreeKind :: Class ) , TreeKind :: Class ) ;
2930 }
3031 ( Name | String | HexLit , Colon | Eq , _) => {
3132 res = ( stmt ( p) , TreeKind :: Entry ) ;
3233 }
3334 ( LCurly , _, _) => {
34- let m = p. open ( ) ;
35- block ( p) ;
36- res = ( p. close ( m, TreeKind :: ListItem ) , TreeKind :: ListItem ) ;
35+ let m = block ( p) ;
36+ res = ( p. close ( m, TreeKind :: ListBlock ) , TreeKind :: ListBlock ) ;
3737 p. eat ( Comma ) ;
3838 }
3939 ( Name | HexLit | String | Number | True | False , _, _) => {
@@ -108,7 +108,8 @@ pub fn entry_value(p: &mut Parser) -> bool {
108108 p. scope ( TreeKind :: Class , |p| {
109109 p. advance ( ) ;
110110 if p. at ( LCurly ) {
111- block ( p) ;
111+ let block = block ( p) ;
112+ p. close ( block, TreeKind :: Block ) ;
112113 }
113114 } ) ;
114115 } ) ;
@@ -120,7 +121,8 @@ pub fn entry_value(p: &mut Parser) -> bool {
120121 p. scope ( TreeKind :: Literal , |p| p. advance ( ) ) ;
121122 }
122123 ( LCurly , _) => {
123- block ( p) ;
124+ let block = block ( p) ;
125+ p. close ( block, TreeKind :: Block ) ;
124126 }
125127 ( Newline , _) => {
126128 p. advance_with_error ( ErrorKind :: Unexpected { token : Newline } , None ) ;
@@ -165,7 +167,8 @@ pub fn expr_type_arg(p: &mut Parser) {
165167 }
166168}
167169
168- pub fn block ( p : & mut Parser ) {
170+ #[ must_use]
171+ pub fn block ( p : & mut Parser ) -> MarkOpened {
169172 assert ! ( p. at( LCurly ) ) ;
170173 let m = p. open ( ) ;
171174 p. expect ( LCurly ) ;
@@ -177,6 +180,5 @@ pub fn block(p: &mut Parser) {
177180 }
178181 }
179182 p. expect ( RCurly ) ;
180-
181- p. close ( m, TreeKind :: Block ) ;
183+ m
182184}
0 commit comments