Changeset 15596d7 for src/Parser


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

small formatting changes after Andrew's major updates

Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r089a0d7 r15596d7  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 25 12:15:40 2023
    13 // Update Count     : 1404
     12// Last Modified On : Tue Mar 14 08:54:13 2023
     13// Update Count     : 1405
    1414//
    1515
     
    600600        } else {
    601601                switch ( dst->kind ) {
    602                 case TypeData::Unknown:
     602                  case TypeData::Unknown:
    603603                        src->qualifiers |= dst->qualifiers;
    604604                        dst = src;
    605605                        src = nullptr;
    606606                        break;
    607                 case TypeData::Basic:
     607                  case TypeData::Basic:
    608608                        dst->qualifiers |= src->qualifiers;
    609609                        if ( src->kind != TypeData::Unknown ) {
     
    633633                        } // if
    634634                        break;
    635                 default:
     635                  default:
    636636                        switch ( src->kind ) {
    637                         case TypeData::Aggregate:
    638                         case TypeData::Enum:
     637                          case TypeData::Aggregate:
     638                          case TypeData::Enum:
    639639                                dst->base = new TypeData( TypeData::AggregateInst );
    640640                                dst->base->aggInst.aggregate = src;
     
    645645                                src = nullptr;
    646646                                break;
    647                         default:
     647                          default:
    648648                                if ( dst->forall ) {
    649649                                        dst->forall->appendList( src->forall );
     
    727727        assert( type );
    728728        switch ( type->kind ) {
    729         case TypeData::Symbolic:
     729          case TypeData::Symbolic:
    730730                if ( type->symbolic.assertions ) {
    731731                        type->symbolic.assertions->appendList( assertions );
     
    734734                } // if
    735735                break;
    736         default:
     736          default:
    737737                assert( false );
    738738        } // switch
     
    833833                if ( type ) {
    834834                        switch ( type->kind ) {
    835                         case TypeData::Aggregate:
    836                         case TypeData::Enum:
     835                          case TypeData::Aggregate:
     836                          case TypeData::Enum:
    837837                                p->type->base = new TypeData( TypeData::AggregateInst );
    838838                                p->type->base->aggInst.aggregate = type;
     
    843843                                break;
    844844
    845                         default:
     845                          default:
    846846                                p->type->base = type;
    847847                        } // switch
     
    865865
    866866DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) {
    867         if ( ! a ) return this;
     867  if ( ! a ) return this;
    868868        assert( a->type->kind == TypeData::Array );
    869869        TypeData * lastArray = findLast( a->type );
    870870        if ( type ) {
    871871                switch ( type->kind ) {
    872                 case TypeData::Aggregate:
    873                 case TypeData::Enum:
     872                  case TypeData::Aggregate:
     873                  case TypeData::Enum:
    874874                        lastArray->base = new TypeData( TypeData::AggregateInst );
    875875                        lastArray->base->aggInst.aggregate = type;
     
    879879                        lastArray->base->qualifiers |= type->qualifiers;
    880880                        break;
    881                 default:
     881                  default:
    882882                        lastArray->base = type;
    883883                } // switch
     
    12451245
    12461246        switch ( type->kind ) {
    1247         case TypeData::Enum:
    1248         case TypeData::Aggregate: {
    1249                 ReferenceToType * ret = buildComAggInst( type, attributes, linkage );
    1250                 buildList( type->aggregate.actuals, ret->get_parameters() );
    1251                 return ret;
    1252         }
    1253         case TypeData::Symbolic: {
    1254                 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false, attributes );
    1255                 buildList( type->symbolic.actuals, ret->get_parameters() );
    1256                 return ret;
    1257         }
    1258         default:
     1247          case TypeData::Enum:
     1248          case TypeData::Aggregate: {
     1249                  ReferenceToType * ret = buildComAggInst( type, attributes, linkage );
     1250                  buildList( type->aggregate.actuals, ret->get_parameters() );
     1251                  return ret;
     1252          }
     1253          case TypeData::Symbolic: {
     1254                  TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false, attributes );
     1255                  buildList( type->symbolic.actuals, ret->get_parameters() );
     1256                  return ret;
     1257          }
     1258          default:
    12591259                Type * simpletypes = typebuild( type );
    12601260                simpletypes->get_attributes() = attributes;             // copy because member is const
  • 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.