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