Ignore:
Timestamp:
Oct 25, 2018, 11:55:21 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
515a037
Parents:
9507ce3 (diff), ee27df2 (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 'shared_library' of plg.uwaterloo.ca:software/cfa/cfa-cc into shared_library

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r9507ce3 rcdc02f2  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 30 17:02:25 2018
    13 // Update Count     : 4029
     12// Last Modified On : Sun Oct 21 08:27:29 2018
     13// Update Count     : 4045
    1414//
    1515
     
    186186} // fieldDecl
    187187
    188 ExpressionNode *forInc( const OperKinds op ) {
    189         return new ExpressionNode( build_constantInteger( *new string( op == OperKinds::LThan || op == OperKinds::LEThan ? "1" : "-1" ) ) );
    190 } // forInc
    191 
    192188ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
    193189        ConstantExpr *constant = dynamic_cast<ConstantExpr *>(type->get_expr());
     
    198194                distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
    199195                new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ),
    200                 new ExpressionNode( build_binary_val( OperKinds::PlusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) );
     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 ) ) );
    201198} // forCtrl
    202199
     
    261258%token ZERO_T ONE_T                                                                             // CFA
    262259%token VALIST                                                                                   // GCC
    263 %token TYPEOF LABEL                                                                             // GCC
     260%token TYPEOF BASETYPEOF LABEL                                                  // GCC
    264261%token ENUM STRUCT UNION
    265262%token EXCEPTION                                                                                // CFA
     
    636633                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    637634        | postfix_expression ARROW no_attr_identifier
    638                 {
    639                         $$ = new ExpressionNode( build_pfieldSel( $1, *$3 == "0" || *$3 == "1" ? build_constantInteger( *$3 ) : build_varref( $3 ) ) );
    640                 }
     635                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    641636        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
    642637                { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); }
     
    11461141                        } else {
    11471142                                $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    1148                                                           OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan ) );
     1143                                                          OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    11491144                        } // if
    11501145                }
    11511146        | constant_expression inclexcl constant_expression      // CFA
    1152                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2 ) ); }
     1147                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11531148        | constant_expression inclexcl constant_expression '~' constant_expression // CFA
    11541149                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
     
    11621157                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    11631158                                        $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    1164                                                                   OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan ) );
     1159                                                                  OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    11651160                                } else {
    11661161                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     
    11741169                        } else {
    11751170                                if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) {
    1176                                         $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4 ) );
     1171                                        $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );
    11771172                                } else {
    11781173                                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr;
     
    18591854        | TYPEOF '(' comma_expression ')'                                       // GCC: typeof(a+b) y;
    18601855                { $$ = DeclarationNode::newTypeof( $3 ); }
     1856        | BASETYPEOF '(' type ')'                                                       // CFA: basetypeof(x) y;
     1857                { $$ = $3; }
     1858        | BASETYPEOF '(' comma_expression ')'                           // CFA: basetypeof(a+b) y;
     1859                { $$ = DeclarationNode::newTypeof( $3 ); }
    18611860        | ATTR_TYPEGENname '(' type ')'                                         // CFA: e.g., @type(x) y;
    18621861                { $$ = DeclarationNode::newAttr( $1, $3 ); }
Note: See TracChangeset for help on using the changeset viewer.