00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __ast_h
00021 #define __ast_h
00022
00023 #include <memory>
00024 #include <qstring.h>
00025 #include <qptrlist.h>
00026
00027 #if defined( Q_OS_WIN32 ) || defined( Q_CC_SUN )
00028
00029 #ifndef _THROW0
00030 # define _THROW0()
00031 #endif
00032
00033 template <class _Tp> class AUTO_PTR {
00034 private:
00035 _Tp* _M_ptr;
00036
00037 public:
00038 typedef _Tp element_type;
00039
00040 explicit AUTO_PTR(_Tp* __p = 0) _THROW0() : _M_ptr(__p) {}
00041
00042 template <class _Tp1> AUTO_PTR(AUTO_PTR<_Tp1>& __a) _THROW0()
00043 : _M_ptr(__a.release()) {}
00044
00045 AUTO_PTR(AUTO_PTR& __a) _THROW0() : _M_ptr(__a.release()) {}
00046
00047
00048
00049 template <class _Tp1>
00050 AUTO_PTR& operator=(AUTO_PTR<_Tp1>& __a) _THROW0() {
00051 if (__a.get() != this->get()) {
00052 delete _M_ptr;
00053 _M_ptr = __a.release();
00054 }
00055 return *this;
00056 }
00057
00058 AUTO_PTR& operator=(AUTO_PTR& __a) _THROW0() {
00059 if (&__a != this) {
00060 delete _M_ptr;
00061 _M_ptr = __a.release();
00062 }
00063 return *this;
00064 }
00065
00066 ~AUTO_PTR() _THROW0() { delete _M_ptr; }
00067
00068 _Tp& operator*() const _THROW0() {
00069 return *_M_ptr;
00070 }
00071 _Tp* operator->() const _THROW0() {
00072 return _M_ptr;
00073 }
00074 _Tp* get() const _THROW0() {
00075 return _M_ptr;
00076 }
00077 _Tp* release() _THROW0() {
00078 _Tp* __tmp = _M_ptr;
00079 _M_ptr = 0;
00080 return __tmp;
00081 }
00082 void reset(_Tp* __p = 0) _THROW0() {
00083 delete _M_ptr;
00084 _M_ptr = __p;
00085 }
00086
00087
00088
00089
00090
00091
00092
00093 private:
00094 template<class _Tp1> struct AUTO_PTR_ref {
00095 _Tp1* _M_ptr;
00096 AUTO_PTR_ref(_Tp1* __p) : _M_ptr(__p) {}
00097 };
00098
00099 public:
00100 AUTO_PTR(AUTO_PTR_ref<_Tp> __ref) _THROW0()
00101 : _M_ptr(__ref._M_ptr) {}
00102 template <class _Tp1> operator AUTO_PTR_ref<_Tp1>() _THROW0()
00103 { return AUTO_PTR_ref<_Tp>(this->release()); }
00104 template <class _Tp1> operator AUTO_PTR<_Tp1>() _THROW0()
00105 { return AUTO_PTR<_Tp1>(this->release()) }
00106
00107 };
00108
00109 #else
00110 #define AUTO_PTR std::auto_ptr
00111 #endif
00112
00113 template <class T> typename T::Node CreateNode()
00114 {
00115 typename T::Node node( new T );
00116 node->setNodeType( T::Type );
00117 return node;
00118 }
00119
00120 template <class T> typename T::Node NullNode()
00121 {
00122 typename T::Node node;
00123 return node;
00124 }
00125
00126 enum NodeType
00127 {
00128 NodeType_Generic = 0,
00129
00130 NodeType_TemplateArgumentList = 1000,
00131 NodeType_ClassOrNamespaceName,
00132 NodeType_Name,
00133 NodeType_Declaration,
00134 NodeType_TypeSpecifier,
00135 NodeType_BaseSpecifier,
00136 NodeType_BaseClause,
00137 NodeType_ClassSpecifier,
00138 NodeType_Enumerator,
00139 NodeType_EnumSpecifier,
00140 NodeType_ElaboratedTypeSpecifier,
00141 NodeType_LinkageBody,
00142 NodeType_LinkageSpecification,
00143 NodeType_Namespace,
00144 NodeType_NamespaceAlias,
00145 NodeType_Using,
00146 NodeType_UsingDirective,
00147 NodeType_InitDeclaratorList,
00148 NodeType_Typedef,
00149 NodeType_Declarator,
00150 NodeType_InitDeclarator,
00151 NodeType_TemplateDeclaration,
00152 NodeType_SimpleDeclaration,
00153 NodeType_Statement,
00154 NodeType_StatementList,
00155 NodeType_IfStatement,
00156 NodeType_WhileStatement,
00157 NodeType_DoStatement,
00158 NodeType_ForStatement,
00159 NodeType_SwitchStatement,
00160 NodeType_DeclarationStatement,
00161 NodeType_TranslationUnit,
00162 NodeType_FunctionDefinition,
00163 NodeType_ExpressionStatement,
00164 NodeType_ParameterDeclaration,
00165 NodeType_ParameterDeclarationList,
00166 NodeType_ParameterDeclarationClause,
00167 NodeType_Group,
00168 NodeType_AccessDeclaration,
00169 NodeType_TypeParameter,
00170 NodeType_TemplateParameter,
00171 NodeType_TemplateParameterList,
00172 NodeType_Condition,
00173
00174 NodeType_Custom = 2000
00175 };
00176
00177 QString nodeTypeToString( int type );
00178
00179
00180 #if defined(CPPPARSER_QUICK_ALLOCATOR)
00181
00182 #include <quick_allocator.h>
00183
00184 #define DECLARE_ALLOC(tp) \
00185 void * operator new(std::size_t) \
00186 { \
00187 return quick_allocator< tp >::alloc(); \
00188 } \
00189 \
00190 void operator delete(void * p) \
00191 { \
00192 quick_allocator< tp >::dealloc(p); \
00193 }
00194 #else
00195
00196 #define DECLARE_ALLOC(tp)
00197
00198 #endif
00199
00200 struct Slice
00201 {
00202 QString source;
00203 int position;
00204 int length;
00205
00206 inline Slice()
00207 : position(0), length(0) {}
00208 };
00209
00210 class AST
00211 {
00212 public:
00213 typedef AUTO_PTR<AST> Node;
00214 enum { Type=NodeType_Generic };
00215
00216 DECLARE_ALLOC( AST )
00217
00218 public:
00219 AST();
00220 virtual ~AST();
00221
00222 int nodeType() const { return m_nodeType; }
00223 void setNodeType( int nodeType ) { m_nodeType = nodeType; }
00224
00225 AST* parent() { return m_parent; }
00226 void setParent( AST* parent );
00227
00228 void setStartPosition( int line, int col );
00229 void getStartPosition( int* line, int* col ) const;
00230
00231 void setEndPosition( int line, int col );
00232 void getEndPosition( int* line, int* col ) const;
00233
00234 #ifndef CPPPARSER_NO_CHILDREN
00235 QPtrList<AST> children() { return m_children; }
00236 void appendChild( AST* child );
00237 void removeChild( AST* child );
00238 #endif
00239
00240 virtual inline QString text() const
00241 { return m_slice.source.mid(m_slice.position, m_slice.length); }
00242
00243 QString comment() const
00244 { return m_comment; }
00245
00246 inline void setSlice( const Slice& slice )
00247 { m_slice = slice; }
00248
00249 inline void setSlice( const QString &text, int position, int length )
00250 {
00251 m_slice.source = text;
00252 m_slice.position = position;
00253 m_slice.length = length;
00254 }
00255
00256 inline void setText(const QString &text)
00257 { setSlice(text, 0, text.length()); }
00258
00259 void setComment( const QString &comment )
00260 { m_comment = comment; }
00261
00262 private:
00263 int m_nodeType;
00264 AST* m_parent;
00265 int m_startLine, m_startColumn;
00266 int m_endLine, m_endColumn;
00267 Slice m_slice;
00268 #ifndef CPPPARSER_NO_CHILDREN
00269 QPtrList<AST> m_children;
00270 #endif
00271 QString m_comment;
00272
00273 private:
00274 AST( const AST& source );
00275 void operator = ( const AST& source );
00276 };
00277
00278 class GroupAST: public AST
00279 {
00280 public:
00281 typedef AUTO_PTR<GroupAST> Node;
00282 enum { Type = NodeType_Group };
00283
00284 DECLARE_ALLOC( GroupAST )
00285
00286 public:
00287 GroupAST();
00288
00289 QPtrList<AST> nodeList() { return m_nodeList; }
00290 void addNode( AST::Node& node );
00291
00292 virtual QString text() const;
00293
00294 private:
00295 QPtrList<AST> m_nodeList;
00296
00297 private:
00298 GroupAST( const GroupAST& source );
00299 void operator = ( const GroupAST& source );
00300 };
00301
00302
00303 class TemplateArgumentListAST: public AST
00304 {
00305 public:
00306 typedef AUTO_PTR<TemplateArgumentListAST> Node;
00307 enum { Type = NodeType_TemplateArgumentList };
00308
00309 DECLARE_ALLOC( TemplateArgumentListAST )
00310
00311 public:
00312 TemplateArgumentListAST();
00313
00314 void addArgument( AST::Node& arg );
00315 QPtrList<AST> argumentList() { return m_argumentList; }
00316
00317 virtual QString text() const;
00318
00319 private:
00320 QPtrList<AST> m_argumentList;
00321
00322 private:
00323 TemplateArgumentListAST( const TemplateArgumentListAST& source );
00324 void operator = ( const TemplateArgumentListAST& source );
00325 };
00326
00327 class ClassOrNamespaceNameAST: public AST
00328 {
00329 public:
00330 typedef AUTO_PTR<ClassOrNamespaceNameAST> Node;
00331 enum { Type = NodeType_ClassOrNamespaceName };
00332
00333 DECLARE_ALLOC( ClassOrNamespaceNameAST )
00334
00335 public:
00336 ClassOrNamespaceNameAST();
00337
00338 AST* name() { return m_name.get(); }
00339 void setName( AST::Node& name );
00340
00341 TemplateArgumentListAST* templateArgumentList() { return m_templateArgumentList.get(); }
00342 void setTemplateArgumentList( TemplateArgumentListAST::Node& templateArgumentList );
00343
00344 virtual QString text() const;
00345
00346 private:
00347 AST::Node m_name;
00348 TemplateArgumentListAST::Node m_templateArgumentList;
00349
00350 private:
00351 ClassOrNamespaceNameAST( const ClassOrNamespaceNameAST& source );
00352 void operator = ( const ClassOrNamespaceNameAST& source );
00353 };
00354
00355 class NameAST: public AST
00356 {
00357 public:
00358 typedef AUTO_PTR<NameAST> Node;
00359 enum { Type = NodeType_Name };
00360
00361 DECLARE_ALLOC( NameAST )
00362
00363 public:
00364 NameAST();
00365
00366 bool isGlobal() const { return m_global; }
00367 void setGlobal( bool b );
00368
00369 void addClassOrNamespaceName( ClassOrNamespaceNameAST::Node& classOrNamespaceName );
00370 QPtrList<ClassOrNamespaceNameAST> classOrNamespaceNameList() { return m_classOrNamespaceNameList; }
00371
00372 ClassOrNamespaceNameAST* unqualifiedName() { return m_unqualifiedName.get(); }
00373 void setUnqualifiedName( ClassOrNamespaceNameAST::Node& unqualifiedName );
00374
00375 virtual QString text() const;
00376
00377 private:
00378 bool m_global;
00379 ClassOrNamespaceNameAST::Node m_unqualifiedName;
00380 QPtrList<ClassOrNamespaceNameAST> m_classOrNamespaceNameList;
00381
00382 private:
00383 NameAST( const NameAST& source );
00384 void operator = ( const NameAST& source );
00385 };
00386
00387 class TypeParameterAST: public AST
00388 {
00389 public:
00390 typedef AUTO_PTR<TypeParameterAST> Node;
00391 enum { Type = NodeType_TypeParameter };
00392
00393 DECLARE_ALLOC( TypeParameterAST )
00394
00395 public:
00396 TypeParameterAST();
00397
00398 AST* kind() { return m_kind.get(); }
00399 void setKind( AST::Node& kind );
00400
00401 class TemplateParameterListAST* templateParameterList() { return m_templateParameterList.get(); }
00402 void setTemplateParameterList( AUTO_PTR<class TemplateParameterListAST>& templateParameterList );
00403
00404 NameAST* name() { return m_name.get(); }
00405 void setName( NameAST::Node& name );
00406
00407 AST* typeId() { return m_typeId.get(); }
00408 void setTypeId( AST::Node& typeId );
00409
00410 private:
00411 AST::Node m_kind;
00412 AUTO_PTR<class TemplateParameterListAST> m_templateParameterList;
00413 NameAST::Node m_name;
00414 AST::Node m_typeId;
00415
00416 private:
00417 TypeParameterAST( const TypeParameterAST& source );
00418 void operator = ( const TypeParameterAST& source );
00419 };
00420
00421 class DeclarationAST: public AST
00422 {
00423 public:
00424 typedef AUTO_PTR<DeclarationAST> Node;
00425 enum { Type = NodeType_Declaration };
00426
00427 DECLARE_ALLOC( DeclarationAST )
00428
00429 public:
00430 DeclarationAST();
00431
00432 private:
00433 DeclarationAST( const DeclarationAST& source );
00434 void operator = ( const DeclarationAST& source );
00435 };
00436
00437 class AccessDeclarationAST: public DeclarationAST
00438 {
00439 public:
00440 typedef AUTO_PTR<AccessDeclarationAST> Node;
00441 enum { Type = NodeType_AccessDeclaration };
00442
00443 DECLARE_ALLOC( AccessDeclarationAST )
00444
00445 public:
00446 AccessDeclarationAST();
00447
00448 QPtrList<AST> accessList() { return m_accessList; }
00449 void addAccess( AST::Node& access );
00450
00451 virtual QString text() const;
00452
00453 private:
00454 QPtrList<AST> m_accessList;
00455
00456 private:
00457 AccessDeclarationAST( const AccessDeclarationAST& source );
00458 void operator = ( const AccessDeclarationAST& source );
00459 };
00460
00461 class TypeSpecifierAST: public AST
00462 {
00463 public:
00464 typedef AUTO_PTR<TypeSpecifierAST> Node;
00465 enum { Type = NodeType_TypeSpecifier };
00466
00467 DECLARE_ALLOC( TypeSpecifierAST )
00468
00469 public:
00470 TypeSpecifierAST();
00471
00472 virtual NameAST* name() { return m_name.get(); }
00473 virtual void setName( NameAST::Node& name );
00474
00475 GroupAST* cvQualify() { return m_cvQualify.get(); }
00476 void setCvQualify( GroupAST::Node& cvQualify );
00477
00478 GroupAST* cv2Qualify() { return m_cv2Qualify.get(); }
00479 void setCv2Qualify( GroupAST::Node& cv2Qualify );
00480
00481 virtual QString text() const;
00482
00483 private:
00484 NameAST::Node m_name;
00485 GroupAST::Node m_cvQualify;
00486 GroupAST::Node m_cv2Qualify;
00487
00488 private:
00489 TypeSpecifierAST( const TypeSpecifierAST& source );
00490 void operator = ( const TypeSpecifierAST& source );
00491 };
00492
00493 class BaseSpecifierAST: public AST
00494 {
00495 public:
00496 typedef AUTO_PTR<BaseSpecifierAST> Node;
00497 enum { Type = NodeType_BaseSpecifier };
00498
00499 DECLARE_ALLOC( BaseSpecifierAST )
00500
00501 public:
00502 BaseSpecifierAST();
00503
00504 AST* isVirtual() { return m_isVirtual.get(); }
00505 void setIsVirtual( AST::Node& isVirtual );
00506
00507 AST* access() { return m_access.get(); }
00508 void setAccess( AST::Node& access );
00509
00510 NameAST* name() { return m_name.get(); }
00511 void setName( NameAST::Node& name );
00512
00513 private:
00514 AST::Node m_isVirtual;
00515 AST::Node m_access;
00516 NameAST::Node m_name;
00517
00518 private:
00519 BaseSpecifierAST( const BaseSpecifierAST& source );
00520 void operator = ( const BaseSpecifierAST& source );
00521 };
00522
00523 class BaseClauseAST: public AST
00524 {
00525 public:
00526 typedef AUTO_PTR<BaseClauseAST> Node;
00527 enum { Type = NodeType_BaseClause };
00528
00529 DECLARE_ALLOC( BaseClauseAST )
00530
00531 public:
00532 BaseClauseAST();
00533
00534 void addBaseSpecifier( BaseSpecifierAST::Node& baseSpecifier );
00535 QPtrList<BaseSpecifierAST> baseSpecifierList() { return m_baseSpecifierList; }
00536
00537 private:
00538 QPtrList<BaseSpecifierAST> m_baseSpecifierList;
00539
00540 private:
00541 BaseClauseAST( const BaseClauseAST& source );
00542 void operator = ( const BaseClauseAST& source );
00543 };
00544
00545 class ClassSpecifierAST: public TypeSpecifierAST
00546 {
00547 public:
00548 typedef AUTO_PTR<ClassSpecifierAST> Node;
00549 enum { Type = NodeType_ClassSpecifier };
00550
00551 DECLARE_ALLOC( ClassSpecifierAST )
00552
00553 public:
00554 ClassSpecifierAST();
00555
00556 GroupAST* winDeclSpec() { return m_winDeclSpec.get(); }
00557 void setWinDeclSpec( GroupAST::Node& winDeclSpec );
00558
00559 AST* classKey() { return m_classKey.get(); }
00560 void setClassKey( AST::Node& classKey );
00561
00562 BaseClauseAST* baseClause() { return m_baseClause.get(); }
00563 void setBaseClause( BaseClauseAST::Node& baseClause );
00564
00565 QPtrList<DeclarationAST> declarationList() { return m_declarationList; }
00566 void addDeclaration( DeclarationAST::Node& declaration );
00567
00568 private:
00569 GroupAST::Node m_winDeclSpec;
00570 AST::Node m_classKey;
00571 BaseClauseAST::Node m_baseClause;
00572 QPtrList<DeclarationAST> m_declarationList;
00573
00574 private:
00575 ClassSpecifierAST( const ClassSpecifierAST& source );
00576 void operator = ( const ClassSpecifierAST& source );
00577 };
00578
00579 class EnumeratorAST: public AST
00580 {
00581 public:
00582 typedef AUTO_PTR<EnumeratorAST> Node;
00583 enum { Type = NodeType_Enumerator };
00584
00585 DECLARE_ALLOC( EnumeratorAST )
00586
00587 public:
00588 EnumeratorAST();
00589
00590 AST* id() { return m_id.get(); }
00591 void setId( AST::Node& id );
00592
00593 AST* expr() { return m_expr.get(); }
00594 void setExpr( AST::Node& expr );
00595
00596 private:
00597 AST::Node m_id;
00598 AST::Node m_expr;
00599
00600 private:
00601 EnumeratorAST( const EnumeratorAST& source );
00602 void operator = ( const EnumeratorAST& source );
00603 };
00604
00605 class EnumSpecifierAST: public TypeSpecifierAST
00606 {
00607 public:
00608 typedef AUTO_PTR<EnumSpecifierAST> Node;
00609 enum { Type = NodeType_EnumSpecifier };
00610
00611 DECLARE_ALLOC( EnumSpecifierAST )
00612
00613 public:
00614 EnumSpecifierAST();
00615
00616 void addEnumerator( EnumeratorAST::Node& enumerator );
00617 QPtrList<EnumeratorAST> enumeratorList() { return m_enumeratorList; }
00618
00619 private:
00620 QPtrList<EnumeratorAST> m_enumeratorList;
00621
00622 private:
00623 EnumSpecifierAST( const EnumSpecifierAST& source );
00624 void operator = ( const EnumSpecifierAST& source );
00625 };
00626
00627 class ElaboratedTypeSpecifierAST: public TypeSpecifierAST
00628 {
00629 public:
00630 typedef AUTO_PTR<ElaboratedTypeSpecifierAST> Node;
00631 enum { Type = NodeType_ElaboratedTypeSpecifier };
00632
00633 DECLARE_ALLOC( ElaboratedTypeSpecifierAST )
00634
00635 public:
00636 ElaboratedTypeSpecifierAST();
00637
00638 AST* kind() { return m_kind.get(); }
00639 void setKind( AST::Node& kind );
00640
00641 virtual QString text() const;
00642
00643 private:
00644 AST::Node m_kind;
00645
00646 private:
00647 ElaboratedTypeSpecifierAST( const ElaboratedTypeSpecifierAST& source );
00648 void operator = ( const ElaboratedTypeSpecifierAST& source );
00649 };
00650
00651
00652 class LinkageBodyAST: public AST
00653 {
00654 public:
00655 typedef AUTO_PTR<LinkageBodyAST> Node;
00656 enum { Type = NodeType_LinkageBody };
00657
00658 DECLARE_ALLOC( LinkageBodyAST )
00659
00660 public:
00661 LinkageBodyAST();
00662
00663 void addDeclaration( DeclarationAST::Node& ast );
00664 QPtrList<DeclarationAST> declarationList() { return m_declarationList; }
00665
00666 private:
00667 QPtrList<DeclarationAST> m_declarationList;
00668
00669 private:
00670 LinkageBodyAST( const LinkageBodyAST& source );
00671 void operator = ( const LinkageBodyAST& source );
00672 };
00673
00674 class LinkageSpecificationAST: public DeclarationAST
00675 {
00676 public:
00677 typedef AUTO_PTR<LinkageSpecificationAST> Node;
00678 enum { Type = NodeType_LinkageSpecification };
00679
00680 DECLARE_ALLOC( LinkageSpecificationAST )
00681
00682 public:
00683 LinkageSpecificationAST();
00684
00685 AST* externType() { return m_externType.get(); }
00686 void setExternType( AST::Node& externType );
00687
00688 LinkageBodyAST* linkageBody() { return m_linkageBody.get(); }
00689 void setLinkageBody( LinkageBodyAST::Node& linkageBody );
00690
00691 DeclarationAST* declaration() { return m_declaration.get(); }
00692 void setDeclaration( DeclarationAST::Node& decl );
00693
00694 private:
00695 AST::Node m_externType;
00696 LinkageBodyAST::Node m_linkageBody;
00697 DeclarationAST::Node m_declaration;
00698
00699 private:
00700 LinkageSpecificationAST( const LinkageSpecificationAST& source );
00701 void operator = ( const LinkageSpecificationAST& source );
00702 };
00703
00704 class NamespaceAST: public DeclarationAST
00705 {
00706 public:
00707 typedef AUTO_PTR<NamespaceAST> Node;
00708 enum { Type = NodeType_Namespace };
00709
00710 DECLARE_ALLOC( NamespaceAST )
00711
00712 public:
00713 NamespaceAST();
00714
00715 AST* namespaceName() { return m_namespaceName.get(); }
00716 void setNamespaceName( AST::Node& namespaceName );
00717
00718 LinkageBodyAST* linkageBody() { return m_linkageBody.get(); }
00719 void setLinkageBody( LinkageBodyAST::Node& linkageBody );
00720
00721 private:
00722 AST::Node m_namespaceName;
00723 LinkageBodyAST::Node m_linkageBody;
00724
00725 private:
00726 NamespaceAST( const NamespaceAST& source );
00727 void operator = ( const NamespaceAST& source );
00728 };
00729
00730 class NamespaceAliasAST: public DeclarationAST
00731 {
00732 public:
00733 typedef AUTO_PTR<NamespaceAliasAST> Node;
00734 enum { Type = NodeType_NamespaceAlias };
00735
00736 DECLARE_ALLOC( NamespaceAliasAST )
00737
00738 public:
00739 NamespaceAliasAST();
00740
00741 AST* namespaceName() { return m_namespaceName.get(); }
00742 void setNamespaceName( AST::Node& name );
00743
00744 NameAST* aliasName() { return m_aliasName.get(); }
00745 void setAliasName( NameAST::Node& name );
00746
00747 private:
00748 AST::Node m_namespaceName;
00749 NameAST::Node m_aliasName;
00750
00751 private:
00752 NamespaceAliasAST( const NamespaceAliasAST& source );
00753 void operator = ( const NamespaceAliasAST& source );
00754 };
00755
00756 class UsingAST: public DeclarationAST
00757 {
00758 public:
00759 typedef AUTO_PTR<UsingAST> Node;
00760 enum { Type = NodeType_Using };
00761
00762 DECLARE_ALLOC( UsingAST )
00763
00764 public:
00765 UsingAST();
00766
00767 AST* typeName() { return m_typeName.get(); }
00768 void setTypeName( AST::Node& typeName );
00769
00770 NameAST* name() { return m_name.get(); }
00771 void setName( NameAST::Node& name );
00772
00773 private:
00774 AST::Node m_typeName;
00775 NameAST::Node m_name;
00776
00777 private:
00778 UsingAST( const UsingAST& source );
00779 void operator = ( const UsingAST& source );
00780 };
00781
00782 class UsingDirectiveAST: public DeclarationAST
00783 {
00784 public:
00785 typedef AUTO_PTR<UsingDirectiveAST> Node;
00786 enum { Type = NodeType_UsingDirective };
00787
00788 DECLARE_ALLOC( UsingDirectiveAST )
00789
00790 public:
00791 UsingDirectiveAST();
00792
00793 NameAST* name() { return m_name.get(); }
00794 void setName( NameAST::Node& name );
00795
00796 private:
00797 NameAST::Node m_name;
00798
00799 private:
00800 UsingDirectiveAST( const UsingDirectiveAST& source );
00801 void operator = ( const UsingDirectiveAST& source );
00802 };
00803
00804 class DeclaratorAST: public AST
00805 {
00806 public:
00807 typedef AUTO_PTR<DeclaratorAST> Node;
00808 enum { Type = NodeType_Declarator };
00809
00810 DECLARE_ALLOC( DeclaratorAST )
00811
00812 public:
00813 DeclaratorAST();
00814
00815 QPtrList<AST> ptrOpList() { return m_ptrOpList; }
00816 void addPtrOp( AST::Node& ptrOp );
00817
00818 DeclaratorAST* subDeclarator() { return m_subDeclarator.get(); }
00819 void setSubDeclarator( Node& subDeclarator );
00820
00821 NameAST* declaratorId() { return m_declaratorId.get(); }
00822 void setDeclaratorId( NameAST::Node& declaratorId );
00823
00824 AST* bitfieldInitialization() { return m_bitfieldInitialization.get(); }
00825 void setBitfieldInitialization( AST::Node& bitfieldInitialization );
00826
00827 QPtrList<AST> arrayDimensionList() { return m_arrayDimensionList; }
00828 void addArrayDimension( AST::Node& arrayDimension );
00829
00830 class ParameterDeclarationClauseAST* parameterDeclarationClause() { return m_parameterDeclarationClause.get(); }
00831 void setParameterDeclarationClause( AUTO_PTR<class ParameterDeclarationClauseAST>& parameterDeclarationClause );
00832
00833
00834 AST* constant() { return m_constant.get(); }
00835 void setConstant( AST::Node& constant );
00836
00837 GroupAST* exceptionSpecification() { return m_exceptionSpecification.get(); }
00838 void setExceptionSpecification( GroupAST::Node& exceptionSpecification );
00839
00840 private:
00841 QPtrList<AST> m_ptrOpList;
00842 Node m_subDeclarator;
00843 NameAST::Node m_declaratorId;
00844 AST::Node m_bitfieldInitialization;
00845 QPtrList<AST> m_arrayDimensionList;
00846 AUTO_PTR<class ParameterDeclarationClauseAST> m_parameterDeclarationClause;
00847 AST::Node m_constant;
00848 GroupAST::Node m_exceptionSpecification;
00849
00850 private:
00851 DeclaratorAST( const DeclaratorAST& source );
00852 void operator = ( const DeclaratorAST& source );
00853 };
00854
00855 class ParameterDeclarationAST: public AST
00856 {
00857 public:
00858 typedef AUTO_PTR<ParameterDeclarationAST> Node;
00859 enum { Type = NodeType_ParameterDeclaration };
00860
00861 DECLARE_ALLOC( ParameterDeclarationAST )
00862
00863 public:
00864 ParameterDeclarationAST();
00865
00866 TypeSpecifierAST* typeSpec() { return m_typeSpec.get(); }
00867 void setTypeSpec( TypeSpecifierAST::Node& typeSpec );
00868
00869 DeclaratorAST* declarator() { return m_declarator.get(); }
00870 void setDeclarator( DeclaratorAST::Node& declarator );
00871
00872 AST* expression() { return m_expression.get(); }
00873 void setExpression( AST::Node& expression );
00874
00875 virtual QString text() const;
00876
00877 private:
00878 TypeSpecifierAST::Node m_typeSpec;
00879 DeclaratorAST::Node m_declarator;
00880 AST::Node m_expression;
00881
00882 private:
00883 ParameterDeclarationAST( const ParameterDeclarationAST& source );
00884 void operator = ( const ParameterDeclarationAST& source );
00885 };
00886
00887 class ParameterDeclarationListAST: public AST
00888 {
00889 public:
00890 typedef AUTO_PTR<ParameterDeclarationListAST> Node;
00891 enum { Type = NodeType_ParameterDeclarationList };
00892
00893 DECLARE_ALLOC( ParameterDeclarationListAST )
00894
00895 public:
00896 ParameterDeclarationListAST();
00897
00898 QPtrList<ParameterDeclarationAST> parameterList() { return m_parameterList; }
00899 void addParameter( ParameterDeclarationAST::Node& parameter );
00900
00901 virtual QString text() const;
00902
00903 private:
00904 QPtrList<ParameterDeclarationAST> m_parameterList;
00905
00906 private:
00907 ParameterDeclarationListAST( const ParameterDeclarationListAST& source );
00908 void operator = ( const ParameterDeclarationListAST& source );
00909 };
00910
00911 class ParameterDeclarationClauseAST: public AST
00912 {
00913 public:
00914 typedef AUTO_PTR<ParameterDeclarationClauseAST> Node;
00915 enum { Type = NodeType_ParameterDeclarationClause };
00916
00917 DECLARE_ALLOC( ParameterDeclarationClauseAST )
00918
00919 public:
00920 ParameterDeclarationClauseAST();
00921
00922 ParameterDeclarationListAST* parameterDeclarationList() { return m_parameterDeclarationList.get(); }
00923 void setParameterDeclarationList( ParameterDeclarationListAST::Node& parameterDeclarationList );
00924
00925 AST* ellipsis() { return m_ellipsis.get(); }
00926 void setEllipsis( AST::Node& ellipsis );
00927
00928 virtual QString text() const;
00929
00930 private:
00931 ParameterDeclarationListAST::Node m_parameterDeclarationList;
00932 AST::Node m_ellipsis;
00933
00934 private:
00935 ParameterDeclarationClauseAST( const ParameterDeclarationClauseAST& source );
00936 void operator = ( const ParameterDeclarationClauseAST& source );
00937 };
00938
00939
00940 class InitDeclaratorAST: public AST
00941 {
00942 public:
00943 typedef AUTO_PTR<InitDeclaratorAST> Node;
00944 enum { Type = NodeType_InitDeclarator };
00945
00946 DECLARE_ALLOC( InitDeclaratorAST )
00947
00948 public:
00949 InitDeclaratorAST();
00950
00951 DeclaratorAST* declarator() { return m_declarator.get(); }
00952 void setDeclarator( DeclaratorAST::Node& declarator );
00953
00954 AST* initializer() { return m_initializer.get(); }
00955 void setInitializer( AST::Node& initializer );
00956
00957 private:
00958 DeclaratorAST::Node m_declarator;
00959 AST::Node m_initializer;
00960
00961 private:
00962 InitDeclaratorAST( const InitDeclaratorAST& source );
00963 void operator = ( const InitDeclaratorAST& source );
00964 };
00965
00966 class InitDeclaratorListAST: public AST
00967 {
00968 public:
00969 typedef AUTO_PTR<InitDeclaratorListAST> Node;
00970 enum { Type = NodeType_InitDeclaratorList };
00971
00972 DECLARE_ALLOC( InitDeclaratorListAST )
00973
00974 public:
00975 InitDeclaratorListAST();
00976
00977 QPtrList<InitDeclaratorAST> initDeclaratorList() { return m_initDeclaratorList; }
00978 void addInitDeclarator( InitDeclaratorAST::Node& decl );
00979
00980 private:
00981 QPtrList<InitDeclaratorAST> m_initDeclaratorList;
00982
00983 private:
00984 InitDeclaratorListAST( const InitDeclaratorListAST& source );
00985 void operator = ( const InitDeclaratorListAST& source );
00986 };
00987
00988 class TypedefAST: public DeclarationAST
00989 {
00990 public:
00991 typedef AUTO_PTR<TypedefAST> Node;
00992 enum { Type = NodeType_Typedef };
00993
00994 DECLARE_ALLOC( TypedefAST )
00995
00996 public:
00997 TypedefAST();
00998
00999 TypeSpecifierAST* typeSpec() { return m_typeSpec.get(); }
01000 void setTypeSpec( TypeSpecifierAST::Node& typeSpec );
01001
01002 InitDeclaratorListAST* initDeclaratorList() { return m_initDeclaratorList.get(); }
01003 void setInitDeclaratorList( InitDeclaratorListAST::Node& initDeclaratorList );
01004
01005 private:
01006 TypeSpecifierAST::Node m_typeSpec;
01007 InitDeclaratorListAST::Node m_initDeclaratorList;
01008
01009 private:
01010 TypedefAST( const TypedefAST& source );
01011 void operator = ( const TypedefAST& source );
01012 };
01013
01014 class TemplateParameterAST: public AST
01015 {
01016 public:
01017 typedef AUTO_PTR<TemplateParameterAST> Node;
01018 enum { Type = NodeType_TemplateParameter };
01019
01020 DECLARE_ALLOC( TemplateParameterAST )
01021
01022 public:
01023 TemplateParameterAST();
01024
01025 TypeParameterAST* typeParameter() { return m_typeParameter.get(); }
01026 void setTypeParameter( TypeParameterAST::Node& typeParameter );
01027
01028 ParameterDeclarationAST* typeValueParameter() { return m_typeValueParameter.get(); }
01029 void setTypeValueParameter( ParameterDeclarationAST::Node& typeValueParameter );
01030
01031 private:
01032 TypeParameterAST::Node m_typeParameter;
01033 ParameterDeclarationAST::Node m_typeValueParameter;
01034
01035 private:
01036 TemplateParameterAST( const TemplateParameterAST& source );
01037 void operator = ( const TemplateParameterAST& source );
01038 };
01039
01040 class TemplateParameterListAST: public AST
01041 {
01042 public:
01043 typedef AUTO_PTR<TemplateParameterListAST> Node;
01044 enum { Type = NodeType_TemplateParameterList };
01045
01046 DECLARE_ALLOC( TemplateParameterListAST )
01047
01048 public:
01049 TemplateParameterListAST();
01050
01051 QPtrList<TemplateParameterAST> templateParameterList() { return m_templateParameterList; }
01052 void addTemplateParameter( TemplateParameterAST::Node& templateParameter );
01053
01054 private:
01055 QPtrList<TemplateParameterAST> m_templateParameterList;
01056
01057 private:
01058 TemplateParameterListAST( const TemplateParameterListAST& source );
01059 void operator = ( const TemplateParameterListAST& source );
01060 };
01061
01062 class TemplateDeclarationAST: public DeclarationAST
01063 {
01064 public:
01065 typedef AUTO_PTR<TemplateDeclarationAST> Node;
01066 enum { Type = NodeType_TemplateDeclaration };
01067
01068 DECLARE_ALLOC( TemplateDeclarationAST )
01069
01070 public:
01071 TemplateDeclarationAST();
01072
01073 AST* exported() { return m_exported.get(); }
01074 void setExported( AST::Node& exported );
01075
01076 TemplateParameterListAST* templateParameterList() { return m_templateParameterList.get(); }
01077 void setTemplateParameterList( TemplateParameterListAST::Node& templateParameterList );
01078
01079 DeclarationAST* declaration() { return m_declaration.get(); }
01080 void setDeclaration( DeclarationAST::Node& declaration );
01081
01082 private:
01083 AST::Node m_exported;
01084 TemplateParameterListAST::Node m_templateParameterList;
01085 DeclarationAST::Node m_declaration;
01086
01087 private:
01088 TemplateDeclarationAST( const TemplateDeclarationAST& source );
01089 void operator = ( const TemplateDeclarationAST& source );
01090 };
01091
01092 class SimpleDeclarationAST: public DeclarationAST
01093 {
01094 public:
01095 typedef AUTO_PTR<SimpleDeclarationAST> Node;
01096 enum { Type = NodeType_SimpleDeclaration };
01097
01098 DECLARE_ALLOC( SimpleDeclarationAST )
01099
01100 public:
01101 SimpleDeclarationAST();
01102
01103 GroupAST* functionSpecifier() { return m_functionSpecifier.get(); }
01104 void setFunctionSpecifier( GroupAST::Node& functionSpecifier );
01105
01106 GroupAST* storageSpecifier() { return m_storageSpecifier.get(); }
01107 void setStorageSpecifier( GroupAST::Node& storageSpecifier );
01108
01109 TypeSpecifierAST* typeSpec() { return m_typeSpec.get(); }
01110 void setTypeSpec( TypeSpecifierAST::Node& typeSpec );
01111
01112 InitDeclaratorListAST* initDeclaratorList() { return m_initDeclaratorList.get(); }
01113 void setInitDeclaratorList( InitDeclaratorListAST::Node& initDeclaratorList );
01114
01115 GroupAST* winDeclSpec() { return m_winDeclSpec.get(); }
01116 void setWinDeclSpec( GroupAST::Node& winDeclSpec );
01117
01118 private:
01119 GroupAST::Node m_functionSpecifier;
01120 GroupAST::Node m_storageSpecifier;
01121 TypeSpecifierAST::Node m_typeSpec;
01122 InitDeclaratorListAST::Node m_initDeclaratorList;
01123 GroupAST::Node m_winDeclSpec;
01124
01125 private:
01126 SimpleDeclarationAST( const SimpleDeclarationAST& source );
01127 void operator = ( const SimpleDeclarationAST& source );
01128 };
01129
01130 class StatementAST: public AST
01131 {
01132 public:
01133 typedef AUTO_PTR<StatementAST> Node;
01134 enum { Type = NodeType_Statement };
01135
01136 DECLARE_ALLOC( StatementAST )
01137
01138 public:
01139 StatementAST();
01140
01141 private:
01142 StatementAST( const StatementAST& source );
01143 void operator = ( const StatementAST& source );
01144 };
01145
01146 class ExpressionStatementAST: public StatementAST
01147 {
01148 public:
01149 typedef AUTO_PTR<ExpressionStatementAST> Node;
01150 enum { Type = NodeType_ExpressionStatement };
01151
01152 DECLARE_ALLOC( ExpressionStatementAST )
01153
01154 public:
01155 ExpressionStatementAST();
01156
01157 AST* expression() { return m_expression.get(); }
01158 void setExpression( AST::Node& expression );
01159
01160 private:
01161 AST::Node m_expression;
01162
01163 private:
01164 ExpressionStatementAST( const ExpressionStatementAST& source );
01165 void operator = ( const ExpressionStatementAST& source );
01166 };
01167
01168 class ConditionAST: public AST
01169 {
01170 public:
01171 typedef AUTO_PTR<ConditionAST> Node;
01172 enum { Type = NodeType_Condition };
01173
01174 DECLARE_ALLOC( ConditionAST )
01175
01176 public:
01177 ConditionAST();
01178
01179 TypeSpecifierAST* typeSpec() { return m_typeSpec.get(); }
01180 void setTypeSpec( TypeSpecifierAST::Node& typeSpec );
01181
01182 DeclaratorAST* declarator() { return m_declarator.get(); }
01183 void setDeclarator( DeclaratorAST::Node& declarator );
01184
01185 AST* expression() { return m_expression.get(); }
01186 void setExpression( AST::Node& expression );
01187
01188 private:
01189 TypeSpecifierAST::Node m_typeSpec;
01190 DeclaratorAST::Node m_declarator;
01191 AST::Node m_expression;
01192
01193 private:
01194 ConditionAST( const ConditionAST& source );
01195 void operator = ( const ConditionAST& source );
01196 };
01197
01198 class IfStatementAST: public StatementAST
01199 {
01200 public:
01201 typedef AUTO_PTR<IfStatementAST> Node;
01202 enum { Type = NodeType_IfStatement };
01203
01204 DECLARE_ALLOC( IfStatementAST )
01205
01206 public:
01207 IfStatementAST();
01208
01209 ConditionAST* condition() const { return m_condition.get(); }
01210 void setCondition( ConditionAST::Node& condition );
01211
01212 StatementAST* statement() { return m_statement.get(); }
01213 void setStatement( StatementAST::Node& statement );
01214
01215 StatementAST* elseStatement() { return m_elseStatement.get(); }
01216 void setElseStatement( StatementAST::Node& statement );
01217
01218 private:
01219 ConditionAST::Node m_condition;
01220 StatementAST::Node m_statement;
01221 StatementAST::Node m_elseStatement;
01222
01223 private:
01224 IfStatementAST( const IfStatementAST& source );
01225 void operator = ( const IfStatementAST& source );
01226 };
01227
01228 class WhileStatementAST: public StatementAST
01229 {
01230 public:
01231 typedef AUTO_PTR<WhileStatementAST> Node;
01232 enum { Type = NodeType_WhileStatement };
01233
01234 DECLARE_ALLOC( WhileStatementAST )
01235
01236 public:
01237 WhileStatementAST();
01238
01239 ConditionAST* condition() const { return m_condition.get(); }
01240 void setCondition( ConditionAST::Node& condition );
01241
01242 StatementAST* statement() { return m_statement.get(); }
01243 void setStatement( StatementAST::Node& statement );
01244
01245 private:
01246 ConditionAST::Node m_condition;
01247 StatementAST::Node m_statement;
01248
01249 private:
01250 WhileStatementAST( const WhileStatementAST& source );
01251 void operator = ( const WhileStatementAST& source );
01252 };
01253
01254 class DoStatementAST: public StatementAST
01255 {
01256 public:
01257 typedef AUTO_PTR<DoStatementAST> Node;
01258 enum { Type = NodeType_DoStatement };
01259
01260 DECLARE_ALLOC( DoStatementAST )
01261
01262 public:
01263 DoStatementAST();
01264
01265 ConditionAST* condition() const { return m_condition.get(); }
01266 void setCondition( ConditionAST::Node& condition );
01267
01268 StatementAST* statement() { return m_statement.get(); }
01269 void setStatement( StatementAST::Node& statement );
01270
01271 private:
01272 ConditionAST::Node m_condition;
01273 StatementAST::Node m_statement;
01274
01275 private:
01276 DoStatementAST( const DoStatementAST& source );
01277 void operator = ( const DoStatementAST& source );
01278 };
01279
01280 class ForStatementAST: public StatementAST
01281 {
01282 public:
01283 typedef AUTO_PTR<ForStatementAST> Node;
01284 enum { Type = NodeType_ForStatement };
01285
01286 DECLARE_ALLOC( ForStatementAST )
01287
01288 public:
01289 ForStatementAST();
01290
01291 StatementAST* initStatement() { return m_initStatement.get(); }
01292 void setInitStatement( StatementAST::Node& statement );
01293
01294 ConditionAST* condition() const { return m_condition.get(); }
01295 void setCondition( ConditionAST::Node& condition );
01296
01297 AST* expression() const { return m_expression.get(); }
01298 void setExpression( AST::Node& expression );
01299
01300 StatementAST* statement() { return m_statement.get(); }
01301 void setStatement( StatementAST::Node& statement );
01302
01303 private:
01304 ConditionAST::Node m_condition;
01305 StatementAST::Node m_initStatement;
01306 StatementAST::Node m_statement;
01307 AST::Node m_expression;
01308
01309 private:
01310 ForStatementAST( const ForStatementAST& source );
01311 void operator = ( const ForStatementAST& source );
01312 };
01313
01314 class SwitchStatementAST: public StatementAST
01315 {
01316 public:
01317 typedef AUTO_PTR<SwitchStatementAST> Node;
01318 enum { Type = NodeType_SwitchStatement };
01319
01320 DECLARE_ALLOC( SwitchStatementAST )
01321
01322 public:
01323 SwitchStatementAST();
01324
01325 ConditionAST* condition() const { return m_condition.get(); }
01326 void setCondition( ConditionAST::Node& condition );
01327
01328 StatementAST* statement() { return m_statement.get(); }
01329 void setStatement( StatementAST::Node& statement );
01330
01331 private:
01332 ConditionAST::Node m_condition;
01333 StatementAST::Node m_statement;
01334
01335 private:
01336 SwitchStatementAST( const SwitchStatementAST& source );
01337 void operator = ( const SwitchStatementAST& source );
01338 };
01339
01340 class StatementListAST: public StatementAST
01341 {
01342 public:
01343 typedef AUTO_PTR<StatementListAST> Node;
01344 enum { Type = NodeType_StatementList };
01345
01346 DECLARE_ALLOC( StatementListAST )
01347
01348 public:
01349 StatementListAST();
01350
01351 QPtrList<StatementAST> statementList() { return m_statementList; }
01352 void addStatement( StatementAST::Node& statement );
01353
01354 private:
01355 QPtrList<StatementAST> m_statementList;
01356
01357 private:
01358 StatementListAST( const StatementListAST& source );
01359 void operator = ( const StatementListAST& source );
01360 };
01361
01362 class DeclarationStatementAST: public StatementAST
01363 {
01364 public:
01365 typedef AUTO_PTR<DeclarationStatementAST> Node;
01366 enum { Type = NodeType_DeclarationStatement };
01367
01368 DECLARE_ALLOC( DeclarationStatementAST )
01369
01370 public:
01371 DeclarationStatementAST();
01372
01373 DeclarationAST* declaration() { return m_declaration.get(); }
01374 void setDeclaration( DeclarationAST::Node& declaration );
01375
01376 private:
01377 DeclarationAST::Node m_declaration;
01378
01379 private:
01380 DeclarationStatementAST( const DeclarationStatementAST& source );
01381 void operator = ( const DeclarationStatementAST& source );
01382 };
01383
01384 class FunctionDefinitionAST: public DeclarationAST
01385 {
01386 public:
01387 typedef AUTO_PTR<FunctionDefinitionAST> Node;
01388 enum { Type = NodeType_FunctionDefinition };
01389
01390 DECLARE_ALLOC( FunctionDefinitionAST )
01391
01392 public:
01393 FunctionDefinitionAST();
01394
01395 GroupAST* functionSpecifier() { return m_functionSpecifier.get(); }
01396 void setFunctionSpecifier( GroupAST::Node& functionSpecifier );
01397
01398 GroupAST* storageSpecifier() { return m_storageSpecifier.get(); }
01399 void setStorageSpecifier( GroupAST::Node& storageSpecifier );
01400
01401 TypeSpecifierAST* typeSpec() { return m_typeSpec.get(); }
01402 void setTypeSpec( TypeSpecifierAST::Node& typeSpec );
01403
01404 InitDeclaratorAST* initDeclarator() { return m_initDeclarator.get(); }
01405 void setInitDeclarator( InitDeclaratorAST::Node& initDeclarator );
01406
01407 StatementListAST* functionBody() { return m_functionBody.get(); }
01408 void setFunctionBody( StatementListAST::Node& functionBody );
01409
01410 GroupAST* winDeclSpec() { return m_winDeclSpec.get(); }
01411 void setWinDeclSpec( GroupAST::Node& winDeclSpec );
01412
01413 private:
01414 GroupAST::Node m_functionSpecifier;
01415 GroupAST::Node m_storageSpecifier;
01416 TypeSpecifierAST::Node m_typeSpec;
01417 InitDeclaratorAST::Node m_initDeclarator;
01418 StatementListAST::Node m_functionBody;
01419 GroupAST::Node m_winDeclSpec;
01420
01421 private:
01422 FunctionDefinitionAST( const FunctionDefinitionAST& source );
01423 void operator = ( const FunctionDefinitionAST& source );
01424 };
01425
01426
01427 class TranslationUnitAST: public AST
01428 {
01429 public:
01430 typedef AUTO_PTR<TranslationUnitAST> Node;
01431 enum { Type = NodeType_TranslationUnit };
01432
01433 DECLARE_ALLOC( TranslationUnitAST )
01434
01435 public:
01436 TranslationUnitAST();
01437
01438 void addDeclaration( DeclarationAST::Node& ast );
01439 QPtrList<DeclarationAST> declarationList() { return m_declarationList; }
01440
01441 private:
01442 QPtrList<DeclarationAST> m_declarationList;
01443
01444 private:
01445 TranslationUnitAST( const TranslationUnitAST& source );
01446 void operator = ( const TranslationUnitAST& source );
01447 };
01448
01449 #endif