Changeset 67d4e37
- Timestamp:
- Apr 13, 2019, 3:51:58 PM (6 years ago)
- Branches:
- ADT, 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:
- b0ccd1c
- Parents:
- 25773cd
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r25773cd r67d4e37 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 13 17:36:49201913 // Update Count : 8 6712 // Last Modified On : Sat Apr 13 15:44:20 2019 13 // Update Count : 873 14 14 // 15 15 … … 132 132 void printOneLine( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {} 133 133 134 Expression * get_expr() const { return expr.get(); }134 Expression * get_expr() const { return expr.get(); } 135 135 template<typename T> 136 136 bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); } 137 137 138 138 Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); } 139 140 std::unique_ptr<Expression> expr; // public because of lifetime implications 139 141 private: 140 142 bool extension = false; 141 std::unique_ptr<Expression> expr;142 143 }; // ExpressionNode 143 144 -
src/Parser/parser.yy
r25773cd r67d4e37 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 15 14:25:43201913 // Update Count : 42 4812 // Last Modified On : Sat Apr 13 14:00:24 2019 13 // Update Count : 4285 14 14 // 15 15 … … 334 334 %type<en> subrange 335 335 %type<decl> asm_name_opt 336 %type<en> asm_operands_opt asm_operands_listasm_operand336 %type<en> asm_operands_opt asm_operands_list asm_operand 337 337 %type<label> label_list 338 338 %type<en> asm_clobbers_list_opt 339 339 %type<flag> asm_volatile_opt 340 340 %type<en> handler_predicate_opt 341 %type<genexpr> generic_association 341 %type<genexpr> generic_association generic_assoc_list 342 342 343 343 // statements … … 1164 1164 for_control_expression 1165 1165 | for_control_expression_list ':' for_control_expression 1166 { $$ = $3; } 1166 // ForCtrl + ForCtrl: 1167 // init + init => multiple declaration statements that are hoisted 1168 // condition + condition => (expression) && (expression) 1169 // change + change => (expression), (expression) 1170 { 1171 $1->init->set_last( $3->init ); 1172 if ( $1->condition ) { 1173 if ( $3->condition ) { 1174 $1->condition->expr.reset( new LogicalExpr( $1->condition->expr.release(), $3->condition->expr.release(), true ) ); 1175 } // if 1176 } else $1->condition = $3->condition; 1177 if ( $1->change ) { 1178 if ( $3->change ) { 1179 $1->change->expr.reset( new CommaExpr( $1->change->expr.release(), $3->change->expr.release() ) ); 1180 } // if 1181 } else $1->change = $3->change; 1182 $$ = $1; 1183 } 1167 1184 ; 1168 1185 … … 1174 1191 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1175 1192 { $$ = new ForCtrl( $1, $2, $4 ); } 1193 1176 1194 | comma_expression // CFA 1177 1195 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), … … 1188 1206 | comma_expression ';' comma_expression inclexcl comma_expression '~' comma_expression // CFA 1189 1207 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); } 1208 1209 // There is a S/R conflicit if ~ and -~ are factored out. 1210 | comma_expression ';' comma_expression '~' '@' // CFA 1211 { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::LThan, nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1212 | comma_expression ';' comma_expression ErangeDown '@' // CFA 1213 { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::GThan, nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1190 1214 | comma_expression ';' comma_expression '~' '@' '~' comma_expression // CFA 1191 1215 { $$ = forCtrl( $3, $1, $3->clone(), OperKinds::LThan, nullptr, $7 ); } -
tests/.expect/loopctrl.txt
r25773cd r67d4e37 19 19 10 8 6 4 2 20 20 21 1 2 3 4 5 6 7 8 9 10 22 10 9 8 7 6 5 4 3 2 1 0 21 23 2 4 6 8 10 22 24 2.1 3.8 5.5 7.2 8.9 … … 42 44 (10 10)(9 9)(8 8)(7 7)(6 6)(5 5)(4 4)(3 3)(2 2)(1 1)(0 0) 43 45 (10 10)(9 9)(8 8)(7 7)(6 6)(5 5)(4 4)(3 3)(2 2)(1 1)(0 0) 46 47 0 -5 1 -4 2 -3 3 -2 4 -1 5 0 6 1 7 2 8 3 9 4 48 0 -5 1 -6 2 -7 3 -8 4 -9 5 -10 6 -11 7 -12 8 -13 9 -14 49 0 -5 1 -3 2 -1 3 1 4 3 5 5 6 7 7 9 8 11 9 13 50 0 -5 1 -7 2 -9 3 -11 4 -13 5 -15 6 -17 7 -19 8 -21 9 -23 51 52 0 -5 1 -4 2 -3 3 -2 4 -1 5 0 6 1 7 2 8 3 9 4 53 0 -5 1 -6 2 -7 3 -8 4 -9 5 -10 6 -11 7 -12 8 -13 9 -14 54 0 -5 1 -3 2 -1 3 1 4 3 5 5 6 7 7 9 8 11 9 13 55 0 -5 1 -7 2 -9 3 -11 4 -13 5 -15 6 -17 7 -19 8 -21 9 -23 56 57 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 5 -15 6.5 6 -17 7.5 7 -19 8.5 8 -21 9.5 9 -23 10.5 58 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 5 -15 6.5 6 -17 7.5 7 -19 8.5 8 -21 9.5 9 -23 10.5 59 0 -5 1.5 1 -7 2.5 2 -9 3.5 3 -11 4.5 4 -13 5.5 5 -15 6.5 6 -17 7.5 7 -19 8.5 8 -21 9.5 9 -23 10.5 -
tests/loopctrl.cfa
r25773cd r67d4e37 10 10 // Created On : Wed Aug 8 18:32:59 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 21 08:54:47201913 // Update Count : 8612 // Last Modified On : Sat Apr 13 11:03:09 2019 13 // Update Count : 104 14 14 // 15 15 … … 56 56 for ( ui; 10u -~= 2u ~ 2u ) { sout | ui; } sout | nl | nl; 57 57 58 // @ means do nothing 59 for ( i; 1 ~ @ ) { 60 if ( i > 10 ) break; 61 sout | i; 62 } sout | nl; 63 for ( i; 10 -~ @ ) { 64 if ( i < 0 ) break; 65 sout | i; 66 } sout | nl; 58 67 for ( i; 2 ~ @ ~ 2 ) { 59 68 if ( i > 10 ) break; … … 94 103 for ( s; (S){10,10} -~ (S){0} ~ (S){1} ) { sout | s; } sout | nl; 95 104 for ( s; (S){10,10} -~= (S){0} ) { sout | s; } sout | nl; 96 for ( s; (S){10,10} -~= (S){0} ~ (S){1} ) { sout | s; } sout | nl; 105 for ( s; (S){10,10} -~= (S){0} ~ (S){1} ) { sout | s; } sout | nl | nl; 106 107 for ( i; 10 : j; -5 ~ @ ) { sout | i | j; } sout | nl; 108 for ( i; 10 : j; -5 -~ @ ) { sout | i | j; } sout | nl; 109 for ( i; 10 : j; -5 ~ @ ~ 2 ) { sout | i | j; } sout | nl; 110 for ( i; 10 : j; -5 -~ @ ~ 2 ) { sout | i | j; } sout | nl | nl; 111 112 for ( j; -5 ~ @ : i; 10 ) { sout | i | j; } sout | nl; 113 for ( j; -5 -~ @ : i; 10 ) { sout | i | j; } sout | nl; 114 for ( j; -5 ~ @ ~ 2 : i; 10 ) { sout | i | j; } sout | nl; 115 for ( j; -5 -~ @ ~ 2 : i; 10 ) { sout | i | j; } sout | nl | nl; 116 117 for ( j; -5 -~ @ ~ 2 : i; 10 : k; 1.5 ~ @ ) { sout | i | j | k; } sout | nl; 118 for ( j; -5 -~ @ ~ 2 : k; 1.5 ~ @ : i; 10 ) { sout | i | j | k; } sout | nl; 119 for ( k; 1.5 ~ @ : j; -5 -~ @ ~ 2 : i; 10 ) { sout | i | j | k; } sout | nl; 97 120 } 98 121
Note: See TracChangeset
for help on using the changeset viewer.