Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    ra7741435 r8780e30  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 14 21:28:22 2016
    13 // Update Count     : 2090
     12// Last Modified On : Wed Oct 26 17:35:53 2016
     13// Update Count     : 2066
    1414//
    1515
     
    7878%token RESTRICT                                                                                 // C99
    7979%token FORALL LVALUE                                                                    // CFA
    80 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T
     80%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    8181%token VALIST                                                                                   // GCC
    8282%token BOOL COMPLEX IMAGINARY                                                   // C99
     
    153153%type<fctl> for_control_expression
    154154%type<en> subrange
    155 %type<constant> asm_name_opt
    156155%type<en> asm_operands_opt asm_operands_list asm_operand
    157156%type<label> label_list
     
    363362                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    364363        | zero_one
    365                 { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); }
     364                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    366365        | tuple
    367366        | '(' comma_expression ')'
     
    413412argument_expression:
    414413        // empty
    415                 { $$ = nullptr; }                                                               // use default argument
     414                { $$ = 0; }                                                                             // use default argument
    416415        | assignment_expression
    417416        ;
     
    444443                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    445444        | no_attr_identifier fraction_constants
    446                 {
    447                         if( (*$1) == "0" || (*$1) == "1" ) {
    448                                 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
    449                         } else {
    450                                 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
    451                         }
    452                 }
     445                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); }
    453446        ;
    454447
     
    685678comma_expression_opt:
    686679        // empty
    687                 { $$ = nullptr; }
     680                { $$ = 0; }
    688681        | comma_expression
    689682        ;
     
    721714        | '{'
    722715                // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
    723                 // requires its own scope.
     716                // requires its own scope
    724717          push push
    725718          local_label_declaration_opt                                           // GCC, local labels
     
    775768                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    776769                        // statement.
    777                         $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     770                        $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    778771                }
    779772        | CHOOSE '(' comma_expression ')' case_clause           // CFA
     
    782775                {
    783776                        StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
    784                         $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     777                        $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    785778                }
    786779        ;
     
    819812switch_clause_list_opt:                                                                 // CFA
    820813        // empty
    821                 { $$ = nullptr; }
     814                { $$ = 0; }
    822815        | switch_clause_list
    823816        ;
     
    832825choose_clause_list_opt:                                                                 // CFA
    833826        // empty
    834                 { $$ = nullptr; }
     827                { $$ = 0; }
    835828        | choose_clause_list
    836829        ;
     
    855848fall_through:                                                                                   // CFA
    856849        FALLTHRU
    857                 { $$ = nullptr; }
     850                { $$ = 0; }
    858851        | FALLTHRU ';'
    859                 { $$ = nullptr; }
     852                { $$ = 0; }
    860853        ;
    861854
     
    991984asm_operands_opt:                                                                               // GCC
    992985        // empty
    993                 { $$ = nullptr; }                                                               // use default argument
     986                { $$ = 0; }                                                                             // use default argument
    994987        | asm_operands_list
    995988        ;
     
    10101003asm_clobbers_list_opt:                                                                  // GCC
    10111004        // empty
    1012                 { $$ = nullptr; }                                                               // use default argument
     1005                { $$ = 0; }                                                                             // use default argument
    10131006        | string_literal
    10141007                { $$ = new ExpressionNode( $1 ); }
    10151008        | asm_clobbers_list_opt ',' string_literal
    1016                 // set_last return ParseNode *
    10171009                { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
    10181010        ;
     
    10351027declaration_list_opt:                                                                   // used at beginning of switch statement
    10361028        pop
    1037                 { $$ = nullptr; }
     1029                { $$ = 0; }
    10381030        | declaration_list
    10391031        ;
     
    10471039old_declaration_list_opt:                                                               // used to declare parameter types in K&R style functions
    10481040        pop
    1049                 { $$ = nullptr; }
     1041                { $$ = 0; }
    10501042        | old_declaration_list
    10511043        ;
     
    11221114                {
    11231115                        typedefTable.setNextIdentifier( *$2 );
    1124                         $$ = $1->addName( $2 )->addAsmName( $3 );
     1116                        $$ = $1->addName( $2 );
    11251117                }
    11261118        | new_abstract_tuple identifier_or_type_name asm_name_opt
    11271119                {
    11281120                        typedefTable.setNextIdentifier( *$2 );
    1129                         $$ = $1->addName( $2 )->addAsmName( $3 );
     1121                        $$ = $1->addName( $2 );
    11301122                }
    11311123        | type_qualifier_list new_abstract_tuple identifier_or_type_name asm_name_opt
    11321124                {
    11331125                        typedefTable.setNextIdentifier( *$3 );
    1134                         $$ = $2->addQualifiers( $1 )->addName( $3 )->addAsmName( $4 );
     1126                        $$ = $2->addQualifiers( $1 )->addName( $3 );
    11351127                }
    11361128        ;
     
    12831275                {
    12841276                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1285                         $$ = ( $2->addType( $1 ))->addAsmName( $3 )->addInitializer( $4 );
     1277                        $$ = ( $2->addType( $1 ))->addInitializer( $4 );
    12861278                }
    12871279        | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt
    12881280                {
    12891281                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1290                         $$ = $1->appendList( $1->cloneBaseType( $4->addAsmName( $5 )->addInitializer( $6 ) ) );
     1282                        $$ = $1->appendList( $1->cloneBaseType( $4->addInitializer( $6 ) ) );
    12911283                }
    12921284        ;
     
    13081300type_qualifier_list_opt:                                                                // GCC, used in asm_statement
    13091301        // empty
    1310                 { $$ = nullptr; }
     1302                { $$ = 0; }
    13111303        | type_qualifier_list
    13121304        ;
     
    14181410        | VALIST                                                                                        // GCC, __builtin_va_list
    14191411                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    1420         | ZERO_T
    1421                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    1422         | ONE_T
    1423                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    14241412        ;
    14251413
     
    15341522field_declaration_list:
    15351523        // empty
    1536                 { $$ = nullptr; }
     1524                { $$ = 0; }
    15371525        | field_declaration_list field_declaration
    1538                 { $$ = $1 ? $1->appendList( $2 ) : $2; }
     1526                { $$ = $1 != 0 ? $1->appendList( $2 ) : $2; }
    15391527        ;
    15401528
     
    15851573bit_subrange_size_opt:
    15861574        // empty
    1587                 { $$ = nullptr; }
     1575                { $$ = 0; }
    15881576        | bit_subrange_size
    15891577                { $$ = $1; }
     
    16221610enumerator_value_opt:
    16231611        // empty
    1624                 { $$ = nullptr; }
     1612                { $$ = 0; }
    16251613        | '=' constant_expression
    16261614                { $$ = $2; }
     
    16311619new_parameter_type_list_opt:                                                    // CFA
    16321620        // empty
    1633                 { $$ = nullptr; }
     1621                { $$ = 0; }
    16341622        | new_parameter_type_list
    16351623        ;
     
    16661654parameter_type_list_opt:
    16671655        // empty
    1668                 { $$ = nullptr; }
     1656                { $$ = 0; }
    16691657        | parameter_type_list
    16701658        ;
     
    17141702                {
    17151703                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1716                         $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
     1704                        $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ) );
    17171705                }
    17181706        | declaration_specifier type_parameter_redeclarator assignment_opt
    17191707                {
    17201708                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1721                         $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
     1709                        $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ) );
    17221710                }
    17231711        ;
     
    17751763initializer_opt:
    17761764        // empty
    1777                 { $$ = nullptr; }
     1765                { $$ = 0; }
    17781766        | '=' initializer
    17791767                { $$ = $2; }
     
    17891777initializer_list:
    17901778        // empty
    1791                 { $$ = nullptr; }
     1779                { $$ = 0; }
    17921780        | initializer
    17931781        | designation initializer                                       { $$ = $2->set_designators( $1 ); }
     
    19001888assertion_list_opt:                                                                             // CFA
    19011889        // empty
    1902                 { $$ = nullptr; }
     1890                { $$ = 0; }
    19031891        | assertion_list_opt assertion
    1904                 { $$ = $1 ? $1->appendList( $2 ) : $2; }
     1892                { $$ = $1 != 0 ? $1->appendList( $2 ) : $2; }
    19051893        ;
    19061894
     
    19141902                { $$ = $4; }
    19151903        | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')'
    1916                 { $$ = nullptr; }
     1904                { $$ = 0; }
    19171905        ;
    19181906
     
    20232011                {}                                                                                              // empty input file
    20242012        | external_definition_list
    2025                 { parseTree = parseTree ? parseTree->appendList( $1 ) : $1;     }
     2013                { parseTree = parseTree != nullptr ? parseTree->appendList( $1 ) : $1;  }
    20262014        ;
    20272015
     
    20292017        external_definition
    20302018        | external_definition_list push external_definition
    2031                 { $$ = $1 ? $1->appendList( $3 ) : $3; }
     2019                { $$ = $1 != nullptr ? $1->appendList( $3 ) : $3; }
    20322020        ;
    20332021
    20342022external_definition_list_opt:
    20352023        // empty
    2036                 { $$ = nullptr; }
     2024                { $$ = 0; }
    20372025        | external_definition_list
    20382026        ;
     
    21572145asm_name_opt:                                                                                   // GCC
    21582146        // empty
    2159                 { $$ = nullptr; }
    2160         | ASM '(' string_literal ')' attribute_list_opt
    2161                 { $$ = $3; }
     2147        | ASM '(' string_literal_list ')' attribute_list_opt { delete $3; }     // FIX ME: unimplemented
    21622148        ;
    21632149
    21642150attribute_list_opt:                                                                             // GCC
    21652151        // empty
    2166                 { $$ = nullptr; }
     2152                { $$ = 0; }
    21672153        | attribute_list
    21682154        ;
     
    21772163        ATTRIBUTE '(' '(' attribute_parameter_list ')' ')'
    21782164        //              { $$ = DeclarationNode::newQualifier( DeclarationNode::Attribute ); }
    2179                 { $$ = nullptr; }
     2165                { $$ = 0; }
    21802166        ;
    21812167
     
    28862872assignment_opt:
    28872873        // empty
    2888                 { $$ = nullptr; }
     2874                { $$ = 0; }
    28892875        | '=' assignment_expression
    28902876                { $$ = $2; }
Note: See TracChangeset for help on using the changeset viewer.