Changes in src/Parser/parser.yy [3d56d15b:a1c9ddd]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r3d56d15b ra1c9ddd 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 22 13:59:11201813 // Update Count : 35 8612 // Last Modified On : Thu Jun 7 10:07:12 2018 13 // Update Count : 3527 14 14 // 15 15 … … 136 136 } // build_postfix_name 137 137 138 bool forall = false, xxx = false , yyy = false;// aggregate have one or more forall qualifiers ?138 bool forall = false, xxx = false; // aggregate have one or more forall qualifiers ? 139 139 140 140 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type … … 304 304 %type<en> enumerator_value_opt 305 305 306 %type<decl> external_definition external_definition_list external_definition_list_opt 307 308 %type<decl> exception_declaration 306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt 309 307 310 308 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list … … 1823 1821 ; 1824 1822 1825 fred:1826 // empty1827 { yyy = false; }1828 ;1829 1830 1823 aggregate_type: // struct, union 1831 1824 aggregate_key attribute_list_opt '{' field_declaration_list_opt '}' 1832 1825 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1833 | aggregate_key attribute_list_opt no_attr_identifier fred1826 | aggregate_key attribute_list_opt no_attr_identifier 1834 1827 { 1835 1828 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef … … 1838 1831 } 1839 1832 '{' field_declaration_list_opt '}' 1840 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $ 7, true )->addQualifiers( $2 ); }1841 | aggregate_key attribute_list_opt type_name fred1833 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); } 1834 | aggregate_key attribute_list_opt type_name 1842 1835 { 1843 1836 typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef … … 1846 1839 } 1847 1840 '{' field_declaration_list_opt '}' 1848 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $ 7, true )->addQualifiers( $2 ); }1841 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $6, true )->addQualifiers( $2 ); } 1849 1842 | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list_opt '}' // CFA 1850 1843 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } … … 1853 1846 1854 1847 aggregate_type_nobody: // struct, union - {...} 1855 aggregate_key attribute_list_opt no_attr_identifier fred1848 aggregate_key attribute_list_opt no_attr_identifier 1856 1849 { 1857 1850 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); … … 1860 1853 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1861 1854 } 1862 | aggregate_key attribute_list_opt type_name fred1855 | aggregate_key attribute_list_opt type_name 1863 1856 { 1864 1857 // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is … … 1874 1867 aggregate_key: 1875 1868 STRUCT 1876 { yyy = true;$$ = DeclarationNode::Struct; }1869 { $$ = DeclarationNode::Struct; } 1877 1870 | UNION 1878 { yyy = true;$$ = DeclarationNode::Union; }1871 { $$ = DeclarationNode::Union; } 1879 1872 | EXCEPTION 1880 { yyy = true;$$ = DeclarationNode::Exception; }1873 { $$ = DeclarationNode::Exception; } 1881 1874 | COROUTINE 1882 { yyy = true;$$ = DeclarationNode::Coroutine; }1875 { $$ = DeclarationNode::Coroutine; } 1883 1876 | MONITOR 1884 { yyy = true;$$ = DeclarationNode::Monitor; }1877 { $$ = DeclarationNode::Monitor; } 1885 1878 | THREAD 1886 { yyy = true;$$ = DeclarationNode::Thread; }1879 { $$ = DeclarationNode::Thread; } 1887 1880 ; 1888 1881 … … 2329 2322 2330 2323 translation_unit: 2331 // empty, input file 2324 // empty 2325 {} // empty input file 2332 2326 | external_definition_list 2333 2327 { parseTree = parseTree ? parseTree->appendList( $1 ) : $1; } … … 2343 2337 ; 2344 2338 2339 // SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope. 2340 // However, external_definition_list creates a new scope around each external_definition, but the pop loses all the 2341 // types in the extern "X" and distribution at the end of the block. This version of external_definition_list does 2342 2343 // not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of 2344 // external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level. 2345 external_definition_list_no_pop_push: 2346 external_definition 2347 | external_definition_list_no_pop_push 2348 { forall = xxx; } 2349 external_definition 2350 { $$ = $1 ? $1->appendList( $3 ) : $3; } 2351 ; 2352 2345 2353 external_definition_list_opt: 2346 2354 // empty 2347 2355 { $$ = nullptr; } 2348 | external_definition_list 2349 ; 2350 2351 up: 2352 { typedefTable.up(); } 2353 ; 2354 2355 down: 2356 { typedefTable.down(); } 2356 | external_definition_list_no_pop_push 2357 2357 ; 2358 2358 … … 2374 2374 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2375 2375 } 2376 '{' up external_definition_list_opt down'}'2376 '{' external_definition_list_opt '}' 2377 2377 { 2378 2378 linkage = linkageStack.top(); 2379 2379 linkageStack.pop(); 2380 $$ = $ 6;2380 $$ = $5; 2381 2381 } 2382 2382 | type_qualifier_list 2383 { 2384 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2385 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2386 } 2387 '{' up external_definition_list_opt down '}' // CFA, namespace 2388 { 2389 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2383 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2384 '{' external_definition_list_opt '}' // CFA, namespace 2385 { 2386 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2390 2387 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2391 2388 iter->addQualifiers( $1->clone() ); … … 2394 2391 xxx = false; 2395 2392 delete $1; 2396 $$ = $ 5;2393 $$ = $4; 2397 2394 } 2398 2395 | declaration_qualifier_list 2399 { 2400 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2401 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2402 } 2403 '{' up external_definition_list_opt down '}' // CFA, namespace 2404 { 2405 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2396 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2397 '{' external_definition_list_opt '}' // CFA, namespace 2398 { 2399 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2406 2400 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2407 2401 iter->addQualifiers( $1->clone() ); … … 2410 2404 xxx = false; 2411 2405 delete $1; 2412 $$ = $ 5;2406 $$ = $4; 2413 2407 } 2414 2408 | declaration_qualifier_list type_qualifier_list 2415 2409 { 2416 if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); }2417 if ( ($1->type && $1->type->forall) ||$2->type->forall ) xxx = forall = true; // remember generic type2418 } 2419 '{' up external_definition_list_opt down '}'// CFA, namespace2420 { 2421 for ( DeclarationNode * iter = $ 6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {2410 // forall must be in the type_qualifier_list 2411 if ( $2->type->forall ) xxx = forall = true; // remember generic type 2412 } 2413 '{' external_definition_list_opt '}' // CFA, namespace 2414 { 2415 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2422 2416 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C" 2423 2417 iter->addQualifiers( $1->clone() ); … … 2428 2422 delete $1; 2429 2423 delete $2; 2430 $$ = $ 6;2424 $$ = $5; 2431 2425 } 2432 2426 ;
Note:
See TracChangeset
for help on using the changeset viewer.