Changes in src/Parser/parser.yy [9a705dc8:1dbc8590]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r9a705dc8 r1dbc8590 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 17 17:10:30201813 // Update Count : 3 14412 // Last Modified On : Fri May 11 17:51:38 2018 13 // Update Count : 3261 14 14 // 15 15 … … 133 133 } // build_postfix_name 134 134 135 bool forall = false ;// aggregate have one or more forall qualifiers ?135 bool forall = false, xxx = false; // aggregate have one or more forall qualifiers ? 136 136 137 137 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type … … 208 208 %token<tok> ATTR_IDENTIFIER ATTR_TYPEDEFname ATTR_TYPEGENname 209 209 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 210 %token<tok> DIRECTIVE 210 211 // Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and 211 212 // overloading constants 0/1, e.g., x.1 is lexed as (x)(.1), where (.1) is a factional constant, but is semantically … … 282 283 %type<decl> aggregate_type aggregate_type_nobody 283 284 284 %type<decl> assertion assertion_list _opt285 %type<decl> assertion assertion_list assertion_list_opt 285 286 286 287 %type<en> bit_subrange_size_opt bit_subrange_size … … 301 302 302 303 %type<decl> field_declaration field_declaration_list field_declarator field_declaring_list 303 %type<en> field field_list field_name fraction_constants 304 %type<en> field field_list field_name fraction_constants_opt 304 305 305 306 %type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr … … 498 499 | type_name '.' no_attr_identifier // CFA, nested type 499 500 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 501 // { $$ = nullptr; } 500 502 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 501 503 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 504 // { $$ = nullptr; } 502 505 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 503 506 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } … … 532 535 | postfix_expression '.' no_attr_identifier 533 536 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 537 | postfix_expression '.' INTEGERconstant // CFA, tuple index 538 { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger( *$3 ) ) ); } 539 | postfix_expression FLOATING_FRACTIONconstant // CFA, tuple index 540 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); } 534 541 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 535 542 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); } 536 | postfix_expression FLOATING_FRACTIONconstant // CFA, tuple index537 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); }538 543 | postfix_expression ARROW no_attr_identifier 539 544 { 540 545 $$ = new ExpressionNode( build_pfieldSel( $1, *$3 == "0" || *$3 == "1" ? build_constantInteger( *$3 ) : build_varref( $3 ) ) ); 541 546 } 542 | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector543 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }544 547 | postfix_expression ARROW INTEGERconstant // CFA, tuple index 545 548 { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); } 549 | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector 550 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); } 546 551 | postfix_expression ICR 547 552 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); } … … 596 601 597 602 field_name: 598 INTEGERconstant fraction_constants 603 INTEGERconstant fraction_constants_opt 599 604 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); } 600 | FLOATINGconstant fraction_constants 605 | FLOATINGconstant fraction_constants_opt 601 606 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 602 | no_attr_identifier fraction_constants 607 | no_attr_identifier fraction_constants_opt 603 608 { 604 609 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 606 611 ; 607 612 608 fraction_constants :613 fraction_constants_opt: 609 614 // empty 610 615 { $$ = nullptr; } 611 | fraction_constants FLOATING_FRACTIONconstant616 | fraction_constants_opt FLOATING_FRACTIONconstant 612 617 { 613 618 Expression * constant = build_field_name_FLOATING_FRACTIONconstant( *$2 ); … … 875 880 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } 876 881 | asm_statement 882 | DIRECTIVE 883 { $$ = new StatementNode( build_directive( $1 ) ); } 877 884 ; 878 885 … … 1204 1211 asm_statement: 1205 1212 ASM asm_volatile_opt '(' string_literal ')' ';' 1206 { $$ = new StatementNode( build_asm stmt( $2, $4, 0 ) ); }1213 { $$ = new StatementNode( build_asm( $2, $4, 0 ) ); } 1207 1214 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC 1208 { $$ = new StatementNode( build_asm stmt( $2, $4, $6 ) ); }1215 { $$ = new StatementNode( build_asm( $2, $4, $6 ) ); } 1209 1216 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ')' ';' 1210 { $$ = new StatementNode( build_asm stmt( $2, $4, $6, $8 ) ); }1217 { $$ = new StatementNode( build_asm( $2, $4, $6, $8 ) ); } 1211 1218 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';' 1212 { $$ = new StatementNode( build_asm stmt( $2, $4, $6, $8, $10 ) ); }1219 { $$ = new StatementNode( build_asm( $2, $4, $6, $8, $10 ) ); } 1213 1220 | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';' 1214 { $$ = new StatementNode( build_asm stmt( $2, $5, 0, $8, $10, $12 ) ); }1221 { $$ = new StatementNode( build_asm( $2, $5, 0, $8, $10, $12 ) ); } 1215 1222 ; 1216 1223 … … 1866 1873 { 1867 1874 typedefTable.makeTypedef( *$3 ); 1875 if ( forall ) typedefTable.changeKind( *$3, TypedefTable::TG ); // possibly update 1876 forall = false; // reset 1868 1877 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1869 1878 } … … 2235 2244 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2236 2245 | type_specifier identifier_parameter_declarator 2246 | assertion_list 2247 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); } 2237 2248 ; 2238 2249 … … 2251 2262 // empty 2252 2263 { $$ = nullptr; } 2253 | assertion_list_opt assertion 2264 | assertion_list 2265 ; 2266 2267 assertion_list: // CFA 2268 assertion 2269 | assertion_list assertion 2254 2270 { $$ = $1 ? $1->appendList( $2 ) : $2; } 2255 2271 ; … … 2378 2394 external_definition_list: 2379 2395 external_definition 2380 | external_definition_list push external_definition 2381 { $$ = $1 ? $1->appendList( $3 ) : $3; } 2396 | external_definition_list 2397 { forall = xxx; } 2398 push external_definition 2399 { $$ = $1 ? $1->appendList( $4 ) : $4; } 2382 2400 ; 2383 2401 … … 2393 2411 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 2394 2412 { 2395 $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm stmt( false, $3, 0 ) ) );2413 $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); 2396 2414 } 2397 2415 | EXTERN STRINGliteral // C++-style linkage specifier … … 2411 2429 $$ = $2; 2412 2430 } 2413 | type_qualifier_list '{' external_definition_list '}' // CFA, namespace 2431 | type_qualifier_list 2432 { 2433 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2434 } 2435 push '{' external_definition_list '}' // CFA, namespace 2436 { 2437 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2438 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2439 iter->addQualifiers( $1->clone() ); 2440 } // if 2441 } // for 2442 xxx = false; 2443 delete $1; 2444 $$ = $5; 2445 } 2446 | declaration_qualifier_list 2447 { 2448 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2449 } 2450 push '{' external_definition_list '}' // CFA, namespace 2451 { 2452 for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2453 if ( isMangled( iter->linkage ) ) { // ignore extern "C" 2454 iter->addQualifiers( $1->clone() ); 2455 } // if 2456 } // for 2457 xxx = false; 2458 delete $1; 2459 $$ = $5; 2460 } 2461 | declaration_qualifier_list type_qualifier_list 2462 { 2463 // forall must be in the type_qualifier_list 2464 if ( $2->type->forall ) xxx = forall = true; // remember generic type 2465 } 2466 push '{' external_definition_list '}' // CFA, namespace 2467 { 2468 for ( DeclarationNode * iter = $6; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) { 2469 if ( isMangled( iter->linkage ) && isMangled( $2->linkage ) ) { // ignore extern "C" 2470 iter->addQualifiers( $1->clone() ); 2471 iter->addQualifiers( $2->clone() ); 2472 } // if 2473 } // for 2474 xxx = false; 2475 delete $1; 2476 delete $2; 2477 $$ = $6; 2478 } 2414 2479 ; 2415 2480 … … 2437 2502 with_clause_opt: 2438 2503 // empty 2439 { $$ = nullptr; }2504 { $$ = nullptr; forall = false; } 2440 2505 | WITH '(' tuple_expression_list ')' 2441 { $$ = $3; }2506 { $$ = $3; forall = false; } 2442 2507 ; 2443 2508
Note:
See TracChangeset
for help on using the changeset viewer.