Changes in src/Parser/parser.yy [1dbc8590:9a705dc8]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r1dbc8590 r9a705dc8 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri May 11 17:51:38201813 // Update Count : 3 26112 // Last Modified On : Tue Apr 17 17:10:30 2018 13 // Update Count : 3144 14 14 // 15 15 … … 133 133 } // build_postfix_name 134 134 135 bool forall = false , xxx = false;// aggregate have one or more forall qualifiers ?135 bool forall = 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> DIRECTIVE211 210 // Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and 212 211 // overloading constants 0/1, e.g., x.1 is lexed as (x)(.1), where (.1) is a factional constant, but is semantically … … 283 282 %type<decl> aggregate_type aggregate_type_nobody 284 283 285 %type<decl> assertion assertion_list assertion_list_opt284 %type<decl> assertion assertion_list_opt 286 285 287 286 %type<en> bit_subrange_size_opt bit_subrange_size … … 302 301 303 302 %type<decl> field_declaration field_declaration_list field_declarator field_declaring_list 304 %type<en> field field_list field_name fraction_constants _opt303 %type<en> field field_list field_name fraction_constants 305 304 306 305 %type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr … … 499 498 | type_name '.' no_attr_identifier // CFA, nested type 500 499 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 501 // { $$ = nullptr; }502 500 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 503 501 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 504 // { $$ = nullptr; }505 502 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 506 503 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } … … 535 532 | postfix_expression '.' no_attr_identifier 536 533 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 537 | postfix_expression '.' INTEGERconstant // CFA, tuple index538 { $$ = new ExpressionNode( build_fieldSel( $1, build_ constantInteger( *$3) ) ); }534 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 535 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); } 539 536 | postfix_expression FLOATING_FRACTIONconstant // CFA, tuple index 540 537 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); } 541 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector542 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }543 538 | postfix_expression ARROW no_attr_identifier 544 539 { 545 540 $$ = new ExpressionNode( build_pfieldSel( $1, *$3 == "0" || *$3 == "1" ? build_constantInteger( *$3 ) : build_varref( $3 ) ) ); 546 541 } 542 | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector 543 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); } 547 544 | postfix_expression ARROW INTEGERconstant // CFA, tuple index 548 545 { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); } 549 | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector550 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }551 546 | postfix_expression ICR 552 547 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); } … … 601 596 602 597 field_name: 603 INTEGERconstant fraction_constants _opt598 INTEGERconstant fraction_constants 604 599 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); } 605 | FLOATINGconstant fraction_constants _opt600 | FLOATINGconstant fraction_constants 606 601 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 607 | no_attr_identifier fraction_constants _opt602 | no_attr_identifier fraction_constants 608 603 { 609 604 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 611 606 ; 612 607 613 fraction_constants _opt:608 fraction_constants: 614 609 // empty 615 610 { $$ = nullptr; } 616 | fraction_constants _optFLOATING_FRACTIONconstant611 | fraction_constants FLOATING_FRACTIONconstant 617 612 { 618 613 Expression * constant = build_field_name_FLOATING_FRACTIONconstant( *$2 ); … … 880 875 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } 881 876 | asm_statement 882 | DIRECTIVE883 { $$ = new StatementNode( build_directive( $1 ) ); }884 877 ; 885 878 … … 1211 1204 asm_statement: 1212 1205 ASM asm_volatile_opt '(' string_literal ')' ';' 1213 { $$ = new StatementNode( build_asm ( $2, $4, 0 ) ); }1206 { $$ = new StatementNode( build_asmstmt( $2, $4, 0 ) ); } 1214 1207 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC 1215 { $$ = new StatementNode( build_asm ( $2, $4, $6 ) ); }1208 { $$ = new StatementNode( build_asmstmt( $2, $4, $6 ) ); } 1216 1209 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ')' ';' 1217 { $$ = new StatementNode( build_asm ( $2, $4, $6, $8 ) ); }1210 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8 ) ); } 1218 1211 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';' 1219 { $$ = new StatementNode( build_asm ( $2, $4, $6, $8, $10 ) ); }1212 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8, $10 ) ); } 1220 1213 | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';' 1221 { $$ = new StatementNode( build_asm ( $2, $5, 0, $8, $10, $12 ) ); }1214 { $$ = new StatementNode( build_asmstmt( $2, $5, 0, $8, $10, $12 ) ); } 1222 1215 ; 1223 1216 … … 1873 1866 { 1874 1867 typedefTable.makeTypedef( *$3 ); 1875 if ( forall ) typedefTable.changeKind( *$3, TypedefTable::TG ); // possibly update1876 forall = false; // reset1877 1868 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1878 1869 } … … 2244 2235 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2245 2236 | type_specifier identifier_parameter_declarator 2246 | assertion_list2247 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }2248 2237 ; 2249 2238 … … 2262 2251 // empty 2263 2252 { $$ = nullptr; } 2264 | assertion_list 2265 ; 2266 2267 assertion_list: // CFA 2268 assertion 2269 | assertion_list assertion 2253 | assertion_list_opt assertion 2270 2254 { $$ = $1 ? $1->appendList( $2 ) : $2; } 2271 2255 ; … … 2394 2378 external_definition_list: 2395 2379 external_definition 2396 | external_definition_list 2397 { forall = xxx; } 2398 push external_definition 2399 { $$ = $1 ? $1->appendList( $4 ) : $4; } 2380 | external_definition_list push external_definition 2381 { $$ = $1 ? $1->appendList( $3 ) : $3; } 2400 2382 ; 2401 2383 … … 2411 2393 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 2412 2394 { 2413 $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm ( false, $3, 0 ) ) );2395 $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asmstmt( false, $3, 0 ) ) ); 2414 2396 } 2415 2397 | EXTERN STRINGliteral // C++-style linkage specifier … … 2429 2411 $$ = $2; 2430 2412 } 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 } 2413 | type_qualifier_list '{' external_definition_list '}' // CFA, namespace 2479 2414 ; 2480 2415 … … 2502 2437 with_clause_opt: 2503 2438 // empty 2504 { $$ = nullptr; forall = false;}2439 { $$ = nullptr; } 2505 2440 | WITH '(' tuple_expression_list ')' 2506 { $$ = $3; forall = false;}2441 { $$ = $3; } 2507 2442 ; 2508 2443
Note:
See TracChangeset
for help on using the changeset viewer.