Ignore:
Timestamp:
Mar 12, 2019, 3:00:54 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
30e32b2, a2545593
Parents:
9d9a451 (diff), 91d6584 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge second draft of Aaron's thesis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r9d9a451 r53bb8f1  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  8 18:08:23 2018
    13 // Update Count     : 4052
     12// Last Modified On : Thu Feb 21 08:45:07 2019
     13// Update Count     : 4232
    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         //cur->addType( specifier );
    102         for ( cur = dynamic_cast< DeclarationNode * >( cur->get_next() ); cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) {
     101        for ( cur = dynamic_cast<DeclarationNode *>( cur->get_next() ); cur != nullptr; cur = dynamic_cast<DeclarationNode *>( cur->get_next() ) ) {
    103102                cl->cloneBaseType( cur );
    104103        } // for
    105104        declList->addType( cl );
    106 //      delete cl;
    107105        return declList;
    108106} // distAttr
     
    193191        return new ForCtrl(
    194192                distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
    195                 new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ),
    196                 new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto
    197                                                                                           OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) );
     193                // NULL comp/inc => leave blank
     194                comp ? new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ) : 0,
     195                inc ? new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto
     196                                                        OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) : 0 );
    198197} // forCtrl
    199198
     
    201200        if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->get_expr()) ) {
    202201                return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
     202        } else if ( CommaExpr * commaExpr = dynamic_cast<CommaExpr *>(index->get_expr()) ) {
     203                if ( NameExpr * identifier = dynamic_cast<NameExpr *>(commaExpr->arg1 ) ) {
     204                        return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
     205                } else {
     206                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
     207                } // if
    203208        } else {
    204209                SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
     
    263268%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    264269%token BOOL COMPLEX IMAGINARY                                                   // C99
    265 %token INT128 FLOAT80 FLOAT128                                                  // GCC
     270%token INT128 uuFLOAT80 uuFLOAT128                                              // GCC
     271%token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC
    266272%token ZERO_T ONE_T                                                                             // CFA
    267273%token VALIST                                                                                   // GCC
     
    324330%type<en> argument_expression_list              argument_expression                     default_initialize_opt
    325331%type<ifctl> if_control_expression
    326 %type<fctl> for_control_expression
     332%type<fctl> for_control_expression              for_control_expression_list
    327333%type<compop> inclexcl
    328334%type<en> subrange
     
    984990                // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER
    985991        identifier_or_type_name ':' attribute_list_opt statement
    986                 {
    987                         $$ = $4->add_label( $1, $3 );
    988                 }
     992                { $$ = $4->add_label( $1, $3 ); }
    989993        ;
    990994
     
    10021006        statement_decl
    10031007        | statement_decl_list statement_decl
    1004                 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
     1008                { assert( $1 ); $1->set_last( $2 ); $$ = $1; }
    10051009        ;
    10061010
     
    10091013                { $$ = new StatementNode( $1 ); }
    10101014        | EXTENSION declaration                                                         // GCC
    1011                 {
    1012                         distExt( $2 );
    1013                         $$ = new StatementNode( $2 );
    1014                 }
     1015                { distExt( $2 ); $$ = new StatementNode( $2 ); }
    10151016        | function_definition
    10161017                { $$ = new StatementNode( $1 ); }
    10171018        | EXTENSION function_definition                                         // GCC
    1018                 {
    1019                         distExt( $2 );
    1020                         $$ = new StatementNode( $2 );
    1021                 }
     1019                { distExt( $2 ); $$ = new StatementNode( $2 ); }
    10221020        | statement
    10231021        ;
     
    10261024        statement
    10271025        | statement_list_nodecl statement
    1028                 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
     1026                { assert( $1 ); $1->set_last( $2 ); $$ = $1; }
    10291027        ;
    10301028
     
    11381136        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    11391137                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), $2 ) ); }
    1140         | FOR '(' push for_control_expression ')' statement pop
     1138        | FOR '(' push for_control_expression_list ')' statement pop
    11411139                { $$ = new StatementNode( build_for( $4, $6 ) ); }
    11421140        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
     
    11441142        ;
    11451143
     1144for_control_expression_list:
     1145        for_control_expression
     1146        | for_control_expression_list ':' for_control_expression
     1147                { $$ = $3; }
     1148        ;
     1149
    11461150for_control_expression:
    1147         comma_expression                                                                        // CFA
     1151        ';' comma_expression_opt ';' comma_expression_opt
     1152                { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); }
     1153        | comma_expression ';' comma_expression_opt ';' comma_expression_opt
     1154                { $$ = new ForCtrl( $1, $3, $5 ); }
     1155        | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
     1156                { $$ = new ForCtrl( $1, $2, $4 ); }
     1157        | comma_expression                                                                      // CFA
    11481158                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11491159                                                OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1150         | constant_expression inclexcl constant_expression      // CFA
     1160        | comma_expression inclexcl comma_expression            // CFA
    11511161                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1152         | constant_expression inclexcl constant_expression '~' constant_expression // CFA
     1162        | comma_expression inclexcl comma_expression '~' comma_expression // CFA
    11531163                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
    11541164        | comma_expression ';' comma_expression                         // CFA
    11551165                { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11561166                                                OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1157         | comma_expression ';' constant_expression inclexcl constant_expression // CFA
     1167        | comma_expression ';' comma_expression inclexcl comma_expression // CFA
    11581168                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1159         | comma_expression ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA
     1169        | comma_expression ';' comma_expression inclexcl comma_expression '~' comma_expression // CFA
    11601170                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); }
    1161         | comma_expression ';' comma_expression_opt ';' comma_expression_opt
    1162                 { $$ = new ForCtrl( $1, $3, $5 ); }
    1163         | ';' comma_expression_opt ';' comma_expression_opt
    1164                 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); }
    1165         | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
    1166                 { $$ = new ForCtrl( $1, $2, $4 ); }
     1171        | comma_expression ';' comma_expression '~' '@' '~' comma_expression // CFA
     1172                { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::LThan, nullptr, $7 ); }
     1173        | comma_expression ';' comma_expression ErangeDown '@' '~' comma_expression // CFA
     1174                { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::GThan, nullptr, $7 ); }
     1175        | comma_expression ';' comma_expression '~' '@' '~' '@' // CFA
     1176                { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::LThan, nullptr, nullptr ); }
    11671177        ;
    11681178
     
    17711781        | FLOAT
    17721782                { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }
    1773         | FLOAT80
    1774                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); }
    1775         | FLOAT128
    1776                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); }
    17771783        | DOUBLE
    17781784                { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); }
     1785        | uuFLOAT80
     1786                { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat80 ); }
     1787        | uuFLOAT128
     1788                { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat128 ); }
     1789        | uFLOAT16
     1790                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat16 ); }
     1791        | uFLOAT32
     1792                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32 ); }
     1793        | uFLOAT32X
     1794                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32x ); }
     1795        | uFLOAT64
     1796                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64 ); }
     1797        | uFLOAT64X
     1798                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64x ); }
     1799        | uFLOAT128
     1800                { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat128 ); }
    17791801        | COMPLEX                                                                                       // C99
    17801802                { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
Note: See TracChangeset for help on using the changeset viewer.