Ignore:
Timestamp:
Mar 14, 2023, 11:15:15 AM (16 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master
Children:
9fa61f5
Parents:
089a0d7
Message:

small formatting changes after Andrew's major updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    r089a0d7 r15596d7  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Mar  0 10:46:00 2023
    13 // Update Count     : 1080
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Mar 14 09:10:22 2023
     13// Update Count     : 1081
    1414//
    1515
     
    122122                if ( str[i] == '1' ) v |= 1;
    123123                i += 1;
    124                 if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break;
     124          if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break;
    125125                v <<= 1;
    126126        } // for
     
    162162        if ( isdigit( str[str.length() - 1] ) ) {                       // no suffix ?
    163163                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 value
    167         } else if ( auto posn = str.find_last_of( "pP" ) ; posn != string::npos ) {
    168                 ltype = 5; str.erase( posn, 1 );
    169         // size_t
    170         } 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 char
    173         } else if ( auto posn = str.rfind( "hh" ) ; posn != string::npos ) {
    174                 type = 1; str.erase( posn, 2 );
    175         // signed char
    176         } else if ( auto posn = str.rfind( "HH" ) ; posn != string::npos ) {
    177                 type = 1; str.erase( posn, 2 );
    178         // short
    179         } 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;
    186164        } 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
    189191
    190192        // Cannot be just "0"/"1"; sscanf stops at the suffix, if any; value goes over the wall => always generate
     
    208210                                        sscanf( (char *)str2.c_str(), "%llx", &v2 );
    209211                                        str = str.substr( 0, len - 16 );
    210                                 }
     212                                } // if
    211213                                sscanf( (char *)str.c_str(), "%llx", &v );
    212214#endif // __SIZEOF_INT128__
     
    434436        Type * strtype;
    435437        switch ( str[0] ) {                                                                     // str has >= 2 characters, i.e, null string "" => safe to look at subscripts 0/1
    436         case 'u':
     438          case 'u':
    437439                if ( str[1] == '8' ) goto Default;                              // utf-8 characters => array of char
    438440                // lookup type of associated typedef
    439441                strtype = new TypeInstType( Type::Qualifiers( ), "char16_t", false );
    440442                break;
    441         case 'U':
     443          case 'U':
    442444                strtype = new TypeInstType( Type::Qualifiers( ), "char32_t", false );
    443445                break;
    444         case 'L':
     446          case 'L':
    445447                strtype = new TypeInstType( Type::Qualifiers( ), "wchar_t", false );
    446448                break;
    447         Default:                                                                                        // char default string type
    448         default:
     449          Default:                                                                                      // char default string type
     450          default:
    449451                strtype = new BasicType( Type::Qualifiers( ), BasicType::Char );
    450452        } // switch
     
    649651// Local Variables: //
    650652// tab-width: 4 //
    651 // mode: c++ //
    652 // compile-command: "make install" //
    653653// End: //
Note: See TracChangeset for help on using the changeset viewer.