Changeset 515a037 for src/Parser/parser.yy
- Timestamp:
- Dec 12, 2018, 3:52:19 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:
- 1b8f13f0
- Parents:
- cdc02f2 (diff), 85acec94 (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
rcdc02f2 r515a037 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Oct 21 08:27:29201813 // Update Count : 40 4512 // Last Modified On : Thu Nov 8 18:08:23 2018 13 // Update Count : 4052 14 14 // 15 15 … … 187 187 188 188 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 189 ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->get_expr());189 ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->get_expr()); 190 190 if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) { 191 191 type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) ); 192 192 } // if 193 193 return new ForCtrl( 194 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),194 distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), 195 195 new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ), 196 196 new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 197 197 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) ); 198 <<<<<<< HEAD 199 ======= 200 } // forCtrl 201 202 ForCtrl * forCtrl( ExpressionNode * type, ExpressionNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 203 if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->get_expr()) ) { 204 return forCtrl( type, new string( identifier->name ), start, compop, comp, inc ); 205 } else { 206 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr; 207 } // if 208 >>>>>>> master 198 209 } // forCtrl 199 210 … … 1132 1143 | FOR '(' push for_control_expression ')' statement pop 1133 1144 { $$ = new StatementNode( build_for( $4, $6 ) ); } 1145 | FOR '(' ')' statement // CFA => for ( ;; ) 1146 { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), $4 ) ); } 1134 1147 ; 1135 1148 1136 1149 for_control_expression: 1150 <<<<<<< HEAD 1137 1151 comma_expression_opt // CFA 1138 1152 { … … 1144 1158 } // if 1145 1159 } 1160 ======= 1161 comma_expression // CFA 1162 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1163 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1164 >>>>>>> master 1146 1165 | constant_expression inclexcl constant_expression // CFA 1147 1166 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1148 1167 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1149 1168 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } 1169 <<<<<<< HEAD 1150 1170 | comma_expression_opt ';' comma_expression // CFA 1151 1171 { … … 1188 1208 } 1189 1209 | comma_expression_opt ';' comma_expression_opt ';' comma_expression_opt 1210 ======= 1211 | comma_expression ';' comma_expression // CFA 1212 { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1213 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1214 | comma_expression ';' constant_expression inclexcl constant_expression // CFA 1215 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1216 | comma_expression ';' constant_expression inclexcl constant_expression '~' constant_expression // CFA 1217 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); } 1218 | comma_expression ';' comma_expression_opt ';' comma_expression_opt 1219 >>>>>>> master 1190 1220 { $$ = new ForCtrl( $1, $3, $5 ); } 1221 | ';' comma_expression_opt ';' comma_expression_opt 1222 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); } 1191 1223 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1192 1224 { $$ = new ForCtrl( $1, $2, $4 ); } … … 1850 1882 1851 1883 indirect_type: 1852 TYPEOF '(' type ')' // GCC: typeof( x) y;1884 TYPEOF '(' type ')' // GCC: typeof( x ) y; 1853 1885 { $$ = $3; } 1854 | TYPEOF '(' comma_expression ')' // GCC: typeof( a+b) y;1886 | TYPEOF '(' comma_expression ')' // GCC: typeof( a+b ) y; 1855 1887 { $$ = DeclarationNode::newTypeof( $3 ); } 1888 <<<<<<< HEAD 1856 1889 | BASETYPEOF '(' type ')' // CFA: basetypeof(x) y; 1857 1890 { $$ = $3; } … … 1859 1892 { $$ = DeclarationNode::newTypeof( $3 ); } 1860 1893 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type(x) y; 1894 ======= 1895 | BASETYPEOF '(' type ')' // CFA: basetypeof( x ) y; 1896 { $$ = DeclarationNode::newTypeof( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ), true ); } 1897 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof( a+b ) y; 1898 { $$ = DeclarationNode::newTypeof( $3, true ); } 1899 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type( x ) y; 1900 >>>>>>> master 1861 1901 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1862 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type( a+b) y;1902 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type( a+b ) y; 1863 1903 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1864 1904 | ZERO_T // CFA
Note: See TracChangeset
for help on using the changeset viewer.