Changeset cc22003
- Timestamp:
- Aug 8, 2018, 10:57:58 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 3b2b37f
- Parents:
- b3763ca
- Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
rb3763ca rcc22003 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Jun 20 09:08:28201813 * Update Count : 68 212 * Last Modified On : Wed Aug 8 17:23:17 2018 13 * Update Count : 685 14 14 */ 15 15 … … 410 410 ">>=" { NAMEDOP_RETURN(RSassign); } 411 411 412 "~=" { NAMEDOP_RETURN(Erange); } // CFA 412 413 "@=" { NAMEDOP_RETURN(ATassign); } // CFA 413 414 -
src/Parser/parser.yy
rb3763ca rcc22003 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 4 09:38:36201813 // Update Count : 39 8612 // Last Modified On : Wed Aug 8 17:50:07 2018 13 // Update Count : 3998 14 14 // 15 15 … … 186 186 } // fieldDecl 187 187 188 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, ExpressionNode * comp, ExpressionNode * inc ) {188 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 189 189 return new ForCtrl( 190 190 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), 191 new ExpressionNode( build_binary_val( OperKinds::LThan, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ),191 new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ), 192 192 new ExpressionNode( build_binary_val( OperKinds::PlusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) ); 193 193 } // forCtrl … … 227 227 IfCtrl * ifctl; 228 228 ForCtrl * fctl; 229 enum OperKinds compop; 229 230 LabelNode * label; 230 231 InitializerNode * in; … … 289 290 %token ANDassign ERassign ORassign // &= ^= |= 290 291 292 %token Erange // ~= 291 293 %token ATassign // @= 292 294 … … 311 313 %type<ifctl> if_control_expression 312 314 %type<fctl> for_control_expression 315 %type<compop> inclexcl 313 316 %type<en> subrange 314 317 %type<decl> asm_name_opt … … 1135 1138 $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ); 1136 1139 } else { 1137 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), $1->clone(),1140 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $1->clone(), 1138 1141 new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1139 1142 } // if 1140 1143 } 1141 | constant_expression '~' constant_expression// CFA1142 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $ 3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }1143 | constant_expression '~'constant_expression '~' constant_expression // CFA1144 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $ 3, $5 ); }1144 | 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" ) ) ) ); } 1146 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1147 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } 1145 1148 | comma_expression_opt ';' comma_expression // CFA 1146 1149 { … … 1151 1154 } else { 1152 1155 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1153 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), $3->clone(),1156 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $3->clone(), 1154 1157 new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1155 1158 } else { … … 1158 1161 } // if 1159 1162 } 1160 | comma_expression_opt ';' constant_expression '~'constant_expression // CFA1163 | comma_expression_opt ';' constant_expression inclexcl constant_expression // CFA 1161 1164 { 1162 1165 if ( ! $1 ) { … … 1164 1167 } else { 1165 1168 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1166 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $ 5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) );1169 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1167 1170 } else { 1168 1171 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1170 1173 } // if 1171 1174 } 1172 | comma_expression_opt ';' constant_expression '~'constant_expression '~' constant_expression // CFA1175 | comma_expression_opt ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA 1173 1176 { 1174 1177 if ( ! $1 ) { … … 1176 1179 } else { 1177 1180 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1178 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $ 5, $7 );1181 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, $7 ); 1179 1182 } else { 1180 1183 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1186 1189 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1187 1190 { $$ = new ForCtrl( $1, $2, $4 ); } 1191 ; 1192 1193 inclexcl: 1194 '~' 1195 { $$ = OperKinds::LThan; } 1196 | Erange 1197 { $$ = OperKinds::LEThan; } 1188 1198 ; 1189 1199
Note: See TracChangeset
for help on using the changeset viewer.