Changeset 15596d7 for src/Parser/ExpressionNode.cc
- Timestamp:
- Mar 14, 2023, 11:15:15 AM (16 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 9fa61f5
- Parents:
- 089a0d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
r089a0d7 r15596d7 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat May 16 13:17:07 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : T hr Mar 0 10:46:00202313 // Update Count : 108 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 09:10:22 2023 13 // Update Count : 1081 14 14 // 15 15 … … 122 122 if ( str[i] == '1' ) v |= 1; 123 123 i += 1; 124 124 if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break; 125 125 v <<= 1; 126 126 } // for … … 162 162 if ( isdigit( str[str.length() - 1] ) ) { // no suffix ? 163 163 lnthSuffix( str, type, ltype ); // could have length suffix 164 // At least one digit in integer constant,165 // so safe to backup while looking for suffix.166 // pointer value167 } else if ( auto posn = str.find_last_of( "pP" ) ; posn != string::npos ) {168 ltype = 5; str.erase( posn, 1 );169 // size_t170 } else if ( auto posn = str.find_last_of( "zZ" ) ; posn != string::npos ) {171 Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 );172 // signed char173 } else if ( auto posn = str.rfind( "hh" ) ; posn != string::npos ) {174 type = 1; str.erase( posn, 2 );175 // signed char176 } else if ( auto posn = str.rfind( "HH" ) ; posn != string::npos ) {177 type = 1; str.erase( posn, 2 );178 // short179 } else if ( auto posn = str.find_last_of( "hH" ) ; posn != string::npos ) {180 type = 0; str.erase( posn, 1 );181 // int (natural number)182 } else if ( auto posn = str.find_last_of( "nN" ) ; posn != string::npos ) {183 type = 2; str.erase( posn, 1 );184 } else if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) {185 type = 4;186 164 } else { 187 lnthSuffix( str, type, ltype ); 188 } 165 // At least one digit in integer constant, so safe to backup while looking for suffix. 166 string::size_type posn; 167 // pointer value 168 if ( posn = str.find_last_of( "pP" ); posn != string::npos ) { 169 ltype = 5; str.erase( posn, 1 ); 170 // size_t 171 } else if ( posn = str.find_last_of( "zZ" ); posn != string::npos ) { 172 Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 ); 173 // signed char 174 } else if ( posn = str.rfind( "hh" ); posn != string::npos ) { 175 type = 1; str.erase( posn, 2 ); 176 // signed char 177 } else if ( posn = str.rfind( "HH" ); posn != string::npos ) { 178 type = 1; str.erase( posn, 2 ); 179 // short 180 } else if ( posn = str.find_last_of( "hH" ); posn != string::npos ) { 181 type = 0; str.erase( posn, 1 ); 182 // int (natural number) 183 } else if ( posn = str.find_last_of( "nN" ); posn != string::npos ) { 184 type = 2; str.erase( posn, 1 ); 185 } else if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) { 186 type = 4; 187 } else { 188 lnthSuffix( str, type, ltype ); 189 } // if 190 } // if 189 191 190 192 // Cannot be just "0"/"1"; sscanf stops at the suffix, if any; value goes over the wall => always generate … … 208 210 sscanf( (char *)str2.c_str(), "%llx", &v2 ); 209 211 str = str.substr( 0, len - 16 ); 210 } 212 } // if 211 213 sscanf( (char *)str.c_str(), "%llx", &v ); 212 214 #endif // __SIZEOF_INT128__ … … 434 436 Type * strtype; 435 437 switch ( str[0] ) { // str has >= 2 characters, i.e, null string "" => safe to look at subscripts 0/1 436 case 'u':438 case 'u': 437 439 if ( str[1] == '8' ) goto Default; // utf-8 characters => array of char 438 440 // lookup type of associated typedef 439 441 strtype = new TypeInstType( Type::Qualifiers( ), "char16_t", false ); 440 442 break; 441 case 'U':443 case 'U': 442 444 strtype = new TypeInstType( Type::Qualifiers( ), "char32_t", false ); 443 445 break; 444 case 'L':446 case 'L': 445 447 strtype = new TypeInstType( Type::Qualifiers( ), "wchar_t", false ); 446 448 break; 447 Default: // char default string type448 default:449 Default: // char default string type 450 default: 449 451 strtype = new BasicType( Type::Qualifiers( ), BasicType::Char ); 450 452 } // switch … … 649 651 // Local Variables: // 650 652 // tab-width: 4 // 651 // mode: c++ //652 // compile-command: "make install" //653 653 // End: //
Note: See TracChangeset
for help on using the changeset viewer.