Changeset c653b37 for src/Parser/parser.yy
- Timestamp:
- Jun 28, 2018, 4:04:11 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- e3b2474
- Parents:
- a12c81f3 (diff), 944ce47 (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
ra12c81f3 rc653b37 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 7 10:07:12201813 // Update Count : 35 2712 // Last Modified On : Sun Jun 24 10:41:10 2018 13 // Update Count : 3587 14 14 // 15 15 … … 136 136 } // build_postfix_name 137 137 138 bool forall = false, xxx = false ;// aggregate have one or more forall qualifiers ?138 bool forall = false, xxx = false, yyy = 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> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt 306 %type<decl> external_definition external_definition_list external_definition_list_opt 307 308 %type<decl> exception_declaration 307 309 308 310 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list … … 503 505 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 504 506 | type_name '.' no_attr_identifier // CFA, nested type 505 // { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 506 { $$ = nullptr; } 507 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 507 508 | type_name '.' '[' field_list ']' // CFA, nested type / tuple field selector 508 // { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 509 { $$ = nullptr; } 509 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 510 510 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 511 511 { … … 1821 1821 ; 1822 1822 1823 fred: 1824 // empty 1825 { yyy = false; } 1826 ; 1827 1823 1828 aggregate_type: // struct, union 1824 1829 aggregate_key attribute_list_opt '{' field_declaration_list_opt '}' 1825 1830 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1826 | aggregate_key attribute_list_opt no_attr_identifier 1831 | aggregate_key attribute_list_opt no_attr_identifier fred 1827 1832 { 1828 1833 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef 1829 //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update1830 1834 forall = false; // reset 1831 1835 } 1832 1836 '{' field_declaration_list_opt '}' 1833 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $ 6, true )->addQualifiers( $2 ); }1834 | aggregate_key attribute_list_opt type_name 1837 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $7, true )->addQualifiers( $2 ); } 1838 | aggregate_key attribute_list_opt type_name fred 1835 1839 { 1836 1840 typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef 1837 //if ( forall ) typedefTable.changeKind( *$3->type->symbolic.name, TYPEGENname ); // possibly update1838 1841 forall = false; // reset 1839 1842 } 1840 1843 '{' field_declaration_list_opt '}' 1841 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $ 6, true )->addQualifiers( $2 ); }1844 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, nullptr, $7, true )->addQualifiers( $2 ); } 1842 1845 | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list_opt '}' // CFA 1843 1846 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } … … 1846 1849 1847 1850 aggregate_type_nobody: // struct, union - {...} 1848 aggregate_key attribute_list_opt no_attr_identifier 1851 aggregate_key attribute_list_opt no_attr_identifier fred 1849 1852 { 1850 1853 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); 1851 //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update1852 1854 forall = false; // reset 1853 1855 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1854 1856 } 1855 | aggregate_key attribute_list_opt type_name 1857 | aggregate_key attribute_list_opt type_name fred 1856 1858 { 1857 1859 // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is … … 1867 1869 aggregate_key: 1868 1870 STRUCT 1869 { $$ = DeclarationNode::Struct; }1871 { yyy = true; $$ = DeclarationNode::Struct; } 1870 1872 | UNION 1871 { $$ = DeclarationNode::Union; }1873 { yyy = true; $$ = DeclarationNode::Union; } 1872 1874 | EXCEPTION 1873 { $$ = DeclarationNode::Exception; }1875 { yyy = true; $$ = DeclarationNode::Exception; } 1874 1876 | COROUTINE 1875 { $$ = DeclarationNode::Coroutine; }1877 { yyy = true; $$ = DeclarationNode::Coroutine; } 1876 1878 | MONITOR 1877 { $$ = DeclarationNode::Monitor; }1879 { yyy = true; $$ = DeclarationNode::Monitor; } 1878 1880 | THREAD 1879 { $$ = DeclarationNode::Thread; }1881 { yyy = true; $$ = DeclarationNode::Thread; } 1880 1882 ; 1881 1883 … … 2320 2322 2321 2323 translation_unit: 2322 // empty 2323 {} // empty input file 2324 // empty, input file 2324 2325 | external_definition_list 2325 2326 { parseTree = parseTree ? parseTree->appendList( $1 ) : $1; } … … 2335 2336 ; 2336 2337 2337 // SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope.2338 // However, external_definition_list creates a new scope around each external_definition, but the pop loses all the2339 // types in the extern "X" and distribution at the end of the block. This version of external_definition_list does2340 2341 // not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of2342 // external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level.2343 external_definition_list_no_pop_push:2344 external_definition2345 | external_definition_list_no_pop_push2346 { forall = xxx; }2347 external_definition2348 { $$ = $1 ? $1->appendList( $3 ) : $3; }2349 ;2350 2351 2338 external_definition_list_opt: 2352 2339 // empty 2353 2340 { $$ = nullptr; } 2354 | external_definition_list_no_pop_push 2341 | external_definition_list 2342 ; 2343 2344 up: 2345 { typedefTable.up(); } 2346 ; 2347 2348 down: 2349 { typedefTable.down(); } 2355 2350 ; 2356 2351 … … 2372 2367 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2373 2368 } 2374 '{' external_definition_list_opt'}'2369 '{' up external_definition_list_opt down '}' 2375 2370 { 2376 2371 linkage = linkageStack.top(); 2377 2372 linkageStack.pop(); 2378 $$ = $ 5;2373 $$ = $6; 2379 2374 } 2380 2375 | type_qualifier_list 2381 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2382 '{' external_definition_list_opt '}' // CFA, namespace 2383 { 2384 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2376 { 2377 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2378 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2379 } 2380 '{' up external_definition_list_opt down '}' // CFA, namespace 2381 { 2382 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2385 2383 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2386 2384 iter->addQualifiers( $1->clone() ); … … 2389 2387 xxx = false; 2390 2388 delete $1; 2391 $$ = $ 4;2389 $$ = $5; 2392 2390 } 2393 2391 | declaration_qualifier_list 2394 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2395 '{' external_definition_list_opt '}' // CFA, namespace 2396 { 2397 for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2392 { 2393 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2394 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2395 } 2396 '{' up external_definition_list_opt down '}' // CFA, namespace 2397 { 2398 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2398 2399 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2399 2400 iter->addQualifiers( $1->clone() ); … … 2402 2403 xxx = false; 2403 2404 delete $1; 2404 $$ = $ 4;2405 $$ = $5; 2405 2406 } 2406 2407 | declaration_qualifier_list type_qualifier_list 2407 2408 { 2408 // forall must be in the type_qualifier_list2409 if ( $2->type->forall ) xxx = forall = true; // remember generic type2410 } 2411 '{' external_definition_list_opt '}'// CFA, namespace2412 { 2413 for ( DeclarationNode * iter = $ 5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {2409 if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2410 if ( ($1->type && $1->type->forall) || $2->type->forall ) xxx = forall = true; // remember generic type 2411 } 2412 '{' up external_definition_list_opt down '}' // CFA, namespace 2413 { 2414 for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2414 2415 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C" 2415 2416 iter->addQualifiers( $1->clone() ); … … 2420 2421 delete $1; 2421 2422 delete $2; 2422 $$ = $ 5;2423 $$ = $6; 2423 2424 } 2424 2425 ;
Note: See TracChangeset
for help on using the changeset viewer.