Changeset 2e9b59b for src/Parser/parser.yy
- Timestamp:
- Apr 19, 2022, 3:00:04 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 5b84a321
- Parents:
- ba897d21 (diff), bb7c77d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rba897d21 r2e9b59b 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 25 17:54:56202213 // Update Count : 52 6212 // Last Modified On : Mon Mar 14 16:35:29 2022 13 // Update Count : 5276 14 14 // 15 15 … … 652 652 // Historic, transitional: Disallow commas in subscripts. 653 653 // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts. 654 // { SemanticError( yylloc, "New array subscript is currently unimplemented." ); $$ = nullptr; }655 654 // Current: Commas in subscripts make tuples. 656 655 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); } … … 661 660 // equivalent to the old x[i,j]. 662 661 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); } 662 | constant '[' assignment_expression ']' // 3[a], 'a'[a], 3.5[a] 663 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); } 664 | string_literal '[' assignment_expression ']' // "abc"[3], 3["abc"] 665 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); } 663 666 | postfix_expression '{' argument_expression_list_opt '}' // CFA, constructor call 664 667 { … … 2300 2303 ; 2301 2304 2302 enum_type: // enum2305 enum_type: // static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed ); // enum 2303 2306 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2304 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }2307 { $$ = DeclarationNode::newEnum( nullptr, $4, true, false )->addQualifiers( $2 ); } 2305 2308 | ENUM attribute_list_opt identifier 2306 2309 { typedefTable.makeTypedef( *$3 ); } 2307 2310 '{' enumerator_list comma_opt '}' 2308 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); }2311 { $$ = DeclarationNode::newEnum( $3, $6, true, false )->addQualifiers( $2 ); } 2309 2312 | ENUM attribute_list_opt typedef_name // unqualified type name 2310 2313 '{' enumerator_list comma_opt '}' 2311 { $$ = DeclarationNode::newEnum( $3->name, $5, true )->addQualifiers( $2 ); }2314 { $$ = DeclarationNode::newEnum( $3->name, $5, true, false )->addQualifiers( $2 ); } 2312 2315 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}' 2313 2316 { 2314 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2315 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2316 } 2317 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2317 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) 2318 { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2319 // SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2320 2321 $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 ) -> addEnumBase( $3 ); 2322 // $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 ); 2323 } 2324 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier 2318 2325 { 2319 2326 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } … … 2322 2329 '{' enumerator_list comma_opt '}' 2323 2330 { 2324 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2331 $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 ); 2332 // $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ); 2325 2333 } 2326 2334 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' … … 2328 2336 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2329 2337 typedefTable.makeTypedef( *$6->name ); 2330 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2338 $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 ); 2339 // $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ); 2331 2340 } 2332 2341 | enum_type_nobody … … 2335 2344 enum_type_nobody: // enum - {...} 2336 2345 ENUM attribute_list_opt identifier 2337 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); }2346 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); } 2338 2347 | ENUM attribute_list_opt type_name // qualified type name 2339 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false )->addQualifiers( $2 ); }2348 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); } 2340 2349 ; 2341 2350
Note:
See TracChangeset
for help on using the changeset viewer.