Changeset d69f4bb4
- Timestamp:
- Aug 29, 2018, 6:09:48 PM (6 years ago)
- 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:
- 933933c
- Parents:
- bcb14b5
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
rbcb14b5 rd69f4bb4 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Aug 8 17:23:17201813 * Update Count : 68 512 * Last Modified On : Wed Aug 29 15:02:41 2018 13 * Update Count : 686 14 14 */ 15 15 … … 410 410 ">>=" { NAMEDOP_RETURN(RSassign); } 411 411 412 "~=" { NAMEDOP_RETURN(Erange); } // CFA413 412 "@=" { NAMEDOP_RETURN(ATassign); } // CFA 413 "~=" { NAMEDOP_RETURN(ErangeUpEq); } // CFA 414 "-~" { NAMEDOP_RETURN(ErangeDown); } // CFA 415 "-~=" { NAMEDOP_RETURN(ErangeDownEq); } // CFA 414 416 415 417 /* CFA, operator identifier */ -
src/Parser/parser.yy
rbcb14b5 rd69f4bb4 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 8 17:50:07 201813 // Update Count : 399812 // Last Modified On : Wed Aug 29 16:44:17 2018 13 // Update Count : 4006 14 14 // 15 15 … … 186 186 } // fieldDecl 187 187 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 188 192 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 189 193 return new ForCtrl( … … 290 294 %token ANDassign ERassign ORassign // &= ^= |= 291 295 292 %token Erange //~=296 %token ErangeUpEq ErangeDown ErangeDownEq // ~= -~ -~= 293 297 %token ATassign // @= 294 298 … … 1138 1142 $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ); 1139 1143 } 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" ) )) );1144 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1145 OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan ) ); 1142 1146 } // if 1143 1147 } 1144 1148 | 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" ) )) ); }1149 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2 ) ); } 1146 1150 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1147 1151 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } … … 1154 1158 } else { 1155 1159 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" ) )) );1160 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1161 OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan ) ); 1158 1162 } else { 1159 1163 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1167 1171 } else { 1168 1172 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" ) )) );1173 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4 ) ); 1170 1174 } else { 1171 1175 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1194 1198 '~' 1195 1199 { $$ = OperKinds::LThan; } 1196 | Erange 1200 | ErangeUpEq 1197 1201 { $$ = OperKinds::LEThan; } 1202 | ErangeDown 1203 { $$ = OperKinds::GThan; } 1204 | ErangeDownEq 1205 { $$ = OperKinds::GEThan; } 1198 1206 ; 1199 1207 -
tests/.expect/forctrl.txt
rbcb14b5 rd69f4bb4 2 2 empty 3 3 empty 4 X X X X X X X X X X 5 Y Y Y Y Y 6 Z Z Z Z Z 4 A A A A A A A A A A 5 B B B B B 6 C C C C C 7 D D D D D 8 E E E E E 7 9 0 1 2 3 4 5 6 7 8 9 8 10 0 1 2 3 4 5 6 7 8 9 11 2 4 6 8 10 12 10 8 6 4 2 9 13 0.5 1.5 2.5 3.5 4.5 14 5.5 4.5 3.5 2.5 1.5 10 15 2 4 6 8 10 11 2 4 6 8 10 16 10 8 6 4 2 12 17 3 6 9 13 18 (0 0)(1 1)(2 2)(3 3)(4 4)(5 5)(6 6)(7 7)(8 8)(9 9) -
tests/forctrl.c
rbcb14b5 rd69f4bb4 10 10 // Created On : Wed Aug 8 18:32:59 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 16 09:25:47201813 // Update Count : 612 // Last Modified On : Wed Aug 29 18:04:15 2018 13 // Update Count : 26 14 14 // 15 15 … … 33 33 do { sout | "empty"; break; } while (); sout | endl; 34 34 for () { sout | "empty"; break; } sout | endl; 35 for ( 10 ) { sout | "X"; } sout | endl; 36 for ( 0.5 ~ 5.5 ) { sout | "Y"; } sout | endl; 37 for ( 2 ~= 10 ~ 2 ) { sout | "Z"; } sout | endl; 35 36 for ( 10 ) { sout | "A"; } sout | endl; 37 38 for ( 2 ~= 10 ~ 2 ) { sout | "B"; } sout | endl; 39 for ( 10 -~= 2 ~ -2 ) { sout | "C"; } sout | endl; 40 for ( 0.5 ~ 5.5 ) { sout | "D"; } sout | endl; 41 for ( 5.5 -~ 0.5 ) { sout | "E"; } sout | endl; 42 38 43 for ( i; 10 ) { sout | i; } sout | endl; 39 44 for ( j; 10 ) { sout | j; } sout | endl; 45 46 //for ( i; 1 ~= 10 ~ 2 ) { sout | i; } sout | endl; 47 for ( i; 2 ~= 10 ~ 2 ) { sout | i; } sout | endl; 48 for ( i; 10 -~= 2 ~ -2 ) { sout | i; } sout | endl; 40 49 for ( i; 0.5 ~ 5.5 ) { sout | i; } sout | endl; 41 for ( i; 2 ~= 10 ~ 2 ) { sout | i; } sout | endl; 50 for ( i; 5.5 -~ 0.5 ) { sout | i; } sout | endl; 51 42 52 for ( ui; 2u ~= 10u ~ 2u ) { sout | ui; } sout | endl; 53 for ( ui; 10u -~= 2u ~ -2u ) { sout | ui; } sout | endl; 54 43 55 int start = 3, comp = 10, inc = 2; 44 56 for ( i; start ~ comp ~ inc + 1 ) { sout | i; } sout | endl;
Note: See TracChangeset
for help on using the changeset viewer.