Changeset 6165ce7 for src/Parser
- Timestamp:
- Jul 27, 2017, 12:37:31 PM (7 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- a04ce4d
- Parents:
- 7bd1bb5
- Location:
- src/Parser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
r7bd1bb5 r6165ce7 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:17:07 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : T us Jul 25 10:11:00 201713 // Update Count : 55 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 27 12:10:10 2017 13 // Update Count : 556 14 14 // 15 15 … … 62 62 bool dec = true, Unsigned = false; // decimal, unsigned constant 63 63 int size; // 0 => int, 1 => long, 2 => long long 64 unsigned long long int v; 64 unsigned long long int v; // converted integral value 65 65 size_t last = str.length() - 1; // last character of constant 66 66 Expression * ret; 67 68 // special constants 69 if ( str == "0" ) { 70 ret = new ConstantExpr( Constant( (Type *)new ZeroType( noQualifiers ), str, (unsigned long long int)0 ) ); 71 goto CLEANUP; 72 } // if 73 if ( str == "1" ) { 74 ret = new ConstantExpr( Constant( (Type *)new OneType( noQualifiers ), str, (unsigned long long int)1 ) ); 75 goto CLEANUP; 76 } // if 77 67 78 if ( str[0] == '0' ) { // octal/hex constant ? 68 79 dec = false; … … 118 129 } // if 119 130 120 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) ); 131 ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) ); 132 CLEANUP: 121 133 delete &str; // created by lex 122 134 return ret; … … 174 186 return ret; 175 187 } // build_constantStr 176 177 Expression *build_constantZeroOne( const std::string & str ) {178 Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( noQualifiers ) : (Type*)new OneType( noQualifiers ), str,179 str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );180 delete &str; // created by lex181 return ret;182 } // build_constantChar183 188 184 189 Expression * build_field_name_FLOATINGconstant( const std::string & str ) { -
src/Parser/ParseNode.h
r7bd1bb5 r6165ce7 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : T us Jul 25 10:09:00201713 // Update Count : 78 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 27 12:08:08 2017 13 // Update Count : 788 14 14 // 15 15 … … 159 159 Expression * build_constantFloat( const std::string &str ); 160 160 Expression * build_constantChar( const std::string &str ); 161 Expression * build_constantZeroOne( const std::string &str );162 161 ConstantExpr * build_constantStr( const std::string &str ); 163 162 Expression * build_field_name_FLOATINGconstant( const std::string & str ); -
src/Parser/lex.ll
r7bd1bb5 r6165ce7 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Mon Jul 24 08:27:23201713 * Update Count : 54 512 * Last Modified On : Thu Jul 27 12:05:50 2017 13 * Update Count : 549 14 14 */ 15 15 … … 288 288 289 289 /* numeric constants */ 290 "0" { NUMERIC_RETURN(ZERO); } // CFA291 "1" { NUMERIC_RETURN(ONE); } // CFA292 290 {decimal_constant} { NUMERIC_RETURN(INTEGERconstant); } 293 291 {octal_constant} { NUMERIC_RETURN(INTEGERconstant); } -
src/Parser/parser.yy
r7bd1bb5 r6165ce7 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 // Last Modified By : Andrew Beach12 // Last Modified On : T us Jul 25 10:07:00201713 // Update Count : 246 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 27 12:08:08 2017 13 // Update Count : 2467 14 14 // 15 15 … … 142 142 // converted into the tuple index (.)(1). e.g., 3.x 143 143 %token<tok> REALDECIMALconstant REALFRACTIONconstant FLOATINGconstant 144 %token<tok> ZERO ONE // CFA145 144 146 145 // multi-character operators … … 159 158 %token ATassign // @= 160 159 161 %type<tok> identifier no_attr_identifier zero_one160 %type<tok> identifier no_attr_identifier 162 161 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name attr_name 163 162 %type<constant> string_literal … … 360 359 ; 361 360 362 zero_one: // CFA363 ZERO364 | ONE365 ;366 367 361 string_literal: 368 362 string_literal_list { $$ = build_constantStr( *$1 ); } … … 384 378 IDENTIFIER // typedef name cannot be used as a variable name 385 379 { $$ = new ExpressionNode( build_varref( $1 ) ); } 386 | zero_one387 { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); }388 380 | tuple 389 381 | '(' comma_expression ')' … … 484 476 { 485 477 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); 486 }487 | zero_one fraction_constants488 {489 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );490 478 } 491 479 ;
Note: See TracChangeset
for help on using the changeset viewer.