Changeset ba01b14


Ignore:
Timestamp:
Feb 11, 2019, 6:46:56 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
cdcddfe1
Parents:
0e66857
Message:

update constant parsing add _FloatNN

Location:
src/Parser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r0e66857 rba01b14  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 20:54:26 2018
    13 // Update Count     : 1108
     12// Last Modified On : Fri Feb  1 16:49:17 2019
     13// Update Count     : 1113
    1414//
    1515
     
    4141
    4242// These must harmonize with the corresponding DeclarationNode enumerations.
    43 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "int128", "float80", "float128", "NoBasicTypeNames" };
    44 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" };
     43const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "int128",
     44                                                                                                   "float", "double", "long double", "float80", "float128",
     45                                                                                                   "_float16", "_float32", "_float32x", "_float64", "_float64x", "_float128", "_float128x", "NoBasicTypeNames" };
     46const char * DeclarationNode::complexTypeNames[] = { "_Complex", "NoComplexTypeNames", "_Imaginary" }; // Imaginary unsupported => parse, but make invisible and print error message
    4547const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" };
    4648const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" };
  • src/Parser/ExpressionNode.cc

    r0e66857 rba01b14  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  4 21:24:45 2018
    13 // Update Count     : 802
     12// Last Modified On : Thu Feb  7 22:35:29 2019
     13// Update Count     : 900
    1414//
    1515
     
    5151extern const Type::Qualifiers noQualifiers;                             // no qualifiers on constants
    5252
    53 static inline bool checkH( char c ) { return c == 'h' || c == 'H'; }
    54 static inline bool checkL( char c ) { return c == 'l' || c == 'L'; }
    55 static inline bool checkZ( char c ) { return c == 'z' || c == 'Z'; }
    56 static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
     53// static inline bool checkH( char c ) { return c == 'h' || c == 'H'; }
     54// static inline bool checkZ( char c ) { return c == 'z' || c == 'Z'; }
     55// static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
    5756static inline bool checkF( char c ) { return c == 'f' || c == 'F'; }
    5857static inline bool checkD( char c ) { return c == 'd' || c == 'D'; }
     58static inline bool checkF80( char c ) { return c == 'w' || c == 'W'; }
     59static inline bool checkL( char c ) { return c == 'l' || c == 'L'; }
     60static inline bool checkF128( char c ) { return c == 'q' || c == 'Q'; }
    5961static inline bool checkI( char c ) { return c == 'i' || c == 'I'; }
    6062static inline bool checkB( char c ) { return c == 'b' || c == 'B'; }
    6163static inline bool checkX( char c ) { return c == 'x' || c == 'X'; }
    6264
    63 static const char * lnthsInt[2][6] = {
    64         { "int8_t", "int16_t", "int32_t", "int64_t", "size_t", },
    65         { "uint8_t", "uint16_t", "uint32_t", "uint64_t", "size_t", }
    66 }; // lnthsInt
    67 
    68 static inline void checkLNInt( string & str, int & lnth, int & size ) {
    69         string::size_type posn = str.find_first_of( "lL" ), start = posn;
    70   if ( posn == string::npos ) return;
    71         size = 4;                                                                                       // assume largest size
    72         posn += 1;                                                                                      // advance to size
    73         if ( str[posn] == '8' ) {                                                       // 8
    74                 lnth = 0;
    75         } else if ( str[posn] == '1' ) {
    76                 posn += 1;
    77                 if ( str[posn] == '6' ) {                                               // 16
    78                         lnth = 1;
    79                 } else {                                                                                // 128
    80                         posn += 1;
    81                         lnth = 5;
    82                 } // if
    83         } else {
    84                 if ( str[posn] == '3' ) {                                               // 32
    85                         lnth = 2;
    86                 } else if ( str[posn] == '6' ) {                                // 64
    87                         lnth = 3;
    88                 } else {
    89                         assertf( false, "internal error, bad integral length %s", str.c_str() );
    90                 } // if
    91                 posn += 1;
    92         } // if
    93         str.erase( start, posn - start + 1 );                           // remove length suffix
    94 } // checkLNInt
    95 
    9665Expression * build_constantInteger( string & str ) {
    9766        static const BasicType::Kind kind[2][6] = {
    98                 // short (h) must be before char (hh)
     67                // short (h) must be before char (hh) because shorter type has the longer suffix
    9968                { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt128, },
    10069                { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, },
    10170        };
    10271
     72        static const char * lnthsInt[2][5] = {
     73                { "int16_t",  "int8_t",  "int32_t",  "int64_t",  "size_t", },
     74                { "uint16_t", "uint8_t", "uint32_t", "uint64_t", "size_t", },
     75        }; // lnthsInt
     76
    10377        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
    104         int size;                                                                                       // 0 => short, 1 => char, 2 => int, 3 => long int, 4 => long long int, 5 => int128
    105         int lnth = -1;                                                                          // literal length
     78        int type = -1;                                                                          // 0 => short, 1 => char, 2 => int, 3 => long int, 4 => long long int, 5 => int128
     79        int ltype = -1;                                                                         // literal length
    10680
    10781        unsigned long long int v;                                                       // converted integral value
     
    127101                        //printf( "%llx %llu\n", v, v );
    128102                } else if ( checkB( str[1] ) ) {                                // binary constant ?
    129                         v = 0;
    130                         for ( unsigned int i = 2;; i += 1 ) {           // compute value
     103                        v = 0;                                                                          // compute value
     104                        for ( unsigned int i = 2;; ) {
    131105                                if ( str[i] == '1' ) v |= 1;
    132                           if ( i == last ) break;
     106                                i += 1;
     107                          if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break;
    133108                                v <<= 1;
    134109                        } // for
    135                         //printf( "%llx %llu\n", v, v );
     110                        //printf( "%#llx %llu\n", v, v );
    136111                } else {                                                                                // octal constant
    137112                        sscanf( (char *)str.c_str(), "%llo", &v );
    138                         //printf( "%llo %llu\n", v, v );
     113                        //printf( "%#llo %llu\n", v, v );
    139114                } // if
    140115        } else {                                                                                        // decimal constant ?
     
    143118        } // if
    144119
    145         if ( v <= INT_MAX ) {                                                           // signed int
    146                 size = 2;
    147         } else if ( v <= UINT_MAX && ! dec ) {                          // unsigned int
    148                 size = 2;
    149                 Unsigned = true;                                                                // unsigned
    150         } else if ( v <= LONG_MAX ) {                                           // signed long int
    151                 size = 3;
    152         } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int
    153                 size = 3;
    154                 Unsigned = true;                                                                // unsigned long int
    155         } else if ( v <= LLONG_MAX ) {                                          // signed long long int
    156                 size = 4;
    157         } else {                                                                                        // unsigned long long int
    158                 size = 4;
    159                 Unsigned = true;                                                                // unsigned long long int
    160         } // if
    161 
    162120        // At least one digit in integer constant, so safe to backup while looking for suffix.
    163121
    164         if ( checkU( str[last] ) ) {                                            // suffix 'u' ?
    165                 Unsigned = true;
    166                 if ( checkL( str[last - 1] ) ) {                                // suffix 'l' ?
    167                         size = 3;
    168                         if ( checkL( str[last - 2] ) ) {                        // suffix "ll" ?
    169                                 size = 4;
     122        string::size_type posn;
     123
     124        if ( str.find_last_of( "uU" ) != string::npos ) Unsigned = true;
     125
     126        posn = str.rfind( "hh" );
     127        if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; }
     128
     129        posn = str.rfind( "HH" );
     130        if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; }
     131
     132        posn = str.find_last_of( "hH" );
     133        if ( posn != string::npos ) { type = 0; str.erase( posn, 1 ); goto FINI; }
     134
     135        posn = str.find_last_of( "zZ" );
     136        if ( posn != string::npos ) { Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 ); goto FINI; }
     137
     138        if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) { type = 4; goto FINI; }
     139
     140        posn = str.find_last_of( "lL" );
     141        if ( posn != string::npos ) {
     142                type = 3;                                                                               // default
     143                posn += 1;                                                                              // advance to size
     144                if ( str[posn] == '3' ) {                                               // 32
     145                        type = ltype = 2; str.erase( posn, 2 );
     146                } else if ( str[posn] == '6' ) {                                // 64
     147                        type = ltype = 3; str.erase( posn, 2 );
     148                } else if ( str[posn] == '8' ) {                                // 8
     149                        type = ltype = 1; str.erase( posn, 1 );
     150                } else if ( str[posn] == '1' ) {
     151                        if ( str[posn + 1] == '6' ) {                           // 16
     152                                type = ltype = 0; str.erase( posn, 2 );
     153                        } else {                                                                        // 128
     154                                type = ltype = 5; str.erase( posn, 3 );
    170155                        } // if
    171                 } else if ( checkH( str[last - 1] ) ) {                 // suffix 'h' ?
    172                         size = 0;
    173                         if ( checkH( str[last - 2] ) ) {                        // suffix "hh" ?
    174                                 size = 1;
    175                         } // if
    176                         str.erase( last - size - 1, size + 1 );         // remove 'h'/"hh"
    177                 } else {                                                                                // suffix "ln" ?
    178                         checkLNInt( str, lnth, size );
    179                 } // if
    180         } else if ( checkL( str[ last ] ) ) {                           // suffix 'l' ?
    181                 size = 3;
    182                 if ( checkL( str[last - 1] ) ) {                                // suffix 'll' ?
    183                         size = 4;
    184                         if ( checkU( str[last - 2] ) ) {                        // suffix 'u' ?
    185                                 Unsigned = true;
    186                         } // if
    187                 } else if ( checkU( str[last - 1] ) ) {                 // suffix 'u' ?
    188                         Unsigned = true;
    189                 } // if
    190         } else if ( checkH( str[ last ] ) ) {                           // suffix 'h' ?
    191                 size = 0;
    192                 if ( checkH( str[last - 1] ) ) {                                // suffix "hh" ?
    193                         size = 1;
    194                         if ( checkU( str[last - 2] ) ) {                        // suffix 'u' ?
    195                                 Unsigned = true;
    196                         } // if
    197                 } else if ( checkU( str[last - 1] ) ) {                 // suffix 'u' ?
    198                         Unsigned = true;
    199                 } // if
    200                 str.erase( last - size, size + 1 );                             // remove 'h'/"hh"
    201         } else if ( checkZ( str[last] ) ) {                                     // suffix 'z' ?
    202                 lnth = 4;
    203                 str.erase( last, 1 );                                                   // remove 'z'
    204         } else {                                                                                        // suffix "ln" ?
    205                 checkLNInt( str, lnth, size );
    206         } // if
    207 
    208         assert( 0 <= size && size < 6 );
     156                } // if
     157        } // if
     158  FINI:
     159
     160        if ( type == -1 ) {                                                                     // no suffix type, use value
     161                if ( v <= INT_MAX ) {                                                   // signed int
     162                        type = 2;
     163                } else if ( v <= UINT_MAX && ! dec ) {                  // unsigned int
     164                        type = 2;
     165                        Unsigned = true;                                                        // unsigned
     166                } else if ( v <= LONG_MAX ) {                                   // signed long int
     167                        type = 3;
     168                } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int
     169                        type = 3;
     170                        Unsigned = true;                                                        // unsigned long int
     171                } else if ( v <= LLONG_MAX ) {                                  // signed long long int
     172                        type = 4;
     173                } else {                                                                                // unsigned long long int
     174                        type = 4;
     175                        Unsigned = true;                                                        // unsigned long long int
     176                } // if
     177        } // if
     178
     179        assert( 0 <= type && type < 6 );
    209180        // Constant type is correct for overload resolving.
    210         ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
    211         if ( Unsigned && size < 2 ) {                                           // hh or h, less than int ?
     181        ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][type] ), str, v ) );
     182        if ( Unsigned && type < 2 ) {                                           // hh or h, less than int ?
    212183                // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values.
    213                 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false );
    214         } else if ( lnth != -1 ) {                                                      // explicit length ?
    215                 if ( lnth == 5 ) {                                                              // int128 ?
    216                         size = 5;
    217                         ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false );
     184                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][type] ), false );
     185        } else if ( ltype != -1 ) {                                                     // explicit length ?
     186                if ( ltype == 5 ) {                                                             // int128 ?
     187                        type = 5;
     188                        ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][type] ), false );
    218189                } else {
    219                         ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ), false );
     190                        ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][ltype], false ), false );
    220191                } // if
    221192        } // if
     
    227198
    228199
    229 static inline void checkLNFloat( string & str, int & lnth, int & size ) {
    230         string::size_type posn = str.find_first_of( "lL" ), start = posn;
     200static inline void checkFnxFloat( string & str, size_t last, bool & explnth, int & type ) {
     201        string::size_type posn;
     202        // floating-point constant has minimum of 2 characters, 1. or .1, so safe to look ahead
     203        if ( str[1] == 'x' ) {                                                          // hex ?
     204                posn = str.find_last_of( "pP" );                                // back for exponent (must have)
     205                posn = str.find_first_of( "fF", posn + 1 );             // forward for size (fF allowed in hex constant)
     206        } else {
     207                posn = str.find_last_of( "fF" );                                // back for size (fF not allowed)
     208        } // if
    231209  if ( posn == string::npos ) return;
    232         size = 2;                                                                                       // assume largest size
    233         lnth = 0;
     210        explnth = true;
    234211        posn += 1;                                                                                      // advance to size
    235212        if ( str[posn] == '3' ) {                                                       // 32
    236                 size = 0;
     213                if ( str[last] != 'x' ) type = 6;
     214                else type = 7;
    237215        } else if ( str[posn] == '6' ) {                                        // 64
    238                 size = 1;
    239         } else if ( str[posn] == '8' || str[posn] == '1' ) { // 80, 128
    240                 size = 2;
    241                 if ( str[posn] == '1' ) posn += 1;
     216                if ( str[last] != 'x' ) type = 8;
     217                else type = 9;
     218        } else if ( str[posn] == '8' ) {                                        // 80
     219                type = 3;
     220        } else if ( str[posn] == '1' ) {                                        // 16/128
     221                if ( str[posn + 1] == '6' ) {                                   // 16
     222                        type = 5;
     223                } else {                                                                                // 128
     224                        if ( str[last] != 'x' ) type = 10;
     225                        else type = 11;
     226                } // if
    242227        } else {
    243228                assertf( false, "internal error, bad floating point length %s", str.c_str() );
    244229        } // if
    245         posn += 1;
    246         str.erase( start, posn - start + 1 );                           // remove length suffix
    247 } // checkLNFloat
     230} // checkFnxFloat
    248231
    249232
    250233Expression * build_constantFloat( string & str ) {
    251         static const BasicType::Kind kind[2][3] = {
    252                 { BasicType::Float, BasicType::Double, BasicType::LongDouble },
    253                 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex },
     234        static const BasicType::Kind kind[2][12] = {
     235                { BasicType::Float, BasicType::Double, BasicType::LongDouble, BasicType::__float80, BasicType::__float128, BasicType::_Float16, BasicType::_Float32, BasicType::_Float32x, BasicType::_Float64, BasicType::_Float64x, BasicType::_Float128, BasicType::_Float128x },
     236                { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, (BasicType::Kind)-1, (BasicType::Kind)-1, BasicType::_Float16Complex, BasicType::_Float32Complex, BasicType::_Float32xComplex, BasicType::_Float64Complex, BasicType::_Float64xComplex, BasicType::_Float128Complex, BasicType::_Float128xComplex },
    254237        };
    255238
    256         bool complx = false;                                                            // real, complex
    257         int size = 1;                                                                           // 0 => float, 1 => double, 2 => long double
    258         int lnth = -1;                                                                          // literal length
    259         // floating-point constant has minimum of 2 characters: 1. or .1
     239        // floating-point constant has minimum of 2 characters 1. or .1
    260240        size_t last = str.length() - 1;
    261241        double v;
     242        int type;                                                                                       // 0 => float, 1 => double, 3 => long double, ...
     243        bool complx = false;                                                            // real, complex
     244        bool explnth = false;                                                           // explicit literal length
    262245
    263246        sscanf( str.c_str(), "%lg", &v );
     
    269252
    270253        if ( checkF( str[last] ) ) {                                            // float ?
    271                 size = 0;
     254                type = 0;
    272255        } else if ( checkD( str[last] ) ) {                                     // double ?
    273                 size = 1;
     256                type = 1;
    274257        } else if ( checkL( str[last] ) ) {                                     // long double ?
    275                 size = 2;
     258                type = 2;
     259        } else if ( checkF80( str[last] ) ) {                           // __float80 ?
     260                type = 3;
     261        } else if ( checkF128( str[last] ) ) {                          // __float128 ?
     262                type = 4;
    276263        } else {
    277                 size = 1;                                                                               // double (default)
    278                 checkLNFloat( str, lnth, size );
    279         } // if
     264                type = 1;                                                                               // double (default if no suffix)
     265                checkFnxFloat( str, last, explnth, type );
     266        } // if
     267
    280268        if ( ! complx && checkI( str[last - 1] ) ) {            // imaginary ?
    281269                complx = true;
    282270        } // if
    283271
    284         assert( 0 <= size && size < 3 );
    285         Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) );
    286         if ( lnth != -1 ) {                                                                     // explicit length ?
    287                 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ), false );
     272        assert( 0 <= type && type < 12 );
     273        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][type] ), str, v ) );
     274        if ( explnth ) {                                                                        // explicit length ?
     275                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][type] ), false );
    288276        } // if
    289277
  • src/Parser/ParseNode.h

    r0e66857 rba01b14  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 20:54:53 2018
    13 // Update Count     : 854
     12// Last Modified On : Fri Feb  1 16:48:10 2019
     13// Update Count     : 866
    1414//
    1515
     
    206206class DeclarationNode : public ParseNode {
    207207  public:
    208         // These enumerations must harmonize with their names.
    209         enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, Int128, Float80, Float128, NoBasicType };
     208        // These enumerations must harmonize with their names in DeclarationNode.cc.
     209        enum BasicType { Void, Bool, Char, Int, Int128,
     210                                         Float, Double, LongDouble, Float80, Float128,
     211                                         _Float16, _Float32, _Float32x, _Float64, _Float64x, _Float128, _Float128x, NoBasicType };
    210212        static const char * basicTypeNames[];
    211         enum ComplexType { Complex, Imaginary, NoComplexType };
     213        enum ComplexType { Complex, NoComplexType, Imaginary }; // Imaginary unsupported => parse, but make invisible and print error message
    212214        static const char * complexTypeNames[];
    213215        enum Signedness { Signed, Unsigned, NoSignedness };
  • src/Parser/TypeData.cc

    r0e66857 rba01b14  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov  2 07:54:26 2018
    13 // Update Count     : 624
     12// Last Modified On : Fri Feb  8 09:36:26 2019
     13// Update Count     : 645
    1414//
    1515
     
    629629                } // if
    630630
    631                 ret = BasicType::Bool;
     631                ret = BasicType::_Bool;
    632632                break;
    633633
     
    666666
    667667          case DeclarationNode::Float:
     668          case DeclarationNode::Double:
     669          case DeclarationNode::LongDouble:                                     // not set until below
    668670          case DeclarationNode::Float80:
    669671          case DeclarationNode::Float128:
    670           case DeclarationNode::Double:
    671           case DeclarationNode::LongDouble:                                     // not set until below
    672                 static BasicType::Kind floattype[3][3] = {
    673                         { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex },
    674                         { BasicType::FloatImaginary, BasicType::DoubleImaginary, BasicType::LongDoubleImaginary },
    675                         { BasicType::Float, BasicType::Double, BasicType::LongDouble },
     672          case DeclarationNode::_Float16:
     673          case DeclarationNode::_Float32:
     674          case DeclarationNode::_Float32x:
     675          case DeclarationNode::_Float64:
     676          case DeclarationNode::_Float64x:
     677          case DeclarationNode::_Float128:
     678          case DeclarationNode::_Float128x:
     679                static BasicType::Kind floattype[2][12] = {
     680                        { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, (BasicType::Kind)-1, (BasicType::Kind)-1, BasicType::_Float16Complex, BasicType::_Float32Complex, BasicType::_Float32xComplex, BasicType::_Float64Complex, BasicType::_Float64xComplex, BasicType::_Float128Complex, BasicType::_Float128xComplex, },
     681                        { BasicType::Float, BasicType::Double, BasicType::LongDouble, BasicType::__float80, BasicType::__float128, BasicType::_Float16, BasicType::_Float32, BasicType::_Float32x, BasicType::_Float64, BasicType::_Float64x, BasicType::_Float128, BasicType::_Float128x, },
    676682                };
    677683
     
    686692                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    687693                } // if
     694                if ( td->complextype == DeclarationNode::Imaginary ) {
     695                        genTSError( DeclarationNode::complexTypeNames[ td->complextype ], td->basictype );
     696                } // if
     697                if ( (td->basictype == DeclarationNode::Float80 || td->basictype == DeclarationNode::Float128) && td->complextype == DeclarationNode::Complex ) { // gcc unsupported
     698                        genTSError( DeclarationNode::complexTypeNames[ td->complextype ], td->basictype );
     699                } // if
    688700                if ( td->length == DeclarationNode::Long ) {
    689701                        const_cast<TypeData *>(td)->basictype = DeclarationNode::LongDouble;
    690702                } // if
    691703
    692                 if ( td->basictype == DeclarationNode::Float80 || td->basictype == DeclarationNode::Float128 ) {
    693                         // if ( td->complextype != DeclarationNode::NoComplexType ) {
    694                         //      genTSError( DeclarationNode::complexTypeNames[ td->complextype ], td->basictype );
    695                         // }
    696                         if ( td->basictype == DeclarationNode::Float80 ) ret = BasicType::Float80;
    697                         else ret = BasicType::Float128;
    698                         break;
    699                 }
    700 
    701704                ret = floattype[ td->complextype ][ td->basictype - DeclarationNode::Float ];
     705                //printf( "XXXX %d %d %d %d\n", td->complextype, td->basictype, DeclarationNode::Float, ret );
    702706                break;
    703707
  • src/Parser/lex.ll

    r0e66857 rba01b14  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Nov  1 20:57:35 2018
    13  * Update Count     : 687
     12 * Last Modified On : Mon Feb  4 22:49:19 2019
     13 * Update Count     : 701
    1414 */
    1515
     
    3939using namespace std;
    4040
     41#include "config.h"                                                                             // configure info
    4142#include "ParseNode.h"
    4243#include "TypedefTable.h"
     
    5960#define IDENTIFIER_RETURN()     RETURN_VAL( typedefTable.isKind( yytext ) )
    6061#define ATTRIBUTE_RETURN()      RETURN_VAL( ATTR_IDENTIFIER )
     62
     63#ifdef HAVE_KEYWORDS_FLOATXX                                                            // GCC >= 7 => keyword, otherwise typedef
     64#define FLOATXX(v) KEYWORD_RETURN(v);
     65#else
     66#define FLOATXX(v) IDENTIFIER_RETURN();
     67#endif // HAVE_KEYWORDS_FLOATXX
    6168
    6269void rm_underscore() {
     
    112119                                // GCC: D (double) and iI (imaginary) suffixes, and DL (long double)
    113120exponent "_"?[eE]"_"?[+-]?{decimal_digits}
    114 floating_size 32|64|80|128
    115 floating_length ([fFdDlL]|[lL]{floating_size})
     121floating_size 16|32|32x|64|64x|80|128|128x
     122floating_length ([fFdDlLwWqQ]|[fF]{floating_size})
    116123floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length})
    117124floating_suffix_opt ("_"?({floating_suffix}|"DL"))?
     
    240247finally                 { KEYWORD_RETURN(FINALLY); }                    // CFA
    241248float                   { KEYWORD_RETURN(FLOAT); }
    242 _Float32                { KEYWORD_RETURN(FLOAT); }                              // GCC
    243 _Float32x               { KEYWORD_RETURN(FLOAT); }                              // GCC
    244 _Float64                { KEYWORD_RETURN(DOUBLE); }                             // GCC
    245 _Float64x               { KEYWORD_RETURN(DOUBLE); }                             // GCC
    246249__float80               { KEYWORD_RETURN(FLOAT80); }                    // GCC
    247250float80                 { KEYWORD_RETURN(FLOAT80); }                    // GCC
    248 _Float128               { KEYWORD_RETURN(FLOAT128); }                   // GCC
    249 _Float128x              { KEYWORD_RETURN(FLOAT128); }                   // GCC
    250251__float128              { KEYWORD_RETURN(FLOAT128); }                   // GCC
    251252float128                { KEYWORD_RETURN(FLOAT128); }                   // GCC
     253_Float16                { FLOATXX(_FLOAT16); }                                  // GCC
     254_Float32                { FLOATXX(_FLOAT32); }                                  // GCC
     255_Float32x               { FLOATXX(_FLOAT32X); }                                 // GCC
     256_Float64                { FLOATXX(_FLOAT64); }                                  // GCC
     257_Float64x               { FLOATXX(_FLOAT64X); }                                 // GCC
     258_Float128               { FLOATXX(_FLOAT128); }                                 // GCC
     259_Float128x              { FLOATXX(_FLOAT128); }                                 // GCC
    252260for                             { KEYWORD_RETURN(FOR); }
    253261forall                  { KEYWORD_RETURN(FORALL); }                             // CFA
  • src/Parser/parser.yy

    r0e66857 rba01b14  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  8 18:08:23 2018
    13 // Update Count     : 4052
     12// Last Modified On : Fri Feb  1 16:26:47 2019
     13// Update Count     : 4061
    1414//
    1515
     
    264264%token BOOL COMPLEX IMAGINARY                                                   // C99
    265265%token INT128 FLOAT80 FLOAT128                                                  // GCC
     266%token _FLOAT16 _FLOAT32 _FLOAT32X _FLOAT64 _FLOAT64X _FLOAT128 // GCC
    266267%token ZERO_T ONE_T                                                                             // CFA
    267268%token VALIST                                                                                   // GCC
     
    17711772        | FLOAT
    17721773                { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }
     1774        | DOUBLE
     1775                { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); }
    17731776        | FLOAT80
    17741777                { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); }
    17751778        | FLOAT128
    17761779                { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); }
    1777         | DOUBLE
    1778                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); }
     1780        | _FLOAT16
     1781                { $$ = DeclarationNode::newBasicType( DeclarationNode::_Float16 ); }
     1782        | _FLOAT32
     1783                { $$ = DeclarationNode::newBasicType( DeclarationNode::_Float32 ); }
     1784        | _FLOAT32X
     1785                { $$ = DeclarationNode::newBasicType( DeclarationNode::_Float32x ); }
     1786        | _FLOAT64
     1787                { $$ = DeclarationNode::newBasicType( DeclarationNode::_Float64 ); }
     1788        | _FLOAT64X
     1789                { $$ = DeclarationNode::newBasicType( DeclarationNode::_Float64x ); }
     1790        | _FLOAT128
     1791                { $$ = DeclarationNode::newBasicType( DeclarationNode::_Float128 ); }
    17791792        | COMPLEX                                                                                       // C99
    17801793                { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
Note: See TracChangeset for help on using the changeset viewer.