Changeset 1b772749 for src/Parser
- Timestamp:
- Sep 16, 2016, 10:48:28 PM (9 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:
- 2298f728
- Parents:
- ba7aa2d
- Location:
- src/Parser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Parser/DeclarationNode.cc ¶
rba7aa2d r1b772749 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Sep 15 23:36:02201613 // Update Count : 5 1512 // Last Modified On : Fri Sep 16 18:17:16 2016 13 // Update Count : 527 14 14 // 15 15 … … 447 447 copyStorageClasses( q ); 448 448 449 if ( ! q->type ) { delete q; return this; } 449 if ( ! q->type ) { 450 delete q; 451 return this; 452 } // if 450 453 451 454 if ( ! type ) { 452 // type = new TypeData; 453 type = q->type; 455 type = q->type; // reuse this structure 456 q->type = nullptr; 457 delete q; 454 458 return this; 455 459 } // if -
TabularUnified src/Parser/ExpressionNode.cc ¶
rba7aa2d r1b772749 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 25 21:39:40201613 // Update Count : 50 312 // Last Modified On : Fri Sep 16 16:27:44 2016 13 // Update Count : 508 14 14 // 15 15 … … 31 31 32 32 using namespace std; 33 34 ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.get_name() ), extension( other.extension ) {}35 33 36 34 //############################################################################## -
TabularUnified src/Parser/ParseNode.h ¶
rba7aa2d r1b772749 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 12 08:00:05201613 // Update Count : 6 0312 // Last Modified On : Fri Sep 16 15:02:38 2016 13 // Update Count : 613 14 14 // 15 15 … … 41 41 public: 42 42 ParseNode() {}; 43 ParseNode( const std::string * name ) : name( * name ) { assert( false ); delete name; }44 ParseNode( const std::string &name ) : name( name ) { assert( false ); }45 43 virtual ~ParseNode() { delete next; }; 46 44 virtual ParseNode * clone() const = 0; … … 48 46 ParseNode * get_next() const { return next; } 49 47 ParseNode * set_next( ParseNode * newlink ) { next = newlink; return this; } 48 50 49 ParseNode * get_last() { 51 50 ParseNode * current; … … 58 57 } 59 58 60 const std::string &get_name() const { return name; }61 void set_name( const std::string &newValue ) { name = newValue; }62 63 59 virtual void print( std::ostream &os, int indent = 0 ) const {} 64 60 virtual void printList( std::ostream &os, int indent = 0 ) const {} 65 private: 61 66 62 static int indent_by; 67 63 … … 106 102 public: 107 103 ExpressionNode( Expression * expr = nullptr ) : expr( expr ) {} 108 ExpressionNode( Expression * expr, const std::string * name ) : ParseNode( name ), expr( expr ) {}109 104 ExpressionNode( const ExpressionNode &other ); 110 105 virtual ~ExpressionNode() {} … … 286 281 287 282 bool get_hasEllipsis() const; 288 const std::string &get_name() const { return name; }289 283 LinkageSpec::Spec get_linkage() const { return linkage; } 290 284 DeclarationNode * extractAggregate() const; … … 295 289 DeclarationNode * set_extension( bool exten ) { extension = exten; return this; } 296 290 public: 297 // StorageClass buildStorageClass() const;298 // bool buildFuncSpecifier( StorageClass key ) const;299 300 291 struct Variable_t { 301 292 DeclarationNode::TypeClass tyClass; … … 315 306 316 307 TypeData * type; 317 std::string name;318 308 StorageClass storageClass; 319 309 bool isInline, isNoreturn; … … 331 321 332 322 Type * buildType( TypeData * type ); 333 //Type::Qualifiers buildQualifiers( const TypeData::Qualifiers & qualifiers );334 323 335 324 static inline Type * maybeMoveBuildType( const DeclarationNode * orig ) { -
TabularUnified src/Parser/TypeData.cc ¶
rba7aa2d r1b772749 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Sep 15 23:05:01201613 // Update Count : 38 412 // Last Modified On : Fri Sep 16 15:12:55 2016 13 // Update Count : 388 14 14 // 15 15 … … 763 763 } // buildTypeof 764 764 765 AttrType * buildAttr( const TypeData * td ) {766 assert( false );767 return nullptr;768 // assert( td->kind == TypeData::Attr );769 // // assert( td->attr );770 // AttrType * ret;771 // if ( td->attr.expr ) {772 // ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.expr->build() );773 // } else {774 // assert( td->attr.type );775 // ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.type->buildType() );776 // } // if777 // return ret;778 } // buildAttr779 780 765 Declaration * buildDecl( const TypeData * td, std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init ) { 781 766 if ( td->kind == TypeData::Function ) { … … 795 780 } // if 796 781 for ( DeclarationNode * cur = td->function.idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) { 797 if ( cur-> get_name()!= "" ) {798 decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur-> get_name());782 if ( cur->name != "" ) { 783 decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur->name ); 799 784 } // if 800 785 } // for -
TabularUnified src/Parser/TypeData.h ¶
rba7aa2d r1b772749 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 12 17:15:49201613 // Update Count : 1 2912 // Last Modified On : Fri Sep 16 15:17:31 2016 13 // Update Count : 131 14 14 // 15 15 … … 88 88 DeclarationNode * tuple; 89 89 ExpressionNode * typeexpr; 90 // Attr_t attr;91 90 // DeclarationNode::BuiltinType builtin; 92 91 … … 111 110 TupleType * buildTuple( const TypeData * ); 112 111 TypeofType * buildTypeof( const TypeData * ); 113 AttrType * buildAttr( const TypeData * );114 112 Declaration * buildDecl( const TypeData *, std::string, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = 0 ); 115 113 FunctionType * buildFunction( const TypeData * ); -
TabularUnified src/Parser/parser.yy ¶
rba7aa2d r1b772749 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 12 17:29:45201613 // Update Count : 19 6912 // Last Modified On : Fri Sep 16 18:12:21 2016 13 // Update Count : 1978 14 14 // 15 15 … … 359 359 { $$ = $2; } 360 360 | '(' compound_statement ')' // GCC, lambda expression 361 { $$ = new ExpressionNode( build_valexpr( $2 ) ); }361 { $$ = new ExpressionNode( build_valexpr( $2 ) ); } 362 362 ; 363 363 … … 896 896 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 897 897 | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop 898 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }898 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); } 899 899 | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 900 900 { $$ = new StatementNode( build_catch( $5, $8 ) ); } … … 968 968 { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); } 969 969 | '[' constant_expression ']' string_literal '(' constant_expression ')' 970 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }970 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); } 971 971 ; 972 972 … … 1467 1467 aggregate_name: 1468 1468 aggregate_key '{' field_declaration_list '}' 1469 { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3, true ); }1469 { $$ = DeclarationNode::newAggregate( $1, new std::string( "" ), nullptr, $3, true ); } 1470 1470 | aggregate_key no_attr_identifier_or_type_name 1471 1471 { … … 1476 1476 { typedefTable.makeTypedef( *$2 ); } 1477 1477 '{' field_declaration_list '}' 1478 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5, true ); }1478 { $$ = DeclarationNode::newAggregate( $1, $2, nullptr, $5, true ); } 1479 1479 | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1480 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6, false ); }1480 { $$ = DeclarationNode::newAggregate( $1, new std::string( "" ), $3, $6, false ); } 1481 1481 | aggregate_key typegen_name // CFA, S/R conflict 1482 1482 { $$ = $2; } … … 1559 1559 enum_name: 1560 1560 enum_key '{' enumerator_list comma_opt '}' 1561 { $$ = DeclarationNode::newEnum( 0, $3 ); }1561 { $$ = DeclarationNode::newEnum( new std::string( "" ), $3 ); } 1562 1562 | enum_key no_attr_identifier_or_type_name 1563 1563 { … … 2520 2520 abstract_function: 2521 2521 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2522 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0); }2522 { $$ = DeclarationNode::newFunction( new std::string( "" ), nullptr, $3, nullptr ); } 2523 2523 | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2524 2524 { $$ = $2->addParamList( $6 ); } … … 2589 2589 abstract_parameter_function: 2590 2590 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2591 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0); }2591 { $$ = DeclarationNode::newFunction( new std::string( "" ), nullptr, $3, nullptr ); } 2592 2592 | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2593 2593 { $$ = $2->addParamList( $6 ); } … … 2813 2813 new_abstract_function: // CFA 2814 2814 '[' ']' '(' new_parameter_type_list_opt ')' 2815 { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $4, 0); }2815 { $$ = DeclarationNode::newFunction( new std::string( "" ), DeclarationNode::newTuple( nullptr ), $4, nullptr ); } 2816 2816 | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')' 2817 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0); }2817 { $$ = DeclarationNode::newFunction( new std::string( "" ), $1, $4, nullptr ); } 2818 2818 | new_function_return '(' push new_parameter_type_list_opt pop ')' 2819 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0); }2819 { $$ = DeclarationNode::newFunction( new std::string( "" ), $1, $4, nullptr ); } 2820 2820 ; 2821 2821
Note: See TracChangeset
for help on using the changeset viewer.