Changeset 455a7d5 for src/Parser


Ignore:
Timestamp:
Aug 9, 2018, 6:35:02 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
ea5b7d6
Parents:
fb975a50 (diff), 0c827019 (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 branch 'master' into jenkins-sandbox

Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    rfb975a50 r455a7d5  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 20 14:56:30 2018
    13 // Update Count     : 850
     12// Last Modified On : Sat Aug  4 09:39:40 2018
     13// Update Count     : 853
    1414//
    1515
     
    132132        void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}
    133133
     134        Expression *get_expr() const { return expr.get(); }
    134135        template<typename T>
    135136        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
     
    390391Statement * build_expr( ExpressionNode * ctl );
    391392
    392 struct IfCtl {
    393         IfCtl( DeclarationNode * decl, ExpressionNode * condition ) :
     393struct IfCtrl {
     394        IfCtrl( DeclarationNode * decl, ExpressionNode * condition ) :
    394395                init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {}
    395396
     
    398399};
    399400
    400 struct ForCtl {
    401         ForCtl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
     401struct ForCtrl {
     402        ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) :
    402403                init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {}
    403         ForCtl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
     404        ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) :
    404405                init( new StatementNode( decl ) ), condition( condition ), change( change ) {}
    405406
     
    409410};
    410411
    411 Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init );
    412 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
     412Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init );
     413Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    413414Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    414415Statement * build_case( ExpressionNode * ctl );
    415416Statement * build_default();
    416 Statement * build_while( IfCtl * ctl, StatementNode * stmt );
     417Statement * build_while( IfCtrl * ctl, StatementNode * stmt );
    417418Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt );
    418 Statement * build_for( ForCtl * forctl, StatementNode * stmt );
     419Statement * build_for( ForCtrl * forctl, StatementNode * stmt );
    419420Statement * build_branch( BranchStmt::Type kind );
    420421Statement * build_branch( std::string * identifier, BranchStmt::Type kind );
  • src/Parser/StatementNode.cc

    rfb975a50 r455a7d5  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun  5 08:58:34 2018
    13 // Update Count     : 362
     12// Last Modified On : Sat Aug  4 09:39:25 2018
     13// Update Count     : 363
    1414//
    1515
     
    7878} // build_expr
    7979
    80 Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init ) {
     80Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init ) {
    8181        if ( ctl->init != 0 ) {
    8282                buildMoveList( ctl->init, init );
     
    100100} // build_if_control
    101101
    102 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
     102Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {
    103103        Statement * thenb, * elseb = nullptr;
    104104        std::list< Statement * > branches;
     
    145145} // build_default
    146146
    147 Statement * build_while( IfCtl * ctl, StatementNode * stmt ) {
     147Statement * build_while( IfCtrl * ctl, StatementNode * stmt ) {
    148148        std::list< Statement * > branches;
    149149        buildMoveList< Statement, StatementNode >( stmt, branches );
     
    164164} // build_do_while
    165165
    166 Statement * build_for( ForCtl * forctl, StatementNode * stmt ) {
     166Statement * build_for( ForCtrl * forctl, StatementNode * stmt ) {
    167167        std::list< Statement * > branches;
    168168        buildMoveList< Statement, StatementNode >( stmt, branches );
  • src/Parser/lex.ll

    rfb975a50 r455a7d5  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Wed Jun 20 09:08:28 2018
    13  * Update Count     : 682
     12 * Last Modified On : Wed Aug  8 17:23:17 2018
     13 * Update Count     : 685
    1414 */
    1515
     
    410410">>="                   { NAMEDOP_RETURN(RSassign); }
    411411
     412"~="                    { NAMEDOP_RETURN(Erange); }                             // CFA
    412413"@="                    { NAMEDOP_RETURN(ATassign); }                   // CFA
    413414
  • src/Parser/module.mk

    rfb975a50 r455a7d5  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk -- 
     8## module.mk --
    99##
    1010## Author           : Peter A. Buhr
     
    3131       Parser/parserutility.cc
    3232
    33 MAINTAINERCLEANFILES += Parser/parser.output
     33MOSTLYCLEANFILES += Parser/parser.hh Parser/parser.output
  • src/Parser/parser.yy

    rfb975a50 r455a7d5  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 25 15:54:35 2018
    13 // Update Count     : 3841
     12// Last Modified On : Wed Aug  8 17:50:07 2018
     13// Update Count     : 3998
    1414//
    1515
     
    186186} // fieldDecl
    187187
     188ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     189        return new ForCtrl(
     190                distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
     191                new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ),
     192                new ExpressionNode( build_binary_val( OperKinds::PlusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) );
     193} // forCtrl
     194
     195
    188196bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
    189197
     
    217225        WaitForStmt * wfs;
    218226        Expression * constant;
    219         IfCtl * ifctl;
    220         ForCtl * fctl;
     227        IfCtrl * ifctl;
     228        ForCtrl * fctl;
     229        enum OperKinds compop;
    221230        LabelNode * label;
    222231        InitializerNode * in;
     
    281290%token ANDassign        ERassign        ORassign                                // &=   ^=      |=
    282291
     292%token Erange                                                                                   // ~=
    283293%token ATassign                                                                                 // @=
    284294
     
    303313%type<ifctl> if_control_expression
    304314%type<fctl> for_control_expression
     315%type<compop> inclexcl
    305316%type<en> subrange
    306317%type<decl> asm_name_opt
     
    10491060if_control_expression:
    10501061        comma_expression
    1051                 { $$ = new IfCtl( nullptr, $1 ); }
     1062                { $$ = new IfCtrl( nullptr, $1 ); }
    10521063        | c_declaration                                                                         // no semi-colon
    1053                 { $$ = new IfCtl( $1, nullptr ); }
     1064                { $$ = new IfCtrl( $1, nullptr ); }
    10541065        | cfa_declaration                                                                       // no semi-colon
    1055                 { $$ = new IfCtl( $1, nullptr ); }
     1066                { $$ = new IfCtrl( $1, nullptr ); }
    10561067        | declaration comma_expression                                          // semi-colon separated
    1057                 { $$ = new IfCtl( $1, $2 ); }
     1068                { $$ = new IfCtrl( $1, $2 ); }
    10581069        ;
    10591070
     
    11111122        WHILE '(' push if_control_expression ')' statement pop
    11121123                { $$ = new StatementNode( build_while( $4, $6 ) ); }
     1124        | WHILE '(' ')' statement                                                       // CFA => while ( 1 )
     1125                { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), $4 ) ); }
    11131126        | DO statement WHILE '(' comma_expression ')' ';'
    11141127                { $$ = new StatementNode( build_do_while( $5, $2 ) ); }
     1128        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
     1129                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), $2 ) ); }
    11151130        | FOR '(' push for_control_expression ')' statement pop
    11161131                { $$ = new StatementNode( build_for( $4, $6 ) ); }
     
    11181133
    11191134for_control_expression:
    1120         comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
    1121                 { $$ = new ForCtl( $1, $3, $5 ); }
    1122         | declaration comma_expression_opt ';' comma_expression_opt // C99
    1123                 { $$ = new ForCtl( $1, $2, $4 ); }
     1135        comma_expression_opt                                                            // CFA
     1136                {
     1137                        if ( ! $1 ) {                                                           // => for ( ;; )
     1138                                $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr );
     1139                        } else {
     1140                                $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $1->clone(),
     1141                                                         new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
     1142                        } // if
     1143                }
     1144        | constant_expression inclexcl constant_expression      // CFA
     1145                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1146        | constant_expression inclexcl constant_expression '~' constant_expression // CFA
     1147                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
     1148        | comma_expression_opt ';' comma_expression                     // CFA
     1149                {
     1150                        if ( ! $1 ) {
     1151                                SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
     1152                        } else if ( ! $3 ) {
     1153                                SemanticError( yylloc, "Missing loop range." ); $$ = nullptr;
     1154                        } else {
     1155                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
     1156                                        $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $3->clone(),
     1157                                                                 new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
     1158                                } else {
     1159                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     1160                                } // if
     1161                        } // if
     1162                }
     1163        | comma_expression_opt ';' constant_expression inclexcl constant_expression // CFA
     1164                {
     1165                        if ( ! $1 ) {
     1166                                SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
     1167                        } else {
     1168                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
     1169                                        $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
     1170                                } else {
     1171                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     1172                                } // if
     1173                        } // if
     1174                }
     1175        | comma_expression_opt ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA
     1176                {
     1177                        if ( ! $1 ) {
     1178                                SemanticError( yylloc, "Missing loop index." ); $$ = nullptr;
     1179                        } else {
     1180                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
     1181                                        $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, $7 );
     1182                                } else {
     1183                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     1184                                } // if
     1185                        } // if
     1186                }
     1187        | comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt
     1188                { $$ = new ForCtrl( $1, $3, $5 ); }
     1189        | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';'
     1190                { $$ = new ForCtrl( $1, $2, $4 ); }
     1191        ;
     1192
     1193inclexcl:
     1194        '~'
     1195                { $$ = OperKinds::LThan; }
     1196        | Erange
     1197                { $$ = OperKinds::LEThan; }
    11241198        ;
    11251199
Note: See TracChangeset for help on using the changeset viewer.