- Timestamp:
- Feb 11, 2019, 6:46:56 PM (6 years ago)
- 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
- Location:
- src/Parser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r0e66857 rba01b14 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Nov 1 20:54:26 201813 // Update Count : 11 0812 // Last Modified On : Fri Feb 1 16:49:17 2019 13 // Update Count : 1113 14 14 // 15 15 … … 41 41 42 42 // 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" }; 43 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "int128", 44 "float", "double", "long double", "float80", "float128", 45 "_float16", "_float32", "_float32x", "_float64", "_float64x", "_float128", "_float128x", "NoBasicTypeNames" }; 46 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "NoComplexTypeNames", "_Imaginary" }; // Imaginary unsupported => parse, but make invisible and print error message 45 47 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; 46 48 const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" }; -
src/Parser/ExpressionNode.cc
r0e66857 rba01b14 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 4 21:24:45 201813 // Update Count : 80212 // Last Modified On : Thu Feb 7 22:35:29 2019 13 // Update Count : 900 14 14 // 15 15 … … 51 51 extern const Type::Qualifiers noQualifiers; // no qualifiers on constants 52 52 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'; } 57 56 static inline bool checkF( char c ) { return c == 'f' || c == 'F'; } 58 57 static inline bool checkD( char c ) { return c == 'd' || c == 'D'; } 58 static inline bool checkF80( char c ) { return c == 'w' || c == 'W'; } 59 static inline bool checkL( char c ) { return c == 'l' || c == 'L'; } 60 static inline bool checkF128( char c ) { return c == 'q' || c == 'Q'; } 59 61 static inline bool checkI( char c ) { return c == 'i' || c == 'I'; } 60 62 static inline bool checkB( char c ) { return c == 'b' || c == 'B'; } 61 63 static inline bool checkX( char c ) { return c == 'x' || c == 'X'; } 62 64 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 }; // lnthsInt67 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 size72 posn += 1; // advance to size73 if ( str[posn] == '8' ) { // 874 lnth = 0;75 } else if ( str[posn] == '1' ) {76 posn += 1;77 if ( str[posn] == '6' ) { // 1678 lnth = 1;79 } else { // 12880 posn += 1;81 lnth = 5;82 } // if83 } else {84 if ( str[posn] == '3' ) { // 3285 lnth = 2;86 } else if ( str[posn] == '6' ) { // 6487 lnth = 3;88 } else {89 assertf( false, "internal error, bad integral length %s", str.c_str() );90 } // if91 posn += 1;92 } // if93 str.erase( start, posn - start + 1 ); // remove length suffix94 } // checkLNInt95 96 65 Expression * build_constantInteger( string & str ) { 97 66 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 99 68 { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt128, }, 100 69 { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, }, 101 70 }; 102 71 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 103 77 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 => int128105 int l nth= -1; // literal length78 int type = -1; // 0 => short, 1 => char, 2 => int, 3 => long int, 4 => long long int, 5 => int128 79 int ltype = -1; // literal length 106 80 107 81 unsigned long long int v; // converted integral value … … 127 101 //printf( "%llx %llu\n", v, v ); 128 102 } else if ( checkB( str[1] ) ) { // binary constant ? 129 v = 0; 130 for ( unsigned int i = 2;; i += 1 ) { // compute value103 v = 0; // compute value 104 for ( unsigned int i = 2;; ) { 131 105 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; 133 108 v <<= 1; 134 109 } // for 135 //printf( "% llx %llu\n", v, v );110 //printf( "%#llx %llu\n", v, v ); 136 111 } else { // octal constant 137 112 sscanf( (char *)str.c_str(), "%llo", &v ); 138 //printf( "% llo %llu\n", v, v );113 //printf( "%#llo %llu\n", v, v ); 139 114 } // if 140 115 } else { // decimal constant ? … … 143 118 } // if 144 119 145 if ( v <= INT_MAX ) { // signed int146 size = 2;147 } else if ( v <= UINT_MAX && ! dec ) { // unsigned int148 size = 2;149 Unsigned = true; // unsigned150 } else if ( v <= LONG_MAX ) { // signed long int151 size = 3;152 } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int153 size = 3;154 Unsigned = true; // unsigned long int155 } else if ( v <= LLONG_MAX ) { // signed long long int156 size = 4;157 } else { // unsigned long long int158 size = 4;159 Unsigned = true; // unsigned long long int160 } // if161 162 120 // At least one digit in integer constant, so safe to backup while looking for suffix. 163 121 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 ); 170 155 } // 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 ); 209 180 // 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 ? 212 183 // 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 ( l nth!= -1 ) { // explicit length ?215 if ( l nth== 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 ); 218 189 } else { 219 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][l nth], false ), false );190 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][ltype], false ), false ); 220 191 } // if 221 192 } // if … … 227 198 228 199 229 static inline void checkLNFloat( string & str, int & lnth, int & size ) { 230 string::size_type posn = str.find_first_of( "lL" ), start = posn; 200 static 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 231 209 if ( posn == string::npos ) return; 232 size = 2; // assume largest size 233 lnth = 0; 210 explnth = true; 234 211 posn += 1; // advance to size 235 212 if ( str[posn] == '3' ) { // 32 236 size = 0; 213 if ( str[last] != 'x' ) type = 6; 214 else type = 7; 237 215 } 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 242 227 } else { 243 228 assertf( false, "internal error, bad floating point length %s", str.c_str() ); 244 229 } // if 245 posn += 1; 246 str.erase( start, posn - start + 1 ); // remove length suffix 247 } // checkLNFloat 230 } // checkFnxFloat 248 231 249 232 250 233 Expression * 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 }, 254 237 }; 255 238 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 260 240 size_t last = str.length() - 1; 261 241 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 262 245 263 246 sscanf( str.c_str(), "%lg", &v ); … … 269 252 270 253 if ( checkF( str[last] ) ) { // float ? 271 size = 0;254 type = 0; 272 255 } else if ( checkD( str[last] ) ) { // double ? 273 size = 1;256 type = 1; 274 257 } 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; 276 263 } 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 280 268 if ( ! complx && checkI( str[last - 1] ) ) { // imaginary ? 281 269 complx = true; 282 270 } // if 283 271 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 ); 288 276 } // if 289 277 -
src/Parser/ParseNode.h
r0e66857 rba01b14 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Nov 1 20:54:53 201813 // Update Count : 8 5412 // Last Modified On : Fri Feb 1 16:48:10 2019 13 // Update Count : 866 14 14 // 15 15 … … 206 206 class DeclarationNode : public ParseNode { 207 207 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 }; 210 212 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 212 214 static const char * complexTypeNames[]; 213 215 enum Signedness { Signed, Unsigned, NoSignedness }; -
src/Parser/TypeData.cc
r0e66857 rba01b14 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 2 07:54:26 201813 // Update Count : 6 2412 // Last Modified On : Fri Feb 8 09:36:26 2019 13 // Update Count : 645 14 14 // 15 15 … … 629 629 } // if 630 630 631 ret = BasicType:: Bool;631 ret = BasicType::_Bool; 632 632 break; 633 633 … … 666 666 667 667 case DeclarationNode::Float: 668 case DeclarationNode::Double: 669 case DeclarationNode::LongDouble: // not set until below 668 670 case DeclarationNode::Float80: 669 671 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, }, 676 682 }; 677 683 … … 686 692 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 687 693 } // 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 688 700 if ( td->length == DeclarationNode::Long ) { 689 701 const_cast<TypeData *>(td)->basictype = DeclarationNode::LongDouble; 690 702 } // if 691 703 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 701 704 ret = floattype[ td->complextype ][ td->basictype - DeclarationNode::Float ]; 705 //printf( "XXXX %d %d %d %d\n", td->complextype, td->basictype, DeclarationNode::Float, ret ); 702 706 break; 703 707 -
src/Parser/lex.ll
r0e66857 rba01b14 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Thu Nov 1 20:57:35 201813 * Update Count : 68712 * Last Modified On : Mon Feb 4 22:49:19 2019 13 * Update Count : 701 14 14 */ 15 15 … … 39 39 using namespace std; 40 40 41 #include "config.h" // configure info 41 42 #include "ParseNode.h" 42 43 #include "TypedefTable.h" … … 59 60 #define IDENTIFIER_RETURN() RETURN_VAL( typedefTable.isKind( yytext ) ) 60 61 #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 61 68 62 69 void rm_underscore() { … … 112 119 // GCC: D (double) and iI (imaginary) suffixes, and DL (long double) 113 120 exponent "_"?[eE]"_"?[+-]?{decimal_digits} 114 floating_size 32|64|80|128115 floating_length ([fFdDlL ]|[lL]{floating_size})121 floating_size 16|32|32x|64|64x|80|128|128x 122 floating_length ([fFdDlLwWqQ]|[fF]{floating_size}) 116 123 floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length}) 117 124 floating_suffix_opt ("_"?({floating_suffix}|"DL"))? … … 240 247 finally { KEYWORD_RETURN(FINALLY); } // CFA 241 248 float { KEYWORD_RETURN(FLOAT); } 242 _Float32 { KEYWORD_RETURN(FLOAT); } // GCC243 _Float32x { KEYWORD_RETURN(FLOAT); } // GCC244 _Float64 { KEYWORD_RETURN(DOUBLE); } // GCC245 _Float64x { KEYWORD_RETURN(DOUBLE); } // GCC246 249 __float80 { KEYWORD_RETURN(FLOAT80); } // GCC 247 250 float80 { KEYWORD_RETURN(FLOAT80); } // GCC 248 _Float128 { KEYWORD_RETURN(FLOAT128); } // GCC249 _Float128x { KEYWORD_RETURN(FLOAT128); } // GCC250 251 __float128 { KEYWORD_RETURN(FLOAT128); } // GCC 251 252 float128 { 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 252 260 for { KEYWORD_RETURN(FOR); } 253 261 forall { KEYWORD_RETURN(FORALL); } // CFA -
src/Parser/parser.yy
r0e66857 rba01b14 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Nov 8 18:08:23 201813 // Update Count : 40 5212 // Last Modified On : Fri Feb 1 16:26:47 2019 13 // Update Count : 4061 14 14 // 15 15 … … 264 264 %token BOOL COMPLEX IMAGINARY // C99 265 265 %token INT128 FLOAT80 FLOAT128 // GCC 266 %token _FLOAT16 _FLOAT32 _FLOAT32X _FLOAT64 _FLOAT64X _FLOAT128 // GCC 266 267 %token ZERO_T ONE_T // CFA 267 268 %token VALIST // GCC … … 1771 1772 | FLOAT 1772 1773 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } 1774 | DOUBLE 1775 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); } 1773 1776 | FLOAT80 1774 1777 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); } 1775 1778 | FLOAT128 1776 1779 { $$ = 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 ); } 1779 1792 | COMPLEX // C99 1780 1793 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
Note: See TracChangeset
for help on using the changeset viewer.