Changeset 917f67dd
- Timestamp:
- Sep 30, 2024, 10:19:48 AM (6 months ago)
- Branches:
- master
- Children:
- e748094
- Parents:
- 86841ee
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Parser/parser.yy ¶
r86841ee r917f67dd 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 23 22:47:42202413 // Update Count : 67 5312 // Last Modified On : Mon Sep 30 09:40:28 2024 13 // Update Count : 6776 14 14 // 15 15 … … 1171 1171 // '[' ']' 1172 1172 // { $$ = new ExpressionNode( build_tuple() ); } 1173 // | '[' push assignment_expression pop']'1174 // { $$ = new ExpressionNode( build_tuple( $ 3) ); }1173 // '[' assignment_expression ']' 1174 // { $$ = new ExpressionNode( build_tuple( $2 ) ); } 1175 1175 '[' ',' tuple_expression_list ']' 1176 1176 { $$ = new ExpressionNode( build_tuple( yylloc, (new ExpressionNode( nullptr ))->set_last( $3 ) ) ); } 1177 | '[' push assignment_expression pop',' tuple_expression_list ']'1178 { $$ = new ExpressionNode( build_tuple( yylloc, $3->set_last( $6) ) ); }1177 | '[' assignment_expression ',' tuple_expression_list ']' 1178 { $$ = new ExpressionNode( build_tuple( yylloc, $2->set_last( $4 ) ) ); } 1179 1179 ; 1180 1180 … … 2109 2109 2110 2110 cfa_function_return: // CFA 2111 '[' push cfa_parameter_list pop']'2112 { $$ = DeclarationNode::newTuple( $ 3); }2113 | '[' push cfa_parameter_list ',' cfa_abstract_parameter_list pop']'2111 '[' cfa_parameter_list ']' 2112 { $$ = DeclarationNode::newTuple( $2 ); } 2113 | '[' cfa_parameter_list ',' cfa_abstract_parameter_list ']' 2114 2114 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the ']'. 2115 { $$ = DeclarationNode::newTuple( $ 3->set_last( $5) ); }2115 { $$ = DeclarationNode::newTuple( $2->set_last( $4 ) ); } 2116 2116 ; 2117 2117 … … 3065 3065 '.' identifier_at // C99, field name 3066 3066 { $$ = new ExpressionNode( build_varref( yylloc, $2 ) ); } 3067 | '[' push assignment_expression pop ']'// C99, single array element3067 | '[' assignment_expression ']' // C99, single array element 3068 3068 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. 3069 { $$ = $2; } 3070 | '[' subrange ']' // CFA, multiple array elements 3071 { $$ = $2; } 3072 | '[' constant_expression ELLIPSIS constant_expression ']' // GCC, multiple array elements 3073 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $2 ), maybeMoveBuild( $4 ) ) ); } 3074 | '.' '[' field_name_list ']' // CFA, tuple field selector 3069 3075 { $$ = $3; } 3070 | '[' push subrange pop ']' // CFA, multiple array elements3071 { $$ = $3; }3072 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements3073 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); }3074 | '.' '[' push field_name_list pop ']' // CFA, tuple field selector3075 { $$ = $4; }3076 3076 ; 3077 3077 … … 4005 4005 { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); } 4006 4006 // Cannot use constant_expression because of tuples => semantic check 4007 | '[' push assignment_expression pop',' comma_expression ']' // CFA4008 { $$ = DeclarationNode::newArray( $ 3, nullptr, false )->addArray( DeclarationNode::newArray( $6, nullptr, false ) ); }4007 | '[' assignment_expression ',' comma_expression ']' // CFA 4008 { $$ = DeclarationNode::newArray( $2, nullptr, false )->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); } 4009 4009 // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 4010 4010 … … 4012 4012 // | '[' push assignment_expression pop ',' push array_dimension_list pop ']' // CFA 4013 4013 4014 | '[' push array_type_list pop ']'// CFA4015 { $$ = DeclarationNode::newArray( $ 3, nullptr, false ); }4014 | '[' array_type_list ']' // CFA 4015 { $$ = DeclarationNode::newArray( $2, nullptr, false ); } 4016 4016 | multi_array_dimension 4017 4017 ; … … 4043 4043 4044 4044 multi_array_dimension: 4045 '[' push assignment_expression pop']'4046 { $$ = DeclarationNode::newArray( $ 3, nullptr, false ); }4047 | '[' push '*' pop ']'// C994045 '[' assignment_expression ']' 4046 { $$ = DeclarationNode::newArray( $2, nullptr, false ); } 4047 | '[' '*' ']' // C99 4048 4048 { $$ = DeclarationNode::newVarArray( 0 ); } 4049 | multi_array_dimension '[' push assignment_expression pop']'4050 { $$ = $1->addArray( DeclarationNode::newArray( $ 4, nullptr, false ) ); }4051 | multi_array_dimension '[' push '*' pop ']'// C994049 | multi_array_dimension '[' assignment_expression ']' 4050 { $$ = $1->addArray( DeclarationNode::newArray( $3, nullptr, false ) ); } 4051 | multi_array_dimension '[' '*' ']' // C99 4052 4052 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } 4053 4053 ; … … 4266 4266 4267 4267 cfa_array_parameter_1st_dimension: 4268 '[' push type_qualifier_list '*' pop ']'// remaining C994269 { $$ = DeclarationNode::newVarArray( $ 3); }4270 | '[' push type_qualifier_list assignment_expression pop']'4271 { $$ = DeclarationNode::newArray( $ 4, $3, false ); }4272 | '[' push declaration_qualifier_list assignment_expression pop']'4268 '[' type_qualifier_list '*' ']' // remaining C99 4269 { $$ = DeclarationNode::newVarArray( $2 ); } 4270 | '[' type_qualifier_list assignment_expression ']' 4271 { $$ = DeclarationNode::newArray( $3, $2, false ); } 4272 | '[' declaration_qualifier_list assignment_expression ']' 4273 4273 // declaration_qualifier_list must be used because of shift/reduce conflict with 4274 4274 // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot 4275 4275 // appear in this context. 4276 { $$ = DeclarationNode::newArray( $ 4, $3, true ); }4277 | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop']'4278 { $$ = DeclarationNode::newArray( $ 5, $4->addQualifiers( $3), true ); }4276 { $$ = DeclarationNode::newArray( $3, $2, true ); } 4277 | '[' declaration_qualifier_list type_qualifier_list assignment_expression ']' 4278 { $$ = DeclarationNode::newArray( $4, $3->addQualifiers( $2 ), true ); } 4279 4279 ; 4280 4280 … … 4345 4345 4346 4346 cfa_abstract_tuple: // CFA 4347 '[' push cfa_abstract_parameter_list pop']'4348 { $$ = DeclarationNode::newTuple( $ 3); }4349 | '[' push type_specifier_nobody ELLIPSIS pop']'4347 '[' cfa_abstract_parameter_list ']' 4348 { $$ = DeclarationNode::newTuple( $2 ); } 4349 | '[' type_specifier_nobody ELLIPSIS ']' 4350 4350 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; } 4351 | '[' push type_specifier_nobody ELLIPSIS constant_expression pop']'4351 | '[' type_specifier_nobody ELLIPSIS constant_expression ']' 4352 4352 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; } 4353 4353 ;
Note: See TracChangeset
for help on using the changeset viewer.