Changeset bedb40e for src/Parser/parser.yy
- Timestamp:
- Sep 10, 2018, 5:17:34 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:
- 67982887, 9fce933a
- Parents:
- 0cf9ffd (diff), e15ba975 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r0cf9ffd rbedb40e 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:07201813 // Update Count : 399812 // Last Modified On : Thu Aug 30 17:02:25 2018 13 // Update Count : 4029 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 ) { 193 ConstantExpr *constant = dynamic_cast<ConstantExpr *>(type->get_expr()); 194 if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) { 195 type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) ); 196 } // if 189 197 return new ForCtrl( 190 198 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), … … 214 222 215 223 // Types declaration for productions 216 %union 217 { 224 %union { 218 225 Token tok; 219 226 ParseNode * pn; … … 290 297 %token ANDassign ERassign ORassign // &= ^= |= 291 298 292 %token Erange //~=299 %token ErangeUpEq ErangeDown ErangeDownEq // ~= -~ -~= 293 300 %token ATassign // @= 294 301 … … 1138 1145 $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ); 1139 1146 } 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" ) )) );1147 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1148 OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan ) ); 1142 1149 } // if 1143 1150 } 1144 1151 | 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" ) )) ); }1152 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2 ) ); } 1146 1153 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1147 1154 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } … … 1154 1161 } else { 1155 1162 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" ) )) );1163 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1164 OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan ) ); 1158 1165 } else { 1159 1166 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1167 1174 } else { 1168 1175 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" ) )) );1176 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4 ) ); 1170 1177 } else { 1171 1178 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1194 1201 '~' 1195 1202 { $$ = OperKinds::LThan; } 1196 | Erange 1203 | ErangeUpEq 1197 1204 { $$ = OperKinds::LEThan; } 1205 | ErangeDown 1206 { $$ = OperKinds::GThan; } 1207 | ErangeDownEq 1208 { $$ = OperKinds::GEThan; } 1198 1209 ; 1199 1210
Note: See TracChangeset
for help on using the changeset viewer.