Changeset 201aeb9 for src/Parser
- Timestamp:
- Sep 26, 2017, 11:22:08 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- d67cdb7
- Parents:
- 9bae71f
- Location:
- src/Parser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r9bae71f r201aeb9 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 12:34:05 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Aug 10 17:02:00201713 // Update Count : 102 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 23 18:16:48 2017 13 // Update Count : 1024 14 14 // 15 15 … … 40 40 using namespace std; 41 41 42 // These must remain in the same order asthe corresponding DeclarationNode enumerations.43 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", " NoBasicTypeNames" };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 44 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" }; 45 45 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; -
src/Parser/ExpressionNode.cc
r9bae71f r201aeb9 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Sep 14 23:09:34201713 // Update Count : 69012 // Last Modified On : Tue Sep 26 11:23:36 2017 13 // Update Count : 780 14 14 // 15 15 … … 60 60 static inline bool checkX( char c ) { return c == 'x' || c == 'X'; } 61 61 62 static const char * lnthsInt[2][6] = { 63 { "int8_t", "int16_t", "int32_t", "int64_t", "size_t", }, 64 { "uint8_t", "uint16_t", "uint32_t", "uint64_t", "size_t", } 65 }; // lnthsInt 66 67 static inline void checkLNInt( string & str, int & lnth, int & size ) { 68 string::size_type posn = str.find_first_of( "lL" ), start = posn; 69 if ( posn == string::npos ) return; 70 size = 4; // assume largest size 71 posn += 1; // advance to size 72 if ( str[posn] == '8' ) { // 8 73 lnth = 0; 74 } else if ( str[posn] == '1' ) { 75 posn += 1; 76 if ( str[posn] == '6' ) { // 16 77 lnth = 1; 78 } else { // 128 79 posn += 1; 80 lnth = 5; 81 } // if 82 } else { 83 if ( str[posn] == '3' ) { // 32 84 lnth = 2; 85 } else if ( str[posn] == '6' ) { // 64 86 lnth = 3; 87 } else { 88 assertf( false, "internal error, bad integral length %s", str.c_str() ); 89 } // if 90 posn += 1; 91 } // if 92 str.erase( start, posn - start + 1 ); // remove length suffix 93 } // checkLNInt 94 62 95 static void sepNumeric( string & str, string & units ) { 63 96 string::size_type posn = str.find_first_of( "`" ); … … 69 102 70 103 Expression * build_constantInteger( string & str ) { 71 static const BasicType::Kind kind[2][ 5] = {104 static const BasicType::Kind kind[2][6] = { 72 105 // short (h) must be before char (hh) 73 { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt },74 { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt },106 { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt128, }, 107 { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, }, 75 108 }; 76 109 77 string units; // units110 string units; 78 111 sepNumeric( str, units ); // separate constant from units 79 112 80 113 bool dec = true, Unsigned = false; // decimal, unsigned constant 81 int size; // 0 => short, 1 => char, 2 => int, 3 => long int, 4 => long long int, 5 => size_t 114 int size; // 0 => short, 1 => char, 2 => int, 3 => long int, 4 => long long int, 5 => int128 115 int lnth = -1; // literal length 116 82 117 unsigned long long int v; // converted integral value 83 118 size_t last = str.length() - 1; // last character of constant … … 140 175 } // if 141 176 str.erase( last - size - 1, size + 1 ); // remove 'h'/"hh" 177 } else { // suffix "ln" ? 178 checkLNInt( str, lnth, size ); 142 179 } // if 143 180 } else if ( checkL( str[ last ] ) ) { // suffix 'l' ? … … 163 200 str.erase( last - size, size + 1 ); // remove 'h'/"hh" 164 201 } else if ( checkZ( str[last] ) ) { // suffix 'z' ? 165 size = 5;202 lnth = 4; 166 203 str.erase( last, 1 ); // remove 'z' 167 } // if 168 204 } else { // suffix "ln" ? 205 checkLNInt( str, lnth, size ); 206 } // if 207 208 assert( 0 <= size && size < 6 ); 169 209 ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) ); 170 if ( Unsigned && size < 2 ) { //less than int ?171 // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which eliminates warnings for large values.210 if ( size < 2 ) { // hh or h, less than int ? 211 // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values. 172 212 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) ); 173 } else if ( size == 5 ) { // explicit cast to size_t 174 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), "size_t", false ) ); 213 } else if ( lnth != -1 ) { // explicit length ? 214 if ( lnth == 5 ) { // int128 ? 215 size = 5; 216 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) ); 217 } else { 218 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ) ); 219 } // if 175 220 } // if 176 221 CLEANUP: … … 182 227 return ret; 183 228 } // build_constantInteger 229 230 231 static inline void checkLNFloat( string & str, int & lnth, int & size ) { 232 string::size_type posn = str.find_first_of( "lL" ), start = posn; 233 if ( posn == string::npos ) return; 234 size = 2; // assume largest size 235 lnth = 0; 236 posn += 1; // advance to size 237 if ( str[posn] == '3' ) { // 32 238 size = 0; 239 } else if ( str[posn] == '6' ) { // 64 240 size = 1; 241 } else if ( str[posn] == '8' || str[posn] == '1' ) { // 80, 128 242 size = 2; 243 if ( str[posn] == '1' ) posn += 1; 244 } else { 245 assertf( false, "internal error, bad floating point length %s", str.c_str() ); 246 } // if 247 posn += 1; 248 str.erase( start, posn - start + 1 ); // remove length suffix 249 } // checkLNFloat 250 184 251 185 252 Expression * build_constantFloat( string & str ) { … … 189 256 }; 190 257 191 string units; // units258 string units; 192 259 sepNumeric( str, units ); // separate constant from units 193 260 194 261 bool complx = false; // real, complex 195 int size = 1; // 0 => float, 1 => double (default), 2 => long double 262 int size = 1; // 0 => float, 1 => double, 2 => long double 263 int lnth = -1; // literal length 196 264 // floating-point constant has minimum of 2 characters: 1. or .1 197 265 size_t last = str.length() - 1; … … 211 279 } else if ( checkL( str[last] ) ) { // long double ? 212 280 size = 2; 281 } else { 282 size = 1; // double (default) 283 checkLNFloat( str, lnth, size ); 213 284 } // if 214 285 if ( ! complx && checkI( str[last - 1] ) ) { // imaginary ? … … 216 287 } // if 217 288 289 assert( 0 <= size && size < 3 ); 218 290 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) ); 291 if ( lnth != -1 ) { // explicit length ? 292 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ) ); 293 } // if 219 294 if ( units.length() != 0 ) { 220 295 ret = new UntypedExpr( new NameExpr( units ), { ret } ); -
src/Parser/ParseNode.h
r9bae71f r201aeb9 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Sep 14 23:09:39201713 // Update Count : 8 1512 // Last Modified On : Sat Sep 23 18:11:22 2017 13 // Update Count : 821 14 14 // 15 15 … … 47 47 #define YYLTYPE_IS_DECLARED 1 /* alert the parser that we have our own definition */ 48 48 49 extern char * yyfilename;50 extern int yylineno;51 49 extern YYLTYPE yylloc; 52 50 … … 197 195 class DeclarationNode : public ParseNode { 198 196 public: 199 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 197 // These enumerations must harmonize with their names. 198 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, Int128, Float80, Float128, NoBasicType }; 199 static const char * basicTypeNames[]; 200 200 enum ComplexType { Complex, Imaginary, NoComplexType }; 201 static const char * complexTypeNames[]; 201 202 enum Signedness { Signed, Unsigned, NoSignedness }; 203 static const char * signednessNames[]; 202 204 enum Length { Short, Long, LongLong, NoLength }; 205 static const char * lengthNames[]; 203 206 enum Aggregate { Struct, Union, Trait, Coroutine, Monitor, Thread, NoAggregate }; 207 static const char * aggregateNames[]; 204 208 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass }; 209 static const char * typeClassNames[]; 205 210 enum BuiltinType { Valist, Zero, One, NoBuiltinType }; 206 207 static const char * basicTypeNames[];208 static const char * complexTypeNames[];209 static const char * signednessNames[];210 static const char * lengthNames[];211 static const char * aggregateNames[];212 static const char * typeClassNames[];213 211 static const char * builtinTypeNames[]; 214 212 -
src/Parser/TypeData.cc
r9bae71f r201aeb9 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Sep 1 23:13:38201713 // Update Count : 5 6912 // Last Modified On : Mon Sep 25 18:33:41 2017 13 // Update Count : 587 14 14 // 15 15 … … 98 98 } // TypeData::TypeData 99 99 100 100 101 TypeData::~TypeData() { 101 102 delete base; … … 161 162 } // switch 162 163 } // TypeData::~TypeData 164 163 165 164 166 TypeData * TypeData::clone() const { … … 235 237 } // TypeData::clone 236 238 239 237 240 void TypeData::print( ostream &os, int indent ) const { 238 241 for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) { … … 398 401 } // switch 399 402 } // TypeData::print 403 400 404 401 405 template< typename ForallList > … … 430 434 } // if 431 435 } // for 432 } 436 } // buildForall 437 433 438 434 439 Type * typebuild( const TypeData * td ) { … … 477 482 } // typebuild 478 483 484 479 485 TypeData * typeextractAggregate( const TypeData * td, bool toplevel ) { 480 486 TypeData * ret = nullptr; … … 504 510 } // typeextractAggregate 505 511 512 506 513 Type::Qualifiers buildQualifiers( const TypeData * td ) { 507 514 return td->qualifiers; 508 515 } // buildQualifiers 509 516 517 518 static string genTSError( string msg, DeclarationNode::BasicType basictype ) { 519 throw SemanticError( string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." ); 520 } // genTSError 521 510 522 Type * buildBasicType( const TypeData * td ) { 511 523 BasicType::Kind ret; … … 513 525 switch ( td->basictype ) { 514 526 case DeclarationNode::Void: 515 if ( td->signedness != DeclarationNode::NoSignedness && td->length != DeclarationNode::NoLength ) { 516 throw SemanticError( "invalid type specifier \"void\" in type: ", td ); 517 } // if 518 527 if ( td->signedness != DeclarationNode::NoSignedness ) { 528 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 529 } // if 530 if ( td->length != DeclarationNode::NoLength ) { 531 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 532 } // if 519 533 return new VoidType( buildQualifiers( td ) ); 520 534 break; … … 522 536 case DeclarationNode::Bool: 523 537 if ( td->signedness != DeclarationNode::NoSignedness ) { 524 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td);538 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 525 539 } // if 526 540 if ( td->length != DeclarationNode::NoLength ) { 527 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);541 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 528 542 } // if 529 543 … … 538 552 539 553 if ( td->length != DeclarationNode::NoLength ) { 540 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);554 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 541 555 } // if 542 556 … … 557 571 break; 558 572 573 case DeclarationNode::Int128: 574 ret = td->signedness == 1 ? BasicType::UnsignedInt128 : BasicType::SignedInt128; 575 if ( td->length != DeclarationNode::NoLength ) { 576 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 577 } // if 578 break; 579 559 580 case DeclarationNode::Float: 581 case DeclarationNode::Float80: 582 case DeclarationNode::Float128: 560 583 case DeclarationNode::Double: 561 584 case DeclarationNode::LongDouble: // not set until below … … 568 591 FloatingPoint: ; 569 592 if ( td->signedness != DeclarationNode::NoSignedness ) { 570 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td);593 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 571 594 } // if 572 595 if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) { 573 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);596 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 574 597 } // if 575 598 if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) { 576 throw SemanticError( "invalid type specifier \"long\" in type: ", td);599 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 577 600 } // if 578 601 if ( td->length == DeclarationNode::Long ) { … … 593 616 goto Integral; 594 617 default: 595 assert (false);618 assertf( false, "unknown basic type" ); 596 619 return nullptr; 597 620 } // switch … … 601 624 return bt; 602 625 } // buildBasicType 626 603 627 604 628 PointerType * buildPointer( const TypeData * td ) { … … 612 636 return pt; 613 637 } // buildPointer 638 614 639 615 640 ArrayType * buildArray( const TypeData * td ) { … … 626 651 } // buildArray 627 652 653 628 654 ReferenceType * buildReference( const TypeData * td ) { 629 655 ReferenceType * rt; … … 637 663 } // buildReference 638 664 665 639 666 AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 640 667 assert( td->kind == TypeData::Aggregate ); … … 665 692 return at; 666 693 } // buildAggregate 694 667 695 668 696 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { … … 722 750 } // buildAggInst 723 751 752 724 753 ReferenceToType * buildAggInst( const TypeData * td ) { 725 754 assert( td->kind == TypeData::AggregateInst ); … … 761 790 } // buildAggInst 762 791 792 763 793 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) { 764 794 assert( td->kind == TypeData::Symbolic ); … … 775 805 } // buildSymbolic 776 806 807 777 808 EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 778 809 assert( td->kind == TypeData::Enum ); … … 790 821 } // buildEnum 791 822 823 792 824 TypeInstType * buildSymbolicInst( const TypeData * td ) { 793 825 assert( td->kind == TypeData::SymbolicInst ); … … 797 829 return ret; 798 830 } // buildSymbolicInst 831 799 832 800 833 TupleType * buildTuple( const TypeData * td ) { … … 807 840 } // buildTuple 808 841 842 809 843 TypeofType * buildTypeof( const TypeData * td ) { 810 844 assert( td->kind == TypeData::Typeof ); … … 813 847 return new TypeofType( buildQualifiers( td ), td->typeexpr->build() ); 814 848 } // buildTypeof 849 815 850 816 851 Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, Expression *asmName, Initializer * init, std::list< Attribute * > attributes ) { … … 836 871 return nullptr; 837 872 } // buildDecl 873 838 874 839 875 FunctionType * buildFunction( const TypeData * td ) { … … 857 893 return ft; 858 894 } // buildFunction 895 859 896 860 897 // Transform KR routine declarations into C99 routine declarations: -
src/Parser/lex.ll
r9bae71f r201aeb9 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : S un Sep 10 22:29:15201713 * Update Count : 6 2012 * Last Modified On : Sat Sep 23 17:29:28 2017 13 * Update Count : 632 14 14 */ 15 15 … … 93 93 // numeric constants, CFA: '_' in constant 94 94 hex_quad {hex}("_"?{hex}){3} 95 length ("ll"|"LL"|[lL])|("hh"|"HH"|[hH]) 95 size_opt (8|16|32|64|128)? 96 length ("ll"|"LL"|[lL]{size_opt})|("hh"|"HH"|[hH]) 96 97 integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))?{user_suffix_opt} 97 98 … … 109 110 // GCC: D (double) and iI (imaginary) suffixes, and DL (long double) 110 111 exponent "_"?[eE]"_"?[+-]?{decimal_digits} 111 floating_suffix ([fFdDlL]?[iI]?)|([iI][lLfFdD]) 112 floating_size 32|64|80|128 113 floating_length ([fFdDlL]|[lL]{floating_size}) 114 floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length}) 112 115 floating_suffix_opt ("_"?({floating_suffix}|"DL"))?{user_suffix_opt} 113 116 decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal}) … … 234 237 finally { KEYWORD_RETURN(FINALLY); } // CFA 235 238 float { KEYWORD_RETURN(FLOAT); } 236 __float128 { KEYWORD_RETURN(FLOAT); } // GCC 239 __float80 { KEYWORD_RETURN(FLOAT80); } // GCC 240 float80 { KEYWORD_RETURN(FLOAT80); } // GCC 241 __float128 { KEYWORD_RETURN(FLOAT128); } // GCC 242 float128 { KEYWORD_RETURN(FLOAT128); } // GCC 237 243 for { KEYWORD_RETURN(FOR); } 238 244 forall { KEYWORD_RETURN(FORALL); } // CFA … … 249 255 __inline__ { KEYWORD_RETURN(INLINE); } // GCC 250 256 int { KEYWORD_RETURN(INT); } 251 __int128 { KEYWORD_RETURN(INT ); } // GCC252 __int128_t { KEYWORD_RETURN(INT); } // GCC257 __int128 { KEYWORD_RETURN(INT128); } // GCC 258 int128 { KEYWORD_RETURN(INT128); } // GCC 253 259 __label__ { KEYWORD_RETURN(LABEL); } // GCC 254 260 long { KEYWORD_RETURN(LONG); } … … 285 291 __typeof { KEYWORD_RETURN(TYPEOF); } // GCC 286 292 __typeof__ { KEYWORD_RETURN(TYPEOF); } // GCC 287 __uint128_t { KEYWORD_RETURN(INT); } // GCC288 293 union { KEYWORD_RETURN(UNION); } 289 294 unsigned { KEYWORD_RETURN(UNSIGNED); } -
src/Parser/parser.yy
r9bae71f r201aeb9 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Sep 14 23:07:12201713 // Update Count : 28 1512 // Last Modified On : Sat Sep 23 17:43:15 2017 13 // Update Count : 2829 14 14 // 15 15 … … 43 43 #define YYDEBUG_LEXER_TEXT (yylval) // lexer loads this up each time 44 44 #define YYDEBUG 1 // get the pretty debugging code to compile 45 #define YYERROR_VERBOSE 45 #define YYERROR_VERBOSE // more information in syntax errors 46 46 47 47 #undef __GNUC_MINOR__ … … 117 117 bool forall = false; // aggregate have one or more forall qualifiers ? 118 118 119 # define YYLLOC_DEFAULT(Cur, Rhs, N) \ 120 do \ 121 if (N) { \ 122 (Cur).first_line = YYRHSLOC(Rhs, 1).first_line; \ 123 (Cur).first_column = YYRHSLOC(Rhs, 1).first_column; \ 124 (Cur).last_line = YYRHSLOC(Rhs, N).last_line; \ 125 (Cur).last_column = YYRHSLOC(Rhs, N).last_column; \ 126 (Cur).filename = YYRHSLOC(Rhs, 1).filename; \ 127 } else { \ 128 (Cur).first_line = (Cur).last_line = \ 129 YYRHSLOC(Rhs, 0).last_line; \ 130 (Cur).first_column = (Cur).last_column = \ 131 YYRHSLOC(Rhs, 0).last_column; \ 132 (Cur).filename = YYRHSLOC(Rhs, 0).filename; \ 133 } \ 134 while (0) 119 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type 120 #define YYLLOC_DEFAULT(Cur, Rhs, N) \ 121 if ( N ) { \ 122 (Cur).first_line = YYRHSLOC( Rhs, 1 ).first_line; \ 123 (Cur).first_column = YYRHSLOC( Rhs, 1 ).first_column; \ 124 (Cur).last_line = YYRHSLOC( Rhs, N ).last_line; \ 125 (Cur).last_column = YYRHSLOC( Rhs, N ).last_column; \ 126 (Cur).filename = YYRHSLOC( Rhs, 1 ).filename; \ 127 } else { \ 128 (Cur).first_line = (Cur).last_line = YYRHSLOC( Rhs, 0 ).last_line; \ 129 (Cur).first_column = (Cur).last_column = YYRHSLOC( Rhs, 0 ).last_column; \ 130 (Cur).filename = YYRHSLOC( Rhs, 0 ).filename; \ 131 } 135 132 %} 136 133 137 134 %define parse.error verbose 138 135 139 // Types declaration 136 // Types declaration for productions 140 137 %union 141 138 { … … 173 170 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 174 171 %token BOOL COMPLEX IMAGINARY // C99 172 %token INT128 FLOAT80 FLOAT128 // GCC 175 173 %token ZERO_T ONE_T // CFA 176 174 %token VALIST // GCC … … 1606 1604 1607 1605 basic_type_name: 1608 CHAR 1606 VOID 1607 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } 1608 | BOOL // C99 1609 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 1610 | CHAR 1609 1611 { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); } 1612 | INT 1613 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); } 1614 | INT128 1615 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); } 1616 | FLOAT 1617 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } 1618 | FLOAT80 1619 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); } 1620 | FLOAT128 1621 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); } 1610 1622 | DOUBLE 1611 1623 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); } 1612 | FLOAT 1613 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } 1614 | INT 1615 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); } 1616 | LONG 1617 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1618 | SHORT 1619 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); } 1624 | COMPLEX // C99 1625 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 1626 | IMAGINARY // C99 1627 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1620 1628 | SIGNED 1621 1629 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); } 1622 1630 | UNSIGNED 1623 1631 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); } 1624 | VOID 1625 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } 1626 | BOOL // C99 1627 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 1628 | COMPLEX // C99 1629 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 1630 | IMAGINARY // C99 1631 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1632 | SHORT 1633 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); } 1634 | LONG 1635 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1632 1636 | ZERO_T 1633 1637 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
Note:
See TracChangeset
for help on using the changeset viewer.