Changes in src/Parser/parser.yy [ecae5860:3d26610]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
recae5860 r3d26610 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 1 17:59:57201813 // Update Count : 34 7612 // Last Modified On : Thu May 31 15:11:40 2018 13 // Update Count : 3444 14 14 // 15 15 … … 304 304 %type<en> enumerator_value_opt 305 305 306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_ no_pop_push external_definition_list_opt306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_opt 307 307 308 308 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list … … 644 644 // semantics checks, e.g., ++3, 3--, *3, &&3 645 645 | constant 646 { $$ = $1; } 646 647 | string_literal 647 648 { $$ = new ExpressionNode( $1 ); } … … 987 988 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); } 988 989 ; 990 989 991 990 992 if_control_expression: … … 1381 1383 cfa_function_declaration: // CFA 1382 1384 cfa_function_specifier 1385 { $$ = $1; } 1383 1386 | type_qualifier_list cfa_function_specifier 1384 1387 { $$ = $2->addQualifiers( $1 ); } … … 1437 1440 TYPEDEF cfa_variable_specifier 1438 1441 { 1439 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname , "1");1442 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "1"*/ ); 1440 1443 $$ = $2->addTypedef(); 1441 1444 } 1442 1445 | TYPEDEF cfa_function_specifier 1443 1446 { 1444 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname , "2");1447 typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "2"*/ ); 1445 1448 $$ = $2->addTypedef(); 1446 1449 } 1447 1450 | cfa_typedef_declaration pop ',' push no_attr_identifier 1448 1451 { 1449 typedefTable.addToEnclosingScope( *$5, TYPEDEFname , "3");1452 typedefTable.addToEnclosingScope( *$5, TYPEDEFname /*, "3"*/ ); 1450 1453 $$ = $1->appendList( $1->cloneType( $5 ) ); 1451 1454 } … … 1458 1461 TYPEDEF type_specifier declarator 1459 1462 { 1460 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname , "4");1463 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "4"*/ ); 1461 1464 $$ = $3->addType( $2 )->addTypedef(); 1462 1465 } 1463 1466 | typedef_declaration pop ',' push declarator 1464 1467 { 1465 typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname , "5");1468 typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname /*, "5"*/ ); 1466 1469 $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() ); 1467 1470 } 1468 1471 | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 ) 1469 1472 { 1470 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname , "6");1473 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "6"*/ ); 1471 1474 $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef(); 1472 1475 } 1473 1476 | type_specifier TYPEDEF declarator 1474 1477 { 1475 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname , "7");1478 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "7"*/ ); 1476 1479 $$ = $3->addType( $1 )->addTypedef(); 1477 1480 } 1478 1481 | type_specifier TYPEDEF type_qualifier_list declarator 1479 1482 { 1480 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname , "8");1483 typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "8"*/ ); 1481 1484 $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 ); 1482 1485 } … … 1934 1937 { $$ = nullptr; } 1935 1938 | bit_subrange_size 1939 { $$ = $1; } 1936 1940 ; 1937 1941 … … 2183 2187 type_parameter_list: // CFA 2184 2188 type_parameter 2189 { $$ = $1; } 2185 2190 | type_parameter_list ',' type_parameter 2186 2191 { $$ = $1->appendList( $3 ); } … … 2196 2201 type_parameter: // CFA 2197 2202 type_class no_attr_identifier_or_type_name 2198 { typedefTable.addToScope( *$2, TYPEDEFname , "9"); }2203 { typedefTable.addToScope( *$2, TYPEDEFname /*, "9"*/ ); } 2199 2204 type_initializer_opt assertion_list_opt 2200 2205 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } … … 2265 2270 no_attr_identifier_or_type_name 2266 2271 { 2267 typedefTable.addToEnclosingScope( *$1, TYPEDEFname , "10");2272 typedefTable.addToEnclosingScope( *$1, TYPEDEFname /*, "10"*/ ); 2268 2273 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2269 2274 } 2270 2275 | no_attr_identifier_or_type_name '(' type_parameter_list ')' 2271 2276 { 2272 typedefTable.addToEnclosingScope( *$1, TYPEGENname , "11");2277 typedefTable.addToEnclosingScope( *$1, TYPEGENname /*, "11"*/ ); 2273 2278 $$ = DeclarationNode::newTypeDecl( $1, $3 ); 2274 2279 } … … 2325 2330 ; 2326 2331 2327 // SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope.2328 // However, external_definition_list creates a new scope around each external_definition, but the pop loses all the2329 // types in the extern "X" and distribution at the end of the block. This version of external_definition_list does2330 2331 // not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of2332 // external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level.2333 external_definition_list_no_pop_push:2334 external_definition2335 | external_definition_list_no_pop_push2336 { forall = xxx; }2337 external_definition2338 { $$ = $1 ? $1->appendList( $3 ) : $3; }2339 ;2340 2341 2332 external_definition_list_opt: 2342 2333 // empty 2343 2334 { $$ = nullptr; } 2344 | external_definition_list _no_pop_push2335 | external_definition_list 2345 2336 ; 2346 2337 … … 2348 2339 declaration 2349 2340 | external_function_definition 2341 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 2342 { 2343 $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); 2344 } 2345 | EXTERN STRINGliteral // C++-style linkage specifier 2346 { 2347 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 2348 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2349 } 2350 // SKULLDUGGERY: Declarations in extern "X" need to be added to the current lexical scope. However, 2351 // external_definition_list_opt creates a new scope that loses the types at the end of the extern block. The 2352 // correction is a pop/push (reverse order) to undo the push/pop from external_definition_list_opt. This 2353 // trick works for nested extern "X"s, as each one undoes itself in the nesting. 2354 '{' pop external_definition_list_opt push '}' 2355 { 2356 linkage = linkageStack.top(); 2357 linkageStack.pop(); 2358 $$ = $6; 2359 } 2350 2360 | EXTENSION external_definition // GCC, multiple __extension__ allowed, meaning unknown 2351 2361 { … … 2353 2363 $$ = $2; 2354 2364 } 2355 | ASM '(' string_literal ')' ';' // GCC, global assembler statement2356 {2357 $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) );2358 }2359 | EXTERN STRINGliteral // C++-style linkage specifier2360 {2361 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall"2362 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );2363 }2364 '{' external_definition_list_opt '}'2365 {2366 linkage = linkageStack.top();2367 linkageStack.pop();2368 $$ = $5;2369 }2370 2365 | type_qualifier_list 2371 2366 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2372 '{' external_definition_list _opt '}'// CFA, namespace2367 '{' external_definition_list push '}' // CFA, namespace 2373 2368 { 2374 2369 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { … … 2383 2378 | declaration_qualifier_list 2384 2379 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2385 '{' external_definition_list _opt '}'// CFA, namespace2380 '{' external_definition_list '}' // CFA, namespace 2386 2381 { 2387 2382 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { … … 2399 2394 if ( $2->type->forall ) xxx = forall = true; // remember generic type 2400 2395 } 2401 '{' external_definition_list _opt '}'// CFA, namespace2396 '{' external_definition_list '}' // CFA, namespace 2402 2397 { 2403 2398 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { … … 2720 2715 typedef 2721 2716 // hide type name in enclosing scope by variable name 2722 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER , "ID"); }2717 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER /*, "ID"*/ ); } 2723 2718 | '(' paren_type ')' 2724 2719 { $$ = $2; }
Note:
See TracChangeset
for help on using the changeset viewer.