Changes in src/Parser/parser.yy [203c667:3fd8b0e]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r203c667 r3fd8b0e 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jun 24 10:41:10201813 // Update Count : 35 8712 // 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 … … 505 503 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 506 504 | type_name '.' no_attr_identifier // CFA, nested type 507 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 505 // { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 506 { $$ = nullptr; } 508 507 | type_name '.' '[' field_list ']' // CFA, nested type / tuple field selector 509 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 508 // { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 509 { $$ = nullptr; } 510 510 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 511 511 { … … 1792 1792 { $$ = DeclarationNode::newFromTypedef( $1 ); } 1793 1793 | '.' TYPEDEFname 1794 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1794 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), DeclarationNode::newFromTypedef( $2 ) ); } 1795 1795 | type_name '.' TYPEDEFname 1796 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1796 { $$ = DeclarationNode::newQualifiedType( $1, DeclarationNode::newFromTypedef( $3 ) ); } 1797 1797 | typegen_name 1798 1798 | '.' typegen_name 1799 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1799 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), $2 ); } 1800 1800 | type_name '.' typegen_name 1801 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1801 { $$ = DeclarationNode::newQualifiedType( $1, $3 ); } 1802 1802 ; 1803 1803 … … 1821 1821 ; 1822 1822 1823 fred:1824 // empty1825 { yyy = false; }1826 ;1827 1828 1823 aggregate_type: // struct, union 1829 1824 aggregate_key attribute_list_opt '{' field_declaration_list_opt '}' 1830 1825 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1831 | aggregate_key attribute_list_opt no_attr_identifier fred1826 | aggregate_key attribute_list_opt no_attr_identifier 1832 1827 { 1833 1828 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef 1829 //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update 1834 1830 forall = false; // reset 1835 1831 } 1836 1832 '{' field_declaration_list_opt '}' 1837 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $ 7, true )->addQualifiers( $2 ); }1838 | 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 1839 1835 { 1840 1836 typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef 1837 //if ( forall ) typedefTable.changeKind( *$3->type->symbolic.name, TYPEGENname ); // possibly update 1841 1838 forall = false; // reset 1842 1839 } 1843 1840 '{' field_declaration_list_opt '}' 1844 { $$ = 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 ); } 1845 1842 | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list_opt '}' // CFA 1846 1843 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } … … 1849 1846 1850 1847 aggregate_type_nobody: // struct, union - {...} 1851 aggregate_key attribute_list_opt no_attr_identifier fred1848 aggregate_key attribute_list_opt no_attr_identifier 1852 1849 { 1853 1850 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); 1851 //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update 1854 1852 forall = false; // reset 1855 1853 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1856 1854 } 1857 | aggregate_key attribute_list_opt type_name fred1855 | aggregate_key attribute_list_opt type_name 1858 1856 { 1859 1857 // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is … … 1869 1867 aggregate_key: 1870 1868 STRUCT 1871 { yyy = true;$$ = DeclarationNode::Struct; }1869 { $$ = DeclarationNode::Struct; } 1872 1870 | UNION 1873 { yyy = true;$$ = DeclarationNode::Union; }1871 { $$ = DeclarationNode::Union; } 1874 1872 | EXCEPTION 1875 { yyy = true;$$ = DeclarationNode::Exception; }1873 { $$ = DeclarationNode::Exception; } 1876 1874 | COROUTINE 1877 { yyy = true;$$ = DeclarationNode::Coroutine; }1875 { $$ = DeclarationNode::Coroutine; } 1878 1876 | MONITOR 1879 { yyy = true;$$ = DeclarationNode::Monitor; }1877 { $$ = DeclarationNode::Monitor; } 1880 1878 | THREAD 1881 { yyy = true;$$ = DeclarationNode::Thread; }1879 { $$ = DeclarationNode::Thread; } 1882 1880 ; 1883 1881 … … 1895 1893 { distExt( $3 ); $$ = distAttr( $2, $3 ); } // mark all fields in list 1896 1894 | typedef_declaration ';' // CFA 1897 { SemanticError( yylloc, "Typedef in aggregate is currently unimplemented." ); $$ = nullptr; }1898 1895 | cfa_field_declaring_list ';' // CFA, new style field declaration 1899 1896 | EXTENSION cfa_field_declaring_list ';' // GCC 1900 1897 { distExt( $2 ); $$ = $2; } // mark all fields in list 1901 1898 | cfa_typedef_declaration ';' // CFA 1902 { SemanticError( yylloc, "Typedef in aggregate is currently unimplemented." ); $$ = nullptr; }1903 1899 | static_assert // C11 1904 1900 ; … … 2324 2320 2325 2321 translation_unit: 2326 // empty, input file 2322 // empty 2323 {} // empty input file 2327 2324 | external_definition_list 2328 2325 { parseTree = parseTree ? parseTree->appendList( $1 ) : $1; } … … 2338 2335 ; 2339 2336 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 the 2339 // types in the extern "X" and distribution at the end of the block. This version of external_definition_list does 2340 2341 // not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of 2342 // 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_definition 2345 | external_definition_list_no_pop_push 2346 { forall = xxx; } 2347 external_definition 2348 { $$ = $1 ? $1->appendList( $3 ) : $3; } 2349 ; 2350 2340 2351 external_definition_list_opt: 2341 2352 // empty 2342 2353 { $$ = nullptr; } 2343 | external_definition_list 2344 ; 2345 2346 up: 2347 { typedefTable.up(); } 2348 ; 2349 2350 down: 2351 { typedefTable.down(); } 2354 | external_definition_list_no_pop_push 2352 2355 ; 2353 2356 … … 2369 2372 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2370 2373 } 2371 '{' up external_definition_list_opt down'}'2374 '{' external_definition_list_opt '}' 2372 2375 { 2373 2376 linkage = linkageStack.top(); 2374 2377 linkageStack.pop(); 2375 $$ = $ 6;2378 $$ = $5; 2376 2379 } 2377 2380 | type_qualifier_list 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() ) { 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() ) { 2385 2385 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2386 2386 iter->addQualifiers( $1->clone() ); … … 2389 2389 xxx = false; 2390 2390 delete $1; 2391 $$ = $ 5;2391 $$ = $4; 2392 2392 } 2393 2393 | declaration_qualifier_list 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() ) { 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() ) { 2401 2398 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2402 2399 iter->addQualifiers( $1->clone() ); … … 2405 2402 xxx = false; 2406 2403 delete $1; 2407 $$ = $ 5;2404 $$ = $4; 2408 2405 } 2409 2406 | declaration_qualifier_list type_qualifier_list 2410 2407 { 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 type2413 } 2414 '{' up external_definition_list_opt down '}'// CFA, namespace2415 { 2416 for ( DeclarationNode * iter = $ 6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {2408 // forall must be in the type_qualifier_list 2409 if ( $2->type->forall ) xxx = forall = true; // remember generic type 2410 } 2411 '{' external_definition_list_opt '}' // CFA, namespace 2412 { 2413 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2417 2414 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C" 2418 2415 iter->addQualifiers( $1->clone() ); … … 2423 2420 delete $1; 2424 2421 delete $2; 2425 $$ = $ 6;2422 $$ = $5; 2426 2423 } 2427 2424 ;
Note:
See TracChangeset
for help on using the changeset viewer.