Changes in src/Parser/parser.yy [0982a056:cc22003]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r0982a056 rcc22003 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 30 17:02:25201813 // Update Count : 402912 // Last Modified On : Wed Aug 8 17:50:07 2018 13 // Update Count : 3998 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 } // forInc191 192 188 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 } // if197 189 return new ForCtrl( 198 190 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), … … 222 214 223 215 // Types declaration for productions 224 %union { 216 %union 217 { 225 218 Token tok; 226 219 ParseNode * pn; … … 297 290 %token ANDassign ERassign ORassign // &= ^= |= 298 291 299 %token Erange UpEq ErangeDown ErangeDownEq // ~= -~ -~=292 %token Erange // ~= 300 293 %token ATassign // @= 301 294 … … 1145 1138 $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ); 1146 1139 } else { 1147 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1148 OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan) );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" ) ) ) ); 1149 1142 } // if 1150 1143 } 1151 1144 | constant_expression inclexcl constant_expression // CFA 1152 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2) ); }1145 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1153 1146 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1154 1147 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } … … 1161 1154 } else { 1162 1155 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1163 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1164 OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan) );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" ) ) ) ); 1165 1158 } else { 1166 1159 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1174 1167 } else { 1175 1168 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1176 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4) );1169 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1177 1170 } else { 1178 1171 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1201 1194 '~' 1202 1195 { $$ = OperKinds::LThan; } 1203 | Erange UpEq1196 | Erange 1204 1197 { $$ = OperKinds::LEThan; } 1205 | ErangeDown1206 { $$ = OperKinds::GThan; }1207 | ErangeDownEq1208 { $$ = OperKinds::GEThan; }1209 1198 ; 1210 1199
Note:
See TracChangeset
for help on using the changeset viewer.