Changes in src/Parser/parser.yy [ee27df2:0982a056]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
ree27df2 r0982a056 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 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 ) { 189 193 ConstantExpr *constant = dynamic_cast<ConstantExpr *>(type->get_expr()); … … 194 198 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), 195 199 new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ), 196 new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 197 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) ); 200 new ExpressionNode( build_binary_val( OperKinds::PlusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) ); 198 201 } // forCtrl 199 202 … … 258 261 %token ZERO_T ONE_T // CFA 259 262 %token VALIST // GCC 260 %token TYPEOF BASETYPEOF LABEL// GCC263 %token TYPEOF LABEL // GCC 261 264 %token ENUM STRUCT UNION 262 265 %token EXCEPTION // CFA … … 633 636 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 634 637 | postfix_expression ARROW no_attr_identifier 635 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 638 { 639 $$ = new ExpressionNode( build_pfieldSel( $1, *$3 == "0" || *$3 == "1" ? build_constantInteger( *$3 ) : build_varref( $3 ) ) ); 640 } 636 641 | postfix_expression ARROW INTEGERconstant // CFA, tuple index 637 642 { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); } … … 1141 1146 } else { 1142 1147 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1143 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) )) );1148 OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan ) ); 1144 1149 } // if 1145 1150 } 1146 1151 | constant_expression inclexcl constant_expression // CFA 1147 { $$ = 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 ) ); } 1148 1153 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1149 1154 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } … … 1157 1162 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1158 1163 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1159 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) )) );1164 OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan ) ); 1160 1165 } else { 1161 1166 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1169 1174 } else { 1170 1175 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1171 $$ = 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 ) ); 1172 1177 } else { 1173 1178 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1854 1859 | TYPEOF '(' comma_expression ')' // GCC: typeof(a+b) y; 1855 1860 { $$ = DeclarationNode::newTypeof( $3 ); } 1856 | BASETYPEOF '(' type ')' // CFA: basetypeof(x) y;1857 { $$ = $3; }1858 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof(a+b) y;1859 { $$ = DeclarationNode::newTypeof( $3 ); }1860 1861 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type(x) y; 1861 1862 { $$ = DeclarationNode::newAttr( $1, $3 ); }
Note:
See TracChangeset
for help on using the changeset viewer.