@@ -13,7 +13,7 @@ pub fn constant_p() -> impl Parser<RcStringView, Output = Statement> {
1313 . or_syntax_error ( "Expected: const name" ) ,
1414 equal_sign ( ) ,
1515 expression_pos_p ( ) . or_syntax_error ( "Expected: const value" ) ,
16- |_, _, const_name, _, const_value_expr| Statement :: Const ( const_name, const_value_expr) ,
16+ |_, _, const_name, _, const_value_expr| Statement :: constant ( const_name, const_value_expr) ,
1717 )
1818}
1919
@@ -34,11 +34,11 @@ mod tests {
3434 assert_eq ! (
3535 program,
3636 vec![
37- GlobalStatement :: Statement ( Statement :: Const (
37+ GlobalStatement :: Statement ( Statement :: constant (
3838 "X" . as_name( 2 , 15 ) ,
3939 42 . as_lit_expr( 2 , 19 ) ,
4040 ) ) ,
41- GlobalStatement :: Statement ( Statement :: Const (
41+ GlobalStatement :: Statement ( Statement :: constant (
4242 "Y$" . as_name( 3 , 15 ) ,
4343 "hello" . as_lit_expr( 3 , 20 ) ,
4444 ) )
@@ -55,12 +55,10 @@ mod tests {
5555 let input = format ! ( "CONST {} = {}" , name, value) ;
5656 let statement = parse ( & input) . demand_single_statement ( ) ;
5757 match statement {
58- Statement :: Const (
59- Positioned { element : left, .. } ,
60- Positioned { element : right, .. } ,
61- ) => {
62- assert_eq ! ( left, Name :: from( * name) ) ;
63- assert_eq ! ( right, Expression :: IntegerLiteral ( * value) ) ;
58+ Statement :: Const ( c) => {
59+ let ( left, right) = c. into ( ) ;
60+ assert_eq ! ( left. element, Name :: from( * name) ) ;
61+ assert_eq ! ( right. element, Expression :: IntegerLiteral ( * value) ) ;
6462 }
6563 _ => panic ! ( "Expected constant" ) ,
6664 }
@@ -75,7 +73,7 @@ mod tests {
7573 assert_eq ! (
7674 program,
7775 vec![
78- GlobalStatement :: Statement ( Statement :: Const (
76+ GlobalStatement :: Statement ( Statement :: constant (
7977 "ANSWER" . as_name( 1 , 7 ) ,
8078 42 . as_lit_expr( 1 , 16 ) ,
8179 ) )
0 commit comments