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