Changeset cdc02f2 for src/Parser
- Timestamp:
- Oct 25, 2018, 11:55:21 AM (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:
- 515a037
- Parents:
- 9507ce3 (diff), ee27df2 (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. - Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
r9507ce3 rcdc02f2 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Aug 29 15:02:41201813 * Update Count : 68 612 * Last Modified On : Sat Oct 20 09:42:45 2018 13 * Update Count : 687 14 14 */ 15 15 … … 209 209 __attribute__ { KEYWORD_RETURN(ATTRIBUTE); } // GCC 210 210 auto { KEYWORD_RETURN(AUTO); } 211 basetypeof { KEYWORD_RETURN(BASETYPEOF); } // CFA 211 212 _Bool { KEYWORD_RETURN(BOOL); } // C99 212 213 break { KEYWORD_RETURN(BREAK); } -
src/Parser/parser.yy
r9507ce3 rcdc02f2 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 : 40 2912 // Last Modified On : Sun Oct 21 08:27:29 2018 13 // Update Count : 4045 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 189 ConstantExpr *constant = dynamic_cast<ConstantExpr *>(type->get_expr()); … … 198 194 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), 199 195 new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ), 200 new ExpressionNode( build_binary_val( OperKinds::PlusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) ); 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 ) ) ); 201 198 } // forCtrl 202 199 … … 261 258 %token ZERO_T ONE_T // CFA 262 259 %token VALIST // GCC 263 %token TYPEOF LABEL// GCC260 %token TYPEOF BASETYPEOF LABEL // GCC 264 261 %token ENUM STRUCT UNION 265 262 %token EXCEPTION // CFA … … 636 633 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 637 634 | postfix_expression ARROW no_attr_identifier 638 { 639 $$ = new ExpressionNode( build_pfieldSel( $1, *$3 == "0" || *$3 == "1" ? build_constantInteger( *$3 ) : build_varref( $3 ) ) ); 640 } 635 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 641 636 | postfix_expression ARROW INTEGERconstant // CFA, tuple index 642 637 { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); } … … 1146 1141 } else { 1147 1142 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1148 OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan) );1143 OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1149 1144 } // if 1150 1145 } 1151 1146 | constant_expression inclexcl constant_expression // CFA 1152 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2) ); }1147 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); } 1153 1148 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1154 1149 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } … … 1162 1157 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1163 1158 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1164 OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan) );1159 OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1165 1160 } else { 1166 1161 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1174 1169 } else { 1175 1170 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1176 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4) );1171 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); 1177 1172 } else { 1178 1173 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1859 1854 | TYPEOF '(' comma_expression ')' // GCC: typeof(a+b) y; 1860 1855 { $$ = 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 ); } 1861 1860 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type(x) y; 1862 1861 { $$ = DeclarationNode::newAttr( $1, $3 ); }
Note: See TracChangeset
for help on using the changeset viewer.