Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r6d01d89 re15853c  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 14 18:02:44 2019
    13 // Update Count     : 4216
     12// Last Modified On : Wed Feb 13 17:56:23 2019
     13// Update Count     : 4064
    1414//
    1515
     
    9999        // distribute declaration_specifier across all declared variables, e.g., static, const, __attribute__.
    100100        DeclarationNode * cur = declList, * cl = (new DeclarationNode)->addType( specifier );
    101         for ( cur = dynamic_cast<DeclarationNode *>( cur->get_next() ); cur != nullptr; cur = dynamic_cast<DeclarationNode *>( cur->get_next() ) ) {
     101        //cur->addType( specifier );
     102        for ( cur = dynamic_cast< DeclarationNode * >( cur->get_next() ); cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) {
    102103                cl->cloneBaseType( cur );
    103104        } // for
    104105        declList->addType( cl );
     106//      delete cl;
    105107        return declList;
    106108} // distAttr
     
    199201        if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->get_expr()) ) {
    200202                return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
    201         } else if ( CommaExpr * commaExpr = dynamic_cast<CommaExpr *>(index->get_expr()) ) {
    202                 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(commaExpr->arg1 ) ) {
    203                         return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
    204                 } else {
    205                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
    206                 } // if
    207203        } else {
    208204                SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
     
    267263%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    268264%token BOOL COMPLEX IMAGINARY                                                   // C99
    269 %token INT128 FLOAT80 FLOAT128                                                  // GCC
     265%token INT128 uuFLOAT80 uuFLOAT128                                              // GCC
     266%token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC
    270267%token ZERO_T ONE_T                                                                             // CFA
    271268%token VALIST                                                                                   // GCC
     
    328325%type<en> argument_expression_list              argument_expression                     default_initialize_opt
    329326%type<ifctl> if_control_expression
    330 %type<fctl> for_control_expression              for_control_expression_list
     327%type<fctl> for_control_expression
    331328%type<compop> inclexcl
    332329%type<en> subrange
     
    988985                // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER
    989986        identifier_or_type_name ':' attribute_list_opt statement
    990                 { $$ = $4->add_label( $1, $3 ); }
     987                {
     988                        $$ = $4->add_label( $1, $3 );
     989                }
    991990        ;
    992991
     
    10041003        statement_decl
    10051004        | statement_decl_list statement_decl
    1006                 { assert( $1 ); $1->set_last( $2 ); $$ = $1; }
     1005                { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
    10071006        ;
    10081007
     
    10111010                { $$ = new StatementNode( $1 ); }
    10121011        | EXTENSION declaration                                                         // GCC
    1013                 { distExt( $2 ); $$ = new StatementNode( $2 ); }
     1012                {
     1013                        distExt( $2 );
     1014                        $$ = new StatementNode( $2 );
     1015                }
    10141016        | function_definition
    10151017                { $$ = new StatementNode( $1 ); }
    10161018        | EXTENSION function_definition                                         // GCC
    1017                 { distExt( $2 ); $$ = new StatementNode( $2 ); }
     1019                {
     1020                        distExt( $2 );
     1021                        $$ = new StatementNode( $2 );
     1022                }
    10181023        | statement
    10191024        ;
     
    10221027        statement
    10231028        | statement_list_nodecl statement
    1024                 { assert( $1 ); $1->set_last( $2 ); $$ = $1; }
     1029                { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
    10251030        ;
    10261031
     
    11341139        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    11351140                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), $2 ) ); }
    1136         | FOR '(' push for_control_expression_list ')' statement pop
     1141        | FOR '(' push for_control_expression ')' statement pop
    11371142                { $$ = new StatementNode( build_for( $4, $6 ) ); }
    11381143        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
     
    11401145        ;
    11411146
    1142 for_control_expression_list:
    1143         for_control_expression
    1144         | for_control_expression_list ':' for_control_expression
    1145                 { $$ = $3; }
    1146         ;
    1147 
    11481147for_control_expression:
    1149         ';' comma_expression_opt ';' comma_expression_opt
    1150                 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); }
    1151         | comma_expression ';' comma_expression_opt ';' comma_expression_opt
    1152                 { $$ = new ForCtrl( $1, $3, $5 ); }
    1153         | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
    1154                 { $$ = new ForCtrl( $1, $2, $4 ); }
    1155         | comma_expression                                                                      // CFA
     1148        comma_expression                                                                        // CFA
    11561149                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11571150                                                OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1158         | comma_expression inclexcl comma_expression            // CFA
     1151        | constant_expression inclexcl constant_expression      // CFA
    11591152                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1160         | comma_expression inclexcl comma_expression '~' comma_expression // CFA
     1153        | constant_expression inclexcl constant_expression '~' constant_expression // CFA
    11611154                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
    11621155        | comma_expression ';' comma_expression                         // CFA
    11631156                { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11641157                                                OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1165         | comma_expression ';' comma_expression inclexcl comma_expression // CFA
     1158        | comma_expression ';' constant_expression inclexcl constant_expression // CFA
    11661159                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1167         | comma_expression ';' comma_expression inclexcl comma_expression '~' comma_expression // CFA
     1160        | comma_expression ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA
    11681161                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); }
     1162        | comma_expression ';' comma_expression_opt ';' comma_expression_opt
     1163                { $$ = new ForCtrl( $1, $3, $5 ); }
     1164        | ';' comma_expression_opt ';' comma_expression_opt
     1165                { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); }
     1166        | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
     1167                { $$ = new ForCtrl( $1, $2, $4 ); }
    11691168        ;
    11701169
     
    17731772        | FLOAT
    17741773                { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }
    1775         | FLOAT80
    1776                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); }
    1777         | FLOAT128
    1778                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); }
    17791774        | DOUBLE
    17801775                { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); }
     1776        | uuFLOAT80
     1777                { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat80 ); }
     1778        | uuFLOAT128
     1779                { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat128 ); }
     1780        | uFLOAT16
     1781                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat16 ); }
     1782        | uFLOAT32
     1783                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32 ); }
     1784        | uFLOAT32X
     1785                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32x ); }
     1786        | uFLOAT64
     1787                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64 ); }
     1788        | uFLOAT64X
     1789                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64x ); }
     1790        | uFLOAT128
     1791                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat128 ); }
    17811792        | COMPLEX                                                                                       // C99
    17821793                { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
Note: See TracChangeset for help on using the changeset viewer.