Changes in src/Parser/parser.yy [3fd8b0e:203c667]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r3fd8b0e r203c667 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 { … … 1792 1792 { $$ = DeclarationNode::newFromTypedef( $1 ); } 1793 1793 | '.' TYPEDEFname 1794 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), DeclarationNode::newFromTypedef( $2 ) ); }1794 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 1795 1795 | type_name '.' TYPEDEFname 1796 { $$ = DeclarationNode::newQualifiedType( $1, DeclarationNode::newFromTypedef( $3 ) ); }1796 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 1797 1797 | typegen_name 1798 1798 | '.' typegen_name 1799 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), $2 ); }1799 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 1800 1800 | type_name '.' typegen_name 1801 { $$ = DeclarationNode::newQualifiedType( $1, $3 ); }1801 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 1802 1802 ; 1803 1803 … … 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 … … 1893 1895 { distExt( $3 ); $$ = distAttr( $2, $3 ); } // mark all fields in list 1894 1896 | typedef_declaration ';' // CFA 1897 { SemanticError( yylloc, "Typedef in aggregate is currently unimplemented." ); $$ = nullptr; } 1895 1898 | cfa_field_declaring_list ';' // CFA, new style field declaration 1896 1899 | EXTENSION cfa_field_declaring_list ';' // GCC 1897 1900 { distExt( $2 ); $$ = $2; } // mark all fields in list 1898 1901 | cfa_typedef_declaration ';' // CFA 1902 { SemanticError( yylloc, "Typedef in aggregate is currently unimplemented." ); $$ = nullptr; } 1899 1903 | static_assert // C11 1900 1904 ; … … 2320 2324 2321 2325 translation_unit: 2322 // empty 2323 {} // empty input file 2326 // empty, input file 2324 2327 | external_definition_list 2325 2328 { parseTree = parseTree ? parseTree->appendList( $1 ) : $1; } … … 2335 2338 ; 2336 2339 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 2340 external_definition_list_opt: 2352 2341 // empty 2353 2342 { $$ = nullptr; } 2354 | external_definition_list_no_pop_push 2343 | external_definition_list 2344 ; 2345 2346 up: 2347 { typedefTable.up(); } 2348 ; 2349 2350 down: 2351 { typedefTable.down(); } 2355 2352 ; 2356 2353 … … 2372 2369 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2373 2370 } 2374 '{' external_definition_list_opt'}'2371 '{' up external_definition_list_opt down '}' 2375 2372 { 2376 2373 linkage = linkageStack.top(); 2377 2374 linkageStack.pop(); 2378 $$ = $ 5;2375 $$ = $6; 2379 2376 } 2380 2377 | 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() ) { 2378 { 2379 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2380 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2381 } 2382 '{' up external_definition_list_opt down '}' // CFA, namespace 2383 { 2384 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2385 2385 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2386 2386 iter->addQualifiers( $1->clone() ); … … 2389 2389 xxx = false; 2390 2390 delete $1; 2391 $$ = $ 4;2391 $$ = $5; 2392 2392 } 2393 2393 | 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() ) { 2394 { 2395 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2396 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2397 } 2398 '{' up external_definition_list_opt down '}' // CFA, namespace 2399 { 2400 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2398 2401 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2399 2402 iter->addQualifiers( $1->clone() ); … … 2402 2405 xxx = false; 2403 2406 delete $1; 2404 $$ = $ 4;2407 $$ = $5; 2405 2408 } 2406 2409 | declaration_qualifier_list type_qualifier_list 2407 2410 { 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() ) {2411 if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2412 if ( ($1->type && $1->type->forall) || $2->type->forall ) xxx = forall = true; // remember generic type 2413 } 2414 '{' up external_definition_list_opt down '}' // CFA, namespace 2415 { 2416 for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2414 2417 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C" 2415 2418 iter->addQualifiers( $1->clone() ); … … 2420 2423 delete $1; 2421 2424 delete $2; 2422 $$ = $ 5;2425 $$ = $6; 2423 2426 } 2424 2427 ;
Note:
See TracChangeset
for help on using the changeset viewer.