Changeset cd623a4 for src/Parser
- Timestamp:
- Jun 7, 2015, 7:59:43 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 5f2f2d7
- Parents:
- 59db689
- Location:
- src/Parser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
r59db689 rcd623a4 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Jun 6 23:18:19201513 // Update Count : 1 2812 // Last Modified On : Sun Jun 7 07:58:00 2015 13 // Update Count : 135 14 14 // 15 15 … … 60 60 } 61 61 62 //############################################################################## 63 62 64 NullExprNode::NullExprNode() {} 63 65 … … 84 86 } 85 87 86 static inline bool checku( char c ) { return c == 'u' || c == 'U'; } 87 static inline bool checkl( char c ) { return c == 'l' || c == 'L'; } 88 static inline bool checkf( char c ) { return c == 'f' || c == 'F'; } 89 static inline bool checkx( char c ) { return c == 'x' || c == 'X'; } 88 //############################################################################## 89 90 static inline bool checkU( char c ) { return c == 'u' || c == 'U'; } 91 static inline bool checkL( char c ) { return c == 'l' || c == 'L'; } 92 static inline bool checkF( char c ) { return c == 'f' || c == 'F'; } 93 static inline bool checkX( char c ) { return c == 'x' || c == 'X'; } 94 95 // Very difficult to separate extra parts of constants during lexing because actions are not allow in the middle of 96 // patterns: 97 // 98 // prefix action constant action suffix 99 // 100 // Alternatively, breaking a pattern using BEGIN does not work if the following pattern can be empty: 101 // 102 // constant BEGIN CONT ... 103 // <CONT>(...)? BEGIN 0 ... // possible empty suffix 104 // 105 // because the CONT rule is NOT triggered if the pattern is empty. Hence, constants are reparsed here to determine their 106 // type. 90 107 91 108 ConstantNode::ConstantNode( Type t, string *inVal ) : type( t ), value( *inVal ) { 109 // lexing divides constants into 4 kinds 92 110 switch ( type ) { 93 case Float:94 {95 size_t len = value.length() - 1;96 97 btype = BasicType::Double; // default98 if ( checkf( value[len] ) ) {99 btype = BasicType::Float;100 } // if101 if ( checkl( value[len] ) ) {102 btype = BasicType::LongDouble;103 } // if104 break;105 }106 111 case Integer: 107 112 { … … 115 120 int size; // 0 => int, 1 => long, 2 => long long 116 121 117 if ( value[0] == '0' ) { // octal ?122 if ( value[0] == '0' ) { // octal constant ? 118 123 dec = false; 119 if ( last != 0 && check x( value[1] ) ) { // hex?124 if ( last != 0 && checkX( value[1] ) ) { // hex constant ? 120 125 sscanf( (char *)value.c_str(), "%llx", &v ); 121 126 //printf( "%llx %llu\n", v, v ); … … 124 129 //printf( "%llo %llu\n", v, v ); 125 130 } // if 126 } else { // decimal ?131 } else { // decimal constant ? 127 132 sscanf( (char *)value.c_str(), "%lld", &v ); 128 133 //printf( "%llu %llu\n", v, v ); … … 146 151 } // if 147 152 148 if ( check u( value[last] ) ) { // suffix 'u' ?153 if ( checkU( value[last] ) ) { // suffix 'u' ? 149 154 Unsigned = true; 150 if ( check l( value[ last - 1 ] ) ) { // suffix 'l' ?155 if ( checkL( value[ last - 1 ] ) ) { // suffix 'l' ? 151 156 size = 1; 152 if ( check l( value[ last - 1 ] ) ) { // suffix 'll' ?157 if ( checkL( value[ last - 1 ] ) ) { // suffix 'll' ? 153 158 size = 2; 154 159 } // if 155 160 } // if 156 } else if ( check l( value[ last ] ) ) { // suffix 'l' ?161 } else if ( checkL( value[ last ] ) ) { // suffix 'l' ? 157 162 size = 1; 158 if ( check l( value[ last - 1 ] ) ) { // suffix 'll' ?163 if ( checkL( value[ last - 1 ] ) ) { // suffix 'll' ? 159 164 size = 2; 160 165 } // if 161 if ( check u( value[ last - 1 ] ) ) { // suffix 'u' ?166 if ( checkU( value[ last - 1 ] ) ) { // suffix 'u' ? 162 167 Unsigned = true; 163 168 } // if 164 169 } // if 165 btype = kind[Unsigned][size]; // loopup type of constant 170 btype = kind[Unsigned][size]; // lookup constant type 171 break; 172 } 173 case Float: 174 { 175 size_t len = value.length() - 1; 176 177 btype = BasicType::Double; // default 178 if ( checkF( value[len] ) ) { // float ? 179 btype = BasicType::Float; 180 } // if 181 if ( checkL( value[len] ) ) { // long double ? 182 btype = BasicType::LongDouble; 183 } // if 166 184 break; 167 185 } … … 185 203 } // ConstantNode::ConstantNode 186 204 187 ConstantNode::Type ConstantNode::get_type( void ) const {188 return type;189 }190 191 205 ConstantNode *ConstantNode::appendstr( const std::string *newValue ) { 192 206 assert( newValue != 0 ); 193 207 assert( type == String ); 194 208 195 // printf( "%lu \"%s\" \"%s\"\n", value.length() - 1, value.c_str(), newValue->substr( 1, newValue->length() - 2 ).c_str() );209 // "abc" "def" "ghi" => "abcdefghi", so remove new text from quotes and insert before last quote in old string. 196 210 value.insert( value.length() - 1, newValue->substr( 1, newValue->length() - 2 ) ); 197 211 198 delete newValue; // allocated by yacc212 delete newValue; // allocated by lexer 199 213 return this; 200 214 } … … 226 240 227 241 Expression *ConstantNode::build() const { 228 ::Type::Qualifiers q; 229 BasicType *bt; 242 ::Type::Qualifiers q; // no qualifiers on constants 230 243 231 244 switch ( get_type() ) { … … 241 254 } 242 255 default: 243 bt = new BasicType( q, btype ); 244 return new ConstantExpr( Constant( bt, get_value() ), maybeBuild< Expression >( get_argName() ) ); 256 return new ConstantExpr( Constant( new BasicType( q, btype ), get_value() ), maybeBuild< Expression >( get_argName() ) ); 245 257 } 246 258 } 259 260 //############################################################################## 247 261 248 262 VarRefNode::VarRefNode() : isLabel( false ) {} … … 268 282 os << endl; 269 283 } 284 285 //############################################################################## 270 286 271 287 OperatorNode::OperatorNode( Type t ) : type( t ) {} … … 300 316 "Cond", "NCond", 301 317 // diadic 302 "SizeOf", 318 "SizeOf", "AlignOf", "Attr", "CompLit", "Plus", "Minus", "Mul", "Div", "Mod", "Or", 303 319 "And", "BitOr", "BitAnd", "Xor", "Cast", "LShift", "RShift", "LThan", "GThan", 304 320 "LEThan", "GEThan", "Eq", "Neq", "Assign", "MulAssn", "DivAssn", "ModAssn", "PlusAssn", … … 308 324 "UnPlus", "UnMinus", "AddressOf", "PointTo", "Neg", "BitNeg", "Incr", "IncrPost", "Decr", "DecrPost", "LabelAddress" 309 325 }; 326 327 //############################################################################## 310 328 311 329 CompositeExprNode::CompositeExprNode( void ) : ExpressionNode(), function( 0 ), arguments( 0 ) { … … 362 380 buildList( get_args(), args ); 363 381 364 if ( ! ( op = dynamic_cast<OperatorNode *>( function )) ) { 365 // a function as opposed to an operator 382 if ( ! ( op = dynamic_cast<OperatorNode *>( function ) ) ) { // function as opposed to operator 366 383 return new UntypedExpr( function->build(), args, maybeBuild< Expression >( get_argName() )); 367 } else { 368 switch ( op->get_type()) { 369 case OperatorNode::Incr: 370 case OperatorNode::Decr: 371 case OperatorNode::IncrPost: 372 case OperatorNode::DecrPost: 373 case OperatorNode::Assign: 374 case OperatorNode::MulAssn: 375 case OperatorNode::DivAssn: 376 case OperatorNode::ModAssn: 377 case OperatorNode::PlusAssn: 378 case OperatorNode::MinusAssn: 379 case OperatorNode::LSAssn: 380 case OperatorNode::RSAssn: 381 case OperatorNode::AndAssn: 382 case OperatorNode::ERAssn: 383 case OperatorNode::OrAssn: 384 // the rewrite rules for these expressions specify that the first argument has its address taken 385 assert( ! args.empty() ); 386 args.front() = new AddressExpr( args.front() ); 387 break; 388 default: 389 /* do nothing */ 390 ; 391 } 392 393 switch ( op->get_type() ) { 394 case OperatorNode::Incr: 395 case OperatorNode::Decr: 396 case OperatorNode::IncrPost: 397 case OperatorNode::DecrPost: 398 case OperatorNode::Assign: 399 case OperatorNode::MulAssn: 400 case OperatorNode::DivAssn: 401 case OperatorNode::ModAssn: 402 case OperatorNode::PlusAssn: 403 case OperatorNode::MinusAssn: 404 case OperatorNode::LSAssn: 405 case OperatorNode::RSAssn: 406 case OperatorNode::AndAssn: 407 case OperatorNode::ERAssn: 408 case OperatorNode::OrAssn: 409 case OperatorNode::Plus: 410 case OperatorNode::Minus: 411 case OperatorNode::Mul: 412 case OperatorNode::Div: 413 case OperatorNode::Mod: 414 case OperatorNode::BitOr: 415 case OperatorNode::BitAnd: 416 case OperatorNode::Xor: 417 case OperatorNode::LShift: 418 case OperatorNode::RShift: 419 case OperatorNode::LThan: 420 case OperatorNode::GThan: 421 case OperatorNode::LEThan: 422 case OperatorNode::GEThan: 423 case OperatorNode::Eq: 424 case OperatorNode::Neq: 425 case OperatorNode::Index: 426 case OperatorNode::Range: 427 case OperatorNode::UnPlus: 428 case OperatorNode::UnMinus: 429 case OperatorNode::PointTo: 430 case OperatorNode::Neg: 431 case OperatorNode::BitNeg: 432 case OperatorNode::LabelAddress: 433 return new UntypedExpr( new NameExpr( opFuncName[ op->get_type() ] ), args ); 434 case OperatorNode::AddressOf: 435 assert( args.size() == 1 ); 436 assert( args.front() ); 437 438 return new AddressExpr( args.front() ); 439 case OperatorNode::Cast: 440 { 441 TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()); 442 assert( arg ); 443 444 DeclarationNode *decl_node = arg->get_decl(); 445 ExpressionNode *expr_node = dynamic_cast<ExpressionNode *>( arg->get_link()); 446 447 Type *targetType = decl_node->buildType(); 448 if ( dynamic_cast< VoidType* >( targetType ) ) { 449 delete targetType; 450 return new CastExpr( expr_node->build(), maybeBuild< Expression >( get_argName() ) ); 451 } else { 452 return new CastExpr( expr_node->build(),targetType, maybeBuild< Expression >( get_argName() ) ); 453 } // if 454 } 455 case OperatorNode::FieldSel: 456 { 457 assert( args.size() == 2 ); 458 459 NameExpr *member = dynamic_cast<NameExpr *>( args.back()); 460 // TupleExpr *memberTup = dynamic_cast<TupleExpr *>( args.back()); 461 462 if ( member != 0 ) { 463 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), args.front()); 464 delete member; 465 return ret; 466 /* else if ( memberTup != 0 ) 467 { 468 UntypedMemberExpr *ret = new UntypedMemberExpr( memberTup->get_name(), args.front()); 469 delete member; 470 return ret; 471 } */ 472 } else 473 assert( false ); 474 } 475 case OperatorNode::PFieldSel: 476 { 477 assert( args.size() == 2 ); 478 479 NameExpr *member = dynamic_cast<NameExpr *>( args.back()); // modify for Tuples xxx 480 assert( member != 0 ); 481 482 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 483 deref->get_args().push_back( args.front() ); 484 485 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref ); 384 } // if 385 386 switch ( op->get_type()) { 387 case OperatorNode::Incr: 388 case OperatorNode::Decr: 389 case OperatorNode::IncrPost: 390 case OperatorNode::DecrPost: 391 case OperatorNode::Assign: 392 case OperatorNode::MulAssn: 393 case OperatorNode::DivAssn: 394 case OperatorNode::ModAssn: 395 case OperatorNode::PlusAssn: 396 case OperatorNode::MinusAssn: 397 case OperatorNode::LSAssn: 398 case OperatorNode::RSAssn: 399 case OperatorNode::AndAssn: 400 case OperatorNode::ERAssn: 401 case OperatorNode::OrAssn: 402 // the rewrite rules for these expressions specify that the first argument has its address taken 403 assert( ! args.empty() ); 404 args.front() = new AddressExpr( args.front() ); 405 break; 406 default: 407 /* do nothing */ 408 ; 409 } 410 411 switch ( op->get_type() ) { 412 case OperatorNode::Incr: 413 case OperatorNode::Decr: 414 case OperatorNode::IncrPost: 415 case OperatorNode::DecrPost: 416 case OperatorNode::Assign: 417 case OperatorNode::MulAssn: 418 case OperatorNode::DivAssn: 419 case OperatorNode::ModAssn: 420 case OperatorNode::PlusAssn: 421 case OperatorNode::MinusAssn: 422 case OperatorNode::LSAssn: 423 case OperatorNode::RSAssn: 424 case OperatorNode::AndAssn: 425 case OperatorNode::ERAssn: 426 case OperatorNode::OrAssn: 427 case OperatorNode::Plus: 428 case OperatorNode::Minus: 429 case OperatorNode::Mul: 430 case OperatorNode::Div: 431 case OperatorNode::Mod: 432 case OperatorNode::BitOr: 433 case OperatorNode::BitAnd: 434 case OperatorNode::Xor: 435 case OperatorNode::LShift: 436 case OperatorNode::RShift: 437 case OperatorNode::LThan: 438 case OperatorNode::GThan: 439 case OperatorNode::LEThan: 440 case OperatorNode::GEThan: 441 case OperatorNode::Eq: 442 case OperatorNode::Neq: 443 case OperatorNode::Index: 444 case OperatorNode::Range: 445 case OperatorNode::UnPlus: 446 case OperatorNode::UnMinus: 447 case OperatorNode::PointTo: 448 case OperatorNode::Neg: 449 case OperatorNode::BitNeg: 450 case OperatorNode::LabelAddress: 451 return new UntypedExpr( new NameExpr( opFuncName[ op->get_type() ] ), args ); 452 case OperatorNode::AddressOf: 453 assert( args.size() == 1 ); 454 assert( args.front() ); 455 456 return new AddressExpr( args.front() ); 457 case OperatorNode::Cast: 458 { 459 TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()); 460 assert( arg ); 461 462 DeclarationNode *decl_node = arg->get_decl(); 463 ExpressionNode *expr_node = dynamic_cast<ExpressionNode *>( arg->get_link()); 464 465 Type *targetType = decl_node->buildType(); 466 if ( dynamic_cast< VoidType* >( targetType ) ) { 467 delete targetType; 468 return new CastExpr( expr_node->build(), maybeBuild< Expression >( get_argName() ) ); 469 } else { 470 return new CastExpr( expr_node->build(),targetType, maybeBuild< Expression >( get_argName() ) ); 471 } // if 472 } 473 case OperatorNode::FieldSel: 474 { 475 assert( args.size() == 2 ); 476 477 NameExpr *member = dynamic_cast<NameExpr *>( args.back()); 478 // TupleExpr *memberTup = dynamic_cast<TupleExpr *>( args.back()); 479 480 if ( member != 0 ) { 481 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), args.front()); 486 482 delete member; 487 483 return ret; 484 /* else if ( memberTup != 0 ) 485 { 486 UntypedMemberExpr *ret = new UntypedMemberExpr( memberTup->get_name(), args.front()); 487 delete member; 488 return ret; 489 } */ 490 } else 491 assert( false ); 492 } 493 case OperatorNode::PFieldSel: 494 { 495 assert( args.size() == 2 ); 496 497 NameExpr *member = dynamic_cast<NameExpr *>( args.back()); // modify for Tuples xxx 498 assert( member != 0 ); 499 500 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 501 deref->get_args().push_back( args.front() ); 502 503 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref ); 504 delete member; 505 return ret; 506 } 507 case OperatorNode::AlignOf: 508 case OperatorNode::SizeOf: 509 { 510 /// bool isSizeOf = ( op->get_type() == OperatorNode::SizeOf ); 511 512 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()) ) { 513 return new SizeofExpr( arg->get_decl()->buildType()); 514 } else { 515 return new SizeofExpr( args.front()); 516 } // if 517 } 518 case OperatorNode::Attr: 519 { 520 VarRefNode *var = dynamic_cast<VarRefNode *>( get_args()); 521 assert( var ); 522 if ( ! get_args()->get_link() ) { 523 return new AttrExpr( var->build(), ( Expression*)0); 524 } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link()) ) { 525 return new AttrExpr( var->build(), arg->get_decl()->buildType()); 526 } else { 527 return new AttrExpr( var->build(), args.back()); 528 } // if 529 } 530 case OperatorNode::CompLit: 531 throw UnimplementedError( "C99 compound literals" ); 532 // the short-circuited operators 533 case OperatorNode::Or: 534 case OperatorNode::And: 535 assert( args.size() == 2); 536 return new LogicalExpr( notZeroExpr( args.front() ), notZeroExpr( args.back() ), ( op->get_type() == OperatorNode::And ) ); 537 case OperatorNode::Cond: 538 { 539 assert( args.size() == 3); 540 std::list< Expression* >::const_iterator i = args.begin(); 541 Expression *arg1 = notZeroExpr( *i++ ); 542 Expression *arg2 = *i++; 543 Expression *arg3 = *i++; 544 return new ConditionalExpr( arg1, arg2, arg3 ); 545 } 546 case OperatorNode::NCond: 547 throw UnimplementedError( "GNU 2-argument conditional expression" ); 548 case OperatorNode::Comma: 549 { 550 assert( args.size() == 2); 551 std::list< Expression* >::const_iterator i = args.begin(); 552 Expression *ret = *i++; 553 while ( i != args.end() ) { 554 ret = new CommaExpr( ret, *i++ ); 488 555 } 489 case OperatorNode::AlignOf: 490 case OperatorNode::SizeOf: 491 { 492 /// bool isSizeOf = ( op->get_type() == OperatorNode::SizeOf ); 493 494 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()) ) { 495 return new SizeofExpr( arg->get_decl()->buildType()); 496 } else { 497 return new SizeofExpr( args.front()); 498 } // if 499 } 500 case OperatorNode::Attr: 501 { 502 VarRefNode *var = dynamic_cast<VarRefNode *>( get_args()); 503 assert( var ); 504 if ( ! get_args()->get_link() ) { 505 return new AttrExpr( var->build(), ( Expression*)0); 506 } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link()) ) { 507 return new AttrExpr( var->build(), arg->get_decl()->buildType()); 508 } else { 509 return new AttrExpr( var->build(), args.back()); 510 } // if 511 } 512 case OperatorNode::CompLit: 513 throw UnimplementedError( "C99 compound literals" ); 514 // the short-circuited operators 515 case OperatorNode::Or: 516 case OperatorNode::And: 517 assert( args.size() == 2); 518 return new LogicalExpr( notZeroExpr( args.front() ), notZeroExpr( args.back() ), ( op->get_type() == OperatorNode::And ) ); 519 case OperatorNode::Cond: 520 { 521 assert( args.size() == 3); 522 std::list< Expression* >::const_iterator i = args.begin(); 523 Expression *arg1 = notZeroExpr( *i++ ); 524 Expression *arg2 = *i++; 525 Expression *arg3 = *i++; 526 return new ConditionalExpr( arg1, arg2, arg3 ); 527 } 528 case OperatorNode::NCond: 529 throw UnimplementedError( "GNU 2-argument conditional expression" ); 530 case OperatorNode::Comma: 531 { 532 assert( args.size() == 2); 533 std::list< Expression* >::const_iterator i = args.begin(); 534 Expression *ret = *i++; 535 while ( i != args.end() ) { 536 ret = new CommaExpr( ret, *i++ ); 537 } 538 return ret; 539 } 540 // Tuples 541 case OperatorNode::TupleC: 542 { 543 TupleExpr *ret = new TupleExpr(); 544 std::copy( args.begin(), args.end(), back_inserter( ret->get_exprs() ) ); 545 return ret; 546 } 547 default: 548 // shouldn't happen 549 return 0; 550 } 551 } 556 return ret; 557 } 558 // Tuples 559 case OperatorNode::TupleC: 560 { 561 TupleExpr *ret = new TupleExpr(); 562 std::copy( args.begin(), args.end(), back_inserter( ret->get_exprs() ) ); 563 return ret; 564 } 565 default: 566 // shouldn't happen 567 return 0; 568 } // switch 552 569 } 553 570 … … 598 615 } 599 616 617 //############################################################################## 618 600 619 CommaExprNode::CommaExprNode(): CompositeExprNode( new OperatorNode( OperatorNode::Comma )) {} 601 620 … … 615 634 } 616 635 636 //############################################################################## 637 617 638 ValofExprNode::ValofExprNode( StatementNode *s ): body( s ) {} 618 639 … … 637 658 return new UntypedValofExpr ( get_body()->build(), maybeBuild< Expression >( get_argName() ) ); 638 659 } 660 661 //############################################################################## 639 662 640 663 ForCtlExprNode::ForCtlExprNode( ParseNode *init_, ExpressionNode *cond, ExpressionNode *incr ) throw ( SemanticError ) : condition( cond ), change( incr ) { … … 689 712 } 690 713 691 TypeValueNode::TypeValueNode( DeclarationNode *decl ) 692 : decl( decl ) { 693 } 694 695 TypeValueNode::TypeValueNode( const TypeValueNode &other ) 696 714 //############################################################################## 715 716 TypeValueNode::TypeValueNode( DeclarationNode *decl ) : decl( decl ) { 717 } 718 719 TypeValueNode::TypeValueNode( const TypeValueNode &other ) : ExpressionNode( other ), decl( maybeClone( other.decl ) ) { 697 720 } 698 721 … … 712 735 713 736 ExpressionNode *flattenCommas( ExpressionNode *list ) { 714 if ( CompositeExprNode *composite = dynamic_cast< CompositeExprNode * >( list ) ) 715 { 716 OperatorNode *op; 717 if ( ( op = dynamic_cast< OperatorNode * >( composite->get_function() )) && ( op->get_type() == OperatorNode::Comma ) ) 718 { 719 if ( ExpressionNode *next = dynamic_cast< ExpressionNode * >( list->get_link() ) ) 720 composite->add_arg( next ); 721 return flattenCommas( composite->get_args() ); 722 } 723 } 737 if ( CompositeExprNode *composite = dynamic_cast< CompositeExprNode * >( list ) ) { 738 OperatorNode *op; 739 if ( ( op = dynamic_cast< OperatorNode * >( composite->get_function() )) && ( op->get_type() == OperatorNode::Comma ) ) { 740 if ( ExpressionNode *next = dynamic_cast< ExpressionNode * >( list->get_link() ) ) 741 composite->add_arg( next ); 742 return flattenCommas( composite->get_args() ); 743 } // if 744 } // if 724 745 725 746 if ( ExpressionNode *next = dynamic_cast< ExpressionNode * >( list->get_link() ) ) … … 734 755 if ( ( op = dynamic_cast< OperatorNode * >( composite->get_function() )) && ( op->get_type() == OperatorNode::TupleC ) ) 735 756 return composite->get_args(); 736 } 757 } // if 737 758 return tuple; 738 759 } -
src/Parser/ParseNode.h
r59db689 rcd623a4 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Jun 6 23:35:33201513 // Update Count : 6 012 // Last Modified On : Sun Jun 7 07:42:50 2015 13 // Update Count : 64 14 14 // 15 15 … … 101 101 class ConstantNode : public ExpressionNode { 102 102 public: 103 enum Type { 104 Integer, Float, Character, String /* , Range, EnumConstant */ 105 }; 103 enum Type { Integer, Float, Character, String }; 106 104 107 105 ConstantNode( Type, std::string * ); 108 106 109 107 virtual ConstantNode *clone() const { return new ConstantNode( *this ); } 110 111 Type get_type() const ; 108 Type get_type( void ) const { return type; } 112 109 virtual void print( std::ostream &, int indent = 0) const; 113 110 virtual void printOneLine( std::ostream &, int indent = 0) const; -
src/Parser/lex.cc
r59db689 rcd623a4 1390 1390 * Created On : Sat Sep 22 08:58:10 2001 1391 1391 * Last Modified By : Peter A. Buhr 1392 * Last Modified On : Fri Jun 5 17:50:1720151393 * Update Count : 37 31392 * Last Modified On : Sun Jun 7 07:14:16 2015 1393 * Update Count : 374 1394 1394 */ 1395 1395 #line 19 "lex.ll" … … 1779 1779 ; 1780 1780 YY_BREAK 1781 /* ignore C style comments */1781 /* ignore C style comments (ALSO HANDLED BY CPP) */ 1782 1782 case 3: 1783 1783 YY_RULE_SETUP … … 1796 1796 { BEGIN 0; } 1797 1797 YY_BREAK 1798 /* ignore C++ style comments */1798 /* ignore C++ style comments (ALSO HANDLED BY CPP) */ 1799 1799 case 6: 1800 1800 /* rule 6 can match eol */ … … 2354 2354 YY_RULE_SETUP 2355 2355 #line 299 "lex.ll" 2356 {} // continuation 2356 {} // continuation (ALSO HANDLED BY CPP) 2357 2357 YY_BREAK 2358 2358 case 115: -
src/Parser/lex.ll
r59db689 rcd623a4 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Fri Jun 5 17:50:17201513 * Update Count : 37 312 * Last Modified On : Sun Jun 7 07:14:16 2015 13 * Update Count : 374 14 14 */ 15 15 … … 167 167 ^{h_white}*"#"[^\n]*"\n" ; 168 168 169 /* ignore C style comments */169 /* ignore C style comments (ALSO HANDLED BY CPP) */ 170 170 "/*" { BEGIN COMMENT; } 171 <COMMENT>.|\n 172 <COMMENT>"*/" 173 174 /* ignore C++ style comments */175 "//"[^\n]*"\n" 171 <COMMENT>.|\n ; 172 <COMMENT>"*/" { BEGIN 0; } 173 174 /* ignore C++ style comments (ALSO HANDLED BY CPP) */ 175 "//"[^\n]*"\n" ; 176 176 177 177 /* ignore whitespace */ … … 297 297 /* common character/string constant */ 298 298 <QUOTE,STRING>{escape_seq} { rm_underscore(); *strtext += std::string( yytext ); } 299 <QUOTE,STRING>"\\"{h_white}*"\n" {} // continuation 299 <QUOTE,STRING>"\\"{h_white}*"\n" {} // continuation (ALSO HANDLED BY CPP) 300 300 <QUOTE,STRING>"\\" { *strtext += std::string( yytext ); } // unknown escape character 301 301
Note: See TracChangeset
for help on using the changeset viewer.