Changes in src/Parser/parser.yy [4c3ee8d:3fd8b0e]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r4c3ee8d r3fd8b0e 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 2 20:23:14201813 // Update Count : 3 60712 // Last Modified On : Thu Jun 7 10:07:12 2018 13 // Update Count : 3527 14 14 // 15 15 … … 115 115 } // distExt 116 116 117 void distQual( DeclarationNode * declaration, DeclarationNode * qualifiers ) {118 // distribute qualifiers across all declarations in a distribution statemement119 for ( DeclarationNode * iter = declaration; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {120 if ( isMangled( iter->linkage ) ) { // ignore extern "C"121 iter->addQualifiers( qualifiers->clone() );122 } // if123 } // for124 } // distExt125 126 117 // There is an ambiguity for inline generic-routine return-types and generic routines. 127 118 // forall( otype T ) struct S { int i; } bar( T ) {} … … 145 136 } // build_postfix_name 146 137 147 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 ? 148 139 149 140 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type … … 313 304 %type<en> enumerator_value_opt 314 305 315 %type<decl> external_definition external_definition_list external_definition_list_opt 316 317 %type<decl> exception_declaration 306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt 318 307 319 308 %type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list … … 514 503 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 515 504 | type_name '.' no_attr_identifier // CFA, nested type 516 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 505 // { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 506 { $$ = nullptr; } 517 507 | type_name '.' '[' field_list ']' // CFA, nested type / tuple field selector 518 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 508 // { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 509 { $$ = nullptr; } 519 510 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 520 511 { … … 1145 1136 1146 1137 waitfor: 1147 WAITFOR '(' cast_expression ')' 1148 { $$ = $3; } 1149 | WAITFOR '(' cast_expression ',' argument_expression_list ')' 1150 { $$ = (ExpressionNode *)$3->set_last( $5 ); } 1138 WAITFOR '(' identifier ')' 1139 { 1140 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 1141 delete $3; 1142 } 1143 | WAITFOR '(' identifier ',' argument_expression_list ')' 1144 { 1145 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 1146 $$->set_last( $5 ); 1147 delete $3; 1148 } 1151 1149 ; 1152 1150 … … 1165 1163 { $$ = build_waitfor_timeout( nullptr, $3, $1 ); } 1166 1164 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1167 | when_clause_opt timeout statement WOR ELSE statement1168 { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }1169 1165 | when_clause_opt timeout statement WOR when_clause ELSE statement 1170 1166 { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); } … … 1796 1792 { $$ = DeclarationNode::newFromTypedef( $1 ); } 1797 1793 | '.' TYPEDEFname 1798 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1794 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), DeclarationNode::newFromTypedef( $2 ) ); } 1799 1795 | type_name '.' TYPEDEFname 1800 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1796 { $$ = DeclarationNode::newQualifiedType( $1, DeclarationNode::newFromTypedef( $3 ) ); } 1801 1797 | typegen_name 1802 1798 | '.' typegen_name 1803 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1799 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), $2 ); } 1804 1800 | type_name '.' typegen_name 1805 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1801 { $$ = DeclarationNode::newQualifiedType( $1, $3 ); } 1806 1802 ; 1807 1803 … … 1825 1821 ; 1826 1822 1827 fred:1828 // empty1829 { yyy = false; }1830 ;1831 1832 1823 aggregate_type: // struct, union 1833 1824 aggregate_key attribute_list_opt '{' field_declaration_list_opt '}' 1834 1825 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1835 | aggregate_key attribute_list_opt no_attr_identifier fred1826 | aggregate_key attribute_list_opt no_attr_identifier 1836 1827 { 1837 1828 typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef 1829 //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update 1838 1830 forall = false; // reset 1839 1831 } 1840 1832 '{' field_declaration_list_opt '}' 1841 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $ 7, true )->addQualifiers( $2 ); }1842 | 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 1843 1835 { 1844 1836 typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef 1837 //if ( forall ) typedefTable.changeKind( *$3->type->symbolic.name, TYPEGENname ); // possibly update 1845 1838 forall = false; // reset 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 ); 1851 //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update 1858 1852 forall = false; // reset 1859 1853 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1860 1854 } 1861 | aggregate_key attribute_list_opt type_name fred1855 | aggregate_key attribute_list_opt type_name 1862 1856 { 1863 1857 // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is … … 1873 1867 aggregate_key: 1874 1868 STRUCT 1875 { yyy = true;$$ = DeclarationNode::Struct; }1869 { $$ = DeclarationNode::Struct; } 1876 1870 | UNION 1877 { yyy = true;$$ = DeclarationNode::Union; }1871 { $$ = DeclarationNode::Union; } 1878 1872 | EXCEPTION 1879 { yyy = true;$$ = DeclarationNode::Exception; }1873 { $$ = DeclarationNode::Exception; } 1880 1874 | COROUTINE 1881 { yyy = true;$$ = DeclarationNode::Coroutine; }1875 { $$ = DeclarationNode::Coroutine; } 1882 1876 | MONITOR 1883 { yyy = true;$$ = DeclarationNode::Monitor; }1877 { $$ = DeclarationNode::Monitor; } 1884 1878 | THREAD 1885 { yyy = true;$$ = DeclarationNode::Thread; }1879 { $$ = DeclarationNode::Thread; } 1886 1880 ; 1887 1881 … … 1899 1893 { distExt( $3 ); $$ = distAttr( $2, $3 ); } // mark all fields in list 1900 1894 | typedef_declaration ';' // CFA 1901 { SemanticError( yylloc, "Typedef in aggregate is currently unimplemented." ); $$ = nullptr; }1902 1895 | cfa_field_declaring_list ';' // CFA, new style field declaration 1903 1896 | EXTENSION cfa_field_declaring_list ';' // GCC 1904 1897 { distExt( $2 ); $$ = $2; } // mark all fields in list 1905 1898 | cfa_typedef_declaration ';' // CFA 1906 { SemanticError( yylloc, "Typedef in aggregate is currently unimplemented." ); $$ = nullptr; }1907 1899 | static_assert // C11 1908 1900 ; … … 2328 2320 2329 2321 translation_unit: 2330 // empty, input file 2322 // empty 2323 {} // empty input file 2331 2324 | external_definition_list 2332 2325 { parseTree = parseTree ? parseTree->appendList( $1 ) : $1; } … … 2342 2335 ; 2343 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 2344 2351 external_definition_list_opt: 2345 2352 // empty 2346 2353 { $$ = nullptr; } 2347 | external_definition_list 2348 ; 2349 2350 up: 2351 { typedefTable.up(); } 2352 ; 2353 2354 down: 2355 { typedefTable.down(); } 2354 | external_definition_list_no_pop_push 2356 2355 ; 2357 2356 … … 2373 2372 linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 ); 2374 2373 } 2375 '{' up external_definition_list_opt down'}'2374 '{' external_definition_list_opt '}' 2376 2375 { 2377 2376 linkage = linkageStack.top(); 2378 2377 linkageStack.pop(); 2379 $$ = $ 6;2378 $$ = $5; 2380 2379 } 2381 2380 | type_qualifier_list 2382 { 2383 if ( $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2384 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2385 } 2386 '{' up external_definition_list_opt down '}' // CFA, namespace 2387 { 2388 distQual( $5, $1 ); 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 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2386 iter->addQualifiers( $1->clone() ); 2387 } // if 2388 } // for 2389 2389 xxx = false; 2390 2390 delete $1; 2391 $$ = $ 5;2391 $$ = $4; 2392 2392 } 2393 2393 | declaration_qualifier_list 2394 { 2395 if ( $1->type && $1->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2396 if ( $1->type && $1->type->forall ) xxx = forall = true; // remember generic type 2397 } 2398 '{' up external_definition_list_opt down '}' // CFA, namespace 2399 { 2400 distQual( $5, $1 ); 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() ) { 2398 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2399 iter->addQualifiers( $1->clone() ); 2400 } // if 2401 } // for 2401 2402 xxx = false; 2402 2403 delete $1; 2403 $$ = $ 5;2404 $$ = $4; 2404 2405 } 2405 2406 | declaration_qualifier_list type_qualifier_list 2406 2407 { 2407 if ( ($1->type && $1->type->qualifiers.val) || $2->type->qualifiers.val ) { SemanticError( yylloc, "CV qualifiers cannot be distributed; only storage-class and forall qualifiers." ); } 2408 if ( ($1->type && $1->type->forall) || $2->type->forall ) xxx = forall = true; // remember generic type 2409 } 2410 '{' up external_definition_list_opt down '}' // CFA, namespace 2411 { 2412 distQual( $6, $2 ); 2413 distQual( $6, $1 ); 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() ) { 2414 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C" 2415 iter->addQualifiers( $1->clone() ); 2416 iter->addQualifiers( $2->clone() ); 2417 } // if 2418 } // for 2414 2419 xxx = false; 2415 2420 delete $1; 2416 2421 delete $2; 2417 $$ = $ 6;2422 $$ = $5; 2418 2423 } 2419 2424 ;
Note:
See TracChangeset
for help on using the changeset viewer.