Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    recae5860 r3d26610  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun  1 17:59:57 2018
    13 // Update Count     : 3476
     12// Last Modified On : Thu May 31 15:11:40 2018
     13// Update Count     : 3444
    1414//
    1515
     
    304304%type<en> enumerator_value_opt
    305305
    306 %type<decl> exception_declaration external_definition external_definition_list external_definition_list_no_pop_push external_definition_list_opt
     306%type<decl> exception_declaration external_definition external_definition_list external_definition_list_opt
    307307
    308308%type<decl> field_declaration field_declaration_list_opt field_declarator_opt field_declaring_list
     
    644644                // semantics checks, e.g., ++3, 3--, *3, &&3
    645645        | constant
     646                { $$ = $1; }
    646647        | string_literal
    647648                { $$ = new ExpressionNode( $1 ); }
     
    987988                { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }
    988989        ;
     990
    989991
    990992if_control_expression:
     
    13811383cfa_function_declaration:                                                               // CFA
    13821384        cfa_function_specifier
     1385                { $$ = $1; }
    13831386        | type_qualifier_list cfa_function_specifier
    13841387                { $$ = $2->addQualifiers( $1 ); }
     
    14371440        TYPEDEF cfa_variable_specifier
    14381441                {
    1439                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "1" );
     1442                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "1"*/ );
    14401443                        $$ = $2->addTypedef();
    14411444                }
    14421445        | TYPEDEF cfa_function_specifier
    14431446                {
    1444                         typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname, "2" );
     1447                        typedefTable.addToEnclosingScope( *$2->name, TYPEDEFname /*, "2"*/ );
    14451448                        $$ = $2->addTypedef();
    14461449                }
    14471450        | cfa_typedef_declaration pop ',' push no_attr_identifier
    14481451                {
    1449                         typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" );
     1452                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname /*, "3"*/ );
    14501453                        $$ = $1->appendList( $1->cloneType( $5 ) );
    14511454                }
     
    14581461        TYPEDEF type_specifier declarator
    14591462                {
    1460                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
     1463                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "4"*/ );
    14611464                        $$ = $3->addType( $2 )->addTypedef();
    14621465                }
    14631466        | typedef_declaration pop ',' push declarator
    14641467                {
    1465                         typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname, "5" );
     1468                        typedefTable.addToEnclosingScope( *$5->name, TYPEDEFname /*, "5"*/ );
    14661469                        $$ = $1->appendList( $1->cloneBaseType( $5 )->addTypedef() );
    14671470                }
    14681471        | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 )
    14691472                {
    1470                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "6" );
     1473                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "6"*/ );
    14711474                        $$ = $4->addType( $3 )->addQualifiers( $1 )->addTypedef();
    14721475                }
    14731476        | type_specifier TYPEDEF declarator
    14741477                {
    1475                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "7" );
     1478                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname /*, "7"*/ );
    14761479                        $$ = $3->addType( $1 )->addTypedef();
    14771480                }
    14781481        | type_specifier TYPEDEF type_qualifier_list declarator
    14791482                {
    1480                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "8" );
     1483                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname /*, "8"*/ );
    14811484                        $$ = $4->addQualifiers( $1 )->addTypedef()->addType( $1 );
    14821485                }
     
    19341937                { $$ = nullptr; }
    19351938        | bit_subrange_size
     1939                { $$ = $1; }
    19361940        ;
    19371941
     
    21832187type_parameter_list:                                                                    // CFA
    21842188        type_parameter
     2189                { $$ = $1; }
    21852190        | type_parameter_list ',' type_parameter
    21862191                { $$ = $1->appendList( $3 ); }
     
    21962201type_parameter:                                                                                 // CFA
    21972202        type_class no_attr_identifier_or_type_name
    2198                 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
     2203                { typedefTable.addToScope( *$2, TYPEDEFname /*, "9"*/ ); }
    21992204          type_initializer_opt assertion_list_opt
    22002205                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
     
    22652270        no_attr_identifier_or_type_name
    22662271                {
    2267                         typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
     2272                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname /*, "10"*/ );
    22682273                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    22692274                }
    22702275        | no_attr_identifier_or_type_name '(' type_parameter_list ')'
    22712276                {
    2272                         typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" );
     2277                        typedefTable.addToEnclosingScope( *$1, TYPEGENname /*, "11"*/ );
    22732278                        $$ = DeclarationNode::newTypeDecl( $1, $3 );
    22742279                }
     
    23252330        ;
    23262331
    2327         // SKULLDUGGERY: Declarations in extern "X" and distribution need to be added to the current lexical scope.
    2328         // However, external_definition_list creates a new scope around each external_definition, but the pop loses all the
    2329         // types in the extern "X" and distribution at the end of the block. This version of external_definition_list does
    2330 
    2331         // not do push/pop for declarations at the level of the extern "X" and distribution block. Any recursive uses of
    2332         // external_definition_list within the extern "X" and distribution block correctly pushes/pops for that scope level.
    2333 external_definition_list_no_pop_push:
    2334         external_definition
    2335         | external_definition_list_no_pop_push
    2336                 { forall = xxx; }
    2337           external_definition
    2338                 { $$ = $1 ? $1->appendList( $3 ) : $3; }
    2339         ;
    2340 
    23412332external_definition_list_opt:
    23422333        // empty
    23432334                { $$ = nullptr; }
    2344         | external_definition_list_no_pop_push
     2335        | external_definition_list
    23452336        ;
    23462337
     
    23482339        declaration
    23492340        | external_function_definition
     2341        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
     2342                {
     2343                        $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) );
     2344                }
     2345        | EXTERN STRINGliteral                                                          // C++-style linkage specifier
     2346                {
     2347                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     2348                        linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
     2349                }
     2350                        // SKULLDUGGERY: Declarations in extern "X" need to be added to the current lexical scope.  However,
     2351                        // external_definition_list_opt creates a new scope that loses the types at the end of the extern block. The
     2352                        // correction is a pop/push (reverse order) to undo the push/pop from external_definition_list_opt.  This
     2353                        // trick works for nested extern "X"s, as each one undoes itself in the nesting.
     2354          '{' pop external_definition_list_opt push '}'
     2355                {
     2356                        linkage = linkageStack.top();
     2357                        linkageStack.pop();
     2358                        $$ = $6;
     2359                }
    23502360        | EXTENSION external_definition                                         // GCC, multiple __extension__ allowed, meaning unknown
    23512361                {
     
    23532363                        $$ = $2;
    23542364                }
    2355         | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    2356                 {
    2357                         $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) );
    2358                 }
    2359         | EXTERN STRINGliteral                                                          // C++-style linkage specifier
    2360                 {
    2361                         linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2362                         linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
    2363                 }
    2364           '{' external_definition_list_opt '}'
    2365                 {
    2366                         linkage = linkageStack.top();
    2367                         linkageStack.pop();
    2368                         $$ = $5;
    2369                 }
    23702365        | type_qualifier_list
    23712366                { if ( $1->type->forall ) xxx = forall = true; } // remember generic type
    2372           '{' external_definition_list_opt '}'                          // CFA, namespace
     2367          '{' external_definition_list push '}'                  // CFA, namespace
    23732368                {
    23742369                        for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     
    23832378        | declaration_qualifier_list
    23842379                { if ( $1->type->forall ) xxx = forall = true; } // remember generic type
    2385           '{' external_definition_list_opt '}'                          // CFA, namespace
     2380          '{' external_definition_list '}'                                       // CFA, namespace
    23862381                {
    23872382                        for ( DeclarationNode * iter = $4; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     
    23992394                        if ( $2->type->forall ) xxx = forall = true; // remember generic type
    24002395                }
    2401           '{' external_definition_list_opt '}'                          // CFA, namespace
     2396          '{' external_definition_list '}'                                      // CFA, namespace
    24022397                {
    24032398                        for ( DeclarationNode * iter = $5; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     
    27202715        typedef
    27212716                // hide type name in enclosing scope by variable name
    2722                 { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" ); }
     2717                { typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER /*, "ID"*/ ); }
    27232718        | '(' paren_type ')'
    27242719                { $$ = $2; }
Note: See TracChangeset for help on using the changeset viewer.