1 /* This file is part of KDevelop
2     SPDX-FileCopyrightText: 2002, 2003 Roberto Raggi <roberto@kdevelop.org>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef __ast_h
8 #define __ast_h
9 
10 #include <QtGlobal>
11 
12 #if QT_VERSION >= 0x050000
13 #include <QExplicitlySharedDataPointer>
14 #define KShared QSharedData
15 #define KSharedPtr QExplicitlySharedDataPointer
16 #else
17 #include <KSharedPtr>
18 #endif
19 
20 #include <memory>
21 #include <QString>
22 #include <QStringList>
23 
24 #if defined(Q_CC_SUN)
25 
26 #ifndef _THROW0
27 #  define _THROW0()
28 #endif
29 
30 template <class _Tp> class AUTO_PTR
31 {
32 private:
33     _Tp* _M_ptr;
34 
35 public:
36     typedef _Tp element_type;
37 
_THROW0()38     explicit AUTO_PTR(_Tp* __p = 0)  _THROW0() : _M_ptr(__p) {}
39 
AUTO_PTR(AUTO_PTR<_Tp1> & __a)40     template <class _Tp1> AUTO_PTR(AUTO_PTR<_Tp1>& __a)  _THROW0()
41         : _M_ptr(__a.release()) {}
42 
_THROW0()43     AUTO_PTR(AUTO_PTR& __a)  _THROW0() : _M_ptr(__a.release()) {}
44 
45 
46 
47     template <class _Tp1>
_THROW0()48     AUTO_PTR& operator=(AUTO_PTR<_Tp1>& __a)  _THROW0()
49     {
50         if (__a.get() != this->get()) {
51             delete _M_ptr;
52             _M_ptr = __a.release();
53         }
54         return *this;
55     }
56 
_THROW0()57     AUTO_PTR& operator=(AUTO_PTR& __a)  _THROW0()
58     {
59         if (&__a != this) {
60             delete _M_ptr;
61             _M_ptr = __a.release();
62         }
63         return *this;
64     }
65 
_THROW0()66     ~AUTO_PTR()  _THROW0()
67     {
68         delete _M_ptr;
69     }
70 
_THROW0()71     _Tp& operator*() const  _THROW0()
72     {
73         return *_M_ptr;
74     }
75     _Tp* operator->() const  _THROW0()
76     {
77         return _M_ptr;
78     }
get()79     _Tp* get() const  _THROW0()
80     {
81         return _M_ptr;
82     }
release()83     _Tp* release()  _THROW0()
84     {
85         _Tp* __tmp = _M_ptr;
86         _M_ptr = 0;
87         return __tmp;
88     }
_THROW0()89     void reset(_Tp* __p = 0)  _THROW0()
90     {
91         delete _M_ptr;
92         _M_ptr = __p;
93     }
94 
95     // According to the C++ standard, these conversions are required.  Most
96     // present-day compilers, however, do not enforce that requirement---and,
97     // in fact, most present-day compilers do not support the language
98     // features that these conversions rely on.
99 
100 
101 private:
102     template<class _Tp1> struct AUTO_PTR_ref {
103         _Tp1* _M_ptr;
AUTO_PTR_refAUTO_PTR_ref104         AUTO_PTR_ref(_Tp1* __p) : _M_ptr(__p) {}
105     };
106 
107 public:
AUTO_PTR(AUTO_PTR_ref<_Tp> __ref)108     AUTO_PTR(AUTO_PTR_ref<_Tp> __ref)  _THROW0()
109         : _M_ptr(__ref._M_ptr) {}
_THROW0()110     template <class _Tp1> operator AUTO_PTR_ref<_Tp1>()  _THROW0()
111     {
112         return AUTO_PTR_ref<_Tp>(this->release());
113     }
_THROW0()114     template <class _Tp1> operator AUTO_PTR<_Tp1>()  _THROW0()
115     {
116         return AUTO_PTR<_Tp1>(this->release());
117     }
118 
119 };
120 
121 #else
122 #define AUTO_PTR std::unique_ptr
123 #endif
124 
CreateNode()125 template <class T> typename T::Node CreateNode()
126 {
127     typename T::Node node(new T);
128     node->setNodeType(T::Type);
129     return node;
130 }
131 
NullNode()132 template <class T> typename T::Node NullNode()
133 {
134     typename T::Node node;
135     return node;
136 }
137 
138 enum NodeType {
139     NodeType_Generic = 0,
140 
141     NodeType_TemplateArgumentList = 1000,
142     NodeType_ClassOrNamespaceName,
143     NodeType_Name,
144     NodeType_Declaration,
145     NodeType_TypeSpecifier,
146     NodeType_BaseSpecifier,
147     NodeType_BaseClause,
148     NodeType_ClassSpecifier,
149     NodeType_Enumerator,
150     NodeType_EnumSpecifier,
151     NodeType_ElaboratedTypeSpecifier,
152     NodeType_LinkageBody,
153     NodeType_LinkageSpecification,
154     NodeType_Namespace,
155     NodeType_NamespaceAlias,
156     NodeType_Using,
157     NodeType_UsingDirective,
158     NodeType_InitDeclaratorList,
159     NodeType_Typedef,
160     NodeType_Declarator,
161     NodeType_InitDeclarator,
162     NodeType_TemplateDeclaration,
163     NodeType_SimpleDeclaration,
164     NodeType_Statement,
165     NodeType_StatementList,
166     NodeType_IfStatement,
167     NodeType_WhileStatement,
168     NodeType_DoStatement,
169     NodeType_ForStatement,
170     NodeType_ForEachStatement, // qt4 [erbsland]
171     NodeType_SwitchStatement,
172     NodeType_CatchStatement,
173     NodeType_CatchStatementList,
174     NodeType_TryBlockStatement,
175     NodeType_DeclarationStatement,
176     NodeType_TranslationUnit,
177     NodeType_FunctionDefinition,
178     NodeType_ExpressionStatement,
179     NodeType_ParameterDeclaration,
180     NodeType_ParameterDeclarationList,
181     NodeType_ParameterDeclarationClause,
182     NodeType_Group,
183     NodeType_AccessDeclaration,
184     NodeType_TypeParameter,
185     NodeType_TemplateParameter,
186     NodeType_TemplateParameterList,
187     NodeType_Condition,
188     NodeType_File,
189 
190     NodeType_Custom = 2000
191 };
192 
193 QString nodeTypeToString(int type);
194 
195 
196 #if defined(CPPPARSER_QUICK_ALLOCATOR)
197 
198 #include <quick_allocator.h>
199 
200 #define DECLARE_ALLOC(tp) \
201     void * operator new(std::size_t) \
202     { \
203         return quick_allocator< tp >::alloc(); \
204     } \
205  \
206     void operator delete(void * p) \
207     { \
208         quick_allocator< tp >::dealloc(p); \
209     }
210 #else
211 
212 #define DECLARE_ALLOC(tp)
213 
214 #endif
215 
216 struct Slice {
217     QString source;
218     int position;
219     int length;
220 
SliceSlice221     inline Slice()
222         : position(0), length(0) {}
223 };
224 
225 
226 class CommentAST
227 {
228     QString m_comment;
229 public:
setComment(const QString & comment)230     void setComment(const QString& comment)
231     {
232         m_comment = comment;
233     }
234 
addComment(const QString & comment)235     void addComment(const QString& comment)
236     {
237         if (!m_comment.isEmpty()) {
238             m_comment += QLatin1String("\n(") + comment + QLatin1String(")");
239         } else {
240             m_comment = comment;
241         }
242     }
243 
comment()244     QString comment() const
245     {
246         return m_comment;
247     }
248 
haveComment()249     bool haveComment() const
250     {
251         return !m_comment.isEmpty();
252     }
253 };
254 
255 class AST : public CommentAST
256 {
257 public:
258     typedef AUTO_PTR<AST> Node;
259     enum { Type=NodeType_Generic };
260 
261     DECLARE_ALLOC(AST)
262 
263 public:
264     AST();
265     virtual ~AST();
266 
nodeType()267     int nodeType() const
268     {
269         return m_nodeType;
270     }
setNodeType(int nodeType)271     void setNodeType(int nodeType)
272     {
273         m_nodeType = nodeType;
274     }
275 
parent()276     AST* parent()
277     {
278         return m_parent;
279     }
280     void setParent(AST* parent);
281 
282     void setStartPosition(int line, int col);
283     void getStartPosition(int* line, int* col) const;
284 
285     void setEndPosition(int line, int col);
286     void getEndPosition(int* line, int* col) const;
287 
288 #ifndef CPPPARSER_NO_CHILDREN
children()289     QList<AST*> children()
290     {
291         return m_children;
292     }
293     void appendChild(AST* child);
294     void removeChild(AST* child);
295 #endif
296 
text()297     virtual inline QString text() const
298     {
299         return m_slice.source.mid(m_slice.position, m_slice.length);
300     }
301 
setSlice(const Slice & slice)302     inline void setSlice(const Slice& slice)
303     {
304         m_slice = slice;
305     }
306 
setSlice(const QString & text,int position,int length)307     inline void setSlice(const QString &text, int position, int length)
308     {
309         CommentAST a;
310         m_slice.source = text;
311         m_slice.position = position;
312         m_slice.length = length;
313     }
314 
setText(const QString & text)315     inline void setText(const QString &text)
316     {
317         setSlice(text, 0, text.length());
318     }
319 
320 private:
321     int m_nodeType;
322     AST* m_parent;
323     int m_startLine, m_startColumn;
324     int m_endLine, m_endColumn;
325     Slice m_slice;
326 #ifndef CPPPARSER_NO_CHILDREN
327     QList<AST*> m_children;
328 #endif
329 
330 private:
331     AST(const AST& source);
332     void operator = (const AST& source);
333 };
334 
335 class GroupAST: public AST
336 {
337 public:
338     typedef AUTO_PTR<GroupAST> Node;
339     enum { Type = NodeType_Group };
340 
341     DECLARE_ALLOC(GroupAST)
342 
343 public:
344     GroupAST();
345 
nodeList()346     QList<AST*> nodeList()
347     {
348         return m_nodeList;
349     }
350     void addNode(AST::Node& node);
351 
352     virtual QString text() const;
353 
354 private:
355     QList<AST*> m_nodeList;
356 
357 private:
358     GroupAST(const GroupAST& source);
359     void operator = (const GroupAST& source);
360 };
361 
362 
363 class TemplateArgumentListAST: public AST
364 {
365 public:
366     typedef AUTO_PTR<TemplateArgumentListAST> Node;
367     enum { Type = NodeType_TemplateArgumentList };
368 
369     DECLARE_ALLOC(TemplateArgumentListAST)
370 
371 public:
372     TemplateArgumentListAST();
373 
374     void addArgument(AST::Node& arg);
argumentList()375     QList<AST*> argumentList()
376     {
377         return m_argumentList;
378     }
379 
380     virtual QString text() const;
381 
382 private:
383     QList<AST*> m_argumentList;
384 
385 private:
386     TemplateArgumentListAST(const TemplateArgumentListAST& source);
387     void operator = (const TemplateArgumentListAST& source);
388 };
389 
390 class ClassOrNamespaceNameAST: public AST
391 {
392 public:
393     typedef AUTO_PTR<ClassOrNamespaceNameAST> Node;
394     enum { Type = NodeType_ClassOrNamespaceName };
395 
396     DECLARE_ALLOC(ClassOrNamespaceNameAST)
397 
398 public:
399     ClassOrNamespaceNameAST();
400 
name()401     AST* name()
402     {
403         return m_name.get();
404     }
405     void setName(AST::Node& name);
406 
templateArgumentList()407     TemplateArgumentListAST* templateArgumentList()
408     {
409         return m_templateArgumentList.get();
410     }
411     void setTemplateArgumentList(TemplateArgumentListAST::Node& templateArgumentList);
412 
413     virtual QString text() const;
414 
415 private:
416     AST::Node m_name;
417     TemplateArgumentListAST::Node m_templateArgumentList;
418 
419 private:
420     ClassOrNamespaceNameAST(const ClassOrNamespaceNameAST& source);
421     void operator = (const ClassOrNamespaceNameAST& source);
422 };
423 
424 class NameAST: public AST
425 {
426 public:
427     typedef AUTO_PTR<NameAST> Node;
428     enum { Type = NodeType_Name };
429 
430     DECLARE_ALLOC(NameAST)
431 
432 public:
433     NameAST();
434 
isGlobal()435     bool isGlobal() const
436     {
437         return m_global;
438     }
439     void setGlobal(bool b);
440 
441     void addClassOrNamespaceName(ClassOrNamespaceNameAST::Node& classOrNamespaceName);
classOrNamespaceNameList()442     QList<ClassOrNamespaceNameAST*> classOrNamespaceNameList()
443     {
444         return m_classOrNamespaceNameList;
445     }
446 
unqualifiedName()447     ClassOrNamespaceNameAST* unqualifiedName()
448     {
449         return m_unqualifiedName.get();
450     }
451     void setUnqualifiedName(ClassOrNamespaceNameAST::Node& unqualifiedName);
452 
453     virtual QString text() const;
454 
455 private:
456     bool m_global;
457     ClassOrNamespaceNameAST::Node m_unqualifiedName;
458     QList<ClassOrNamespaceNameAST*> m_classOrNamespaceNameList;
459 
460 private:
461     NameAST(const NameAST& source);
462     void operator = (const NameAST& source);
463 };
464 
465 class TypeParameterAST: public AST
466 {
467 public:
468     typedef AUTO_PTR<TypeParameterAST> Node;
469     enum { Type = NodeType_TypeParameter };
470 
471     DECLARE_ALLOC(TypeParameterAST)
472 
473 public:
474     TypeParameterAST();
475 
kind()476     AST* kind()
477     {
478         return m_kind.get();
479     }
480     void setKind(AST::Node& kind);
481 
templateParameterList()482     class TemplateParameterListAST* templateParameterList()
483     {
484         return m_templateParameterList.get();
485     }
486     void setTemplateParameterList(AUTO_PTR<class TemplateParameterListAST>& templateParameterList);
487 
name()488     NameAST* name()
489     {
490         return m_name.get();
491     }
492     void setName(NameAST::Node& name);
493 
typeId()494     AST* typeId()
495     {
496         return m_typeId.get();
497     }
498     void setTypeId(AST::Node& typeId);
499 
500 private:
501     AST::Node m_kind;
502     AUTO_PTR<class TemplateParameterListAST> m_templateParameterList;
503     NameAST::Node m_name;
504     AST::Node m_typeId;
505 
506 private:
507     TypeParameterAST(const TypeParameterAST& source);
508     void operator = (const TypeParameterAST& source);
509 };
510 
511 class DeclarationAST: public AST
512 {
513 public:
514     typedef AUTO_PTR<DeclarationAST> Node;
515     enum { Type = NodeType_Declaration };
516 
517     DECLARE_ALLOC(DeclarationAST)
518 
519 public:
520     DeclarationAST();
521 
522 private:
523     DeclarationAST(const DeclarationAST& source);
524     void operator = (const DeclarationAST& source);
525 };
526 
527 class AccessDeclarationAST: public DeclarationAST
528 {
529 public:
530     typedef AUTO_PTR<AccessDeclarationAST> Node;
531     enum { Type = NodeType_AccessDeclaration };
532 
533     DECLARE_ALLOC(AccessDeclarationAST)
534 
535 public:
536     AccessDeclarationAST();
537 
accessList()538     QList<AST*> accessList()
539     {
540         return m_accessList;
541     }
542     void addAccess(AST::Node& access);
543 
544     virtual QString text() const;
545 
546 private:
547     QList<AST*> m_accessList;
548 
549 private:
550     AccessDeclarationAST(const AccessDeclarationAST& source);
551     void operator = (const AccessDeclarationAST& source);
552 };
553 
554 class TypeSpecifierAST: public AST
555 {
556 public:
557     typedef AUTO_PTR<TypeSpecifierAST> Node;
558     enum { Type = NodeType_TypeSpecifier };
559 
560     DECLARE_ALLOC(TypeSpecifierAST)
561 
562 public:
563     TypeSpecifierAST();
564 
name()565     virtual NameAST* name()
566     {
567         return m_name.get();
568     }
569     virtual void setName(NameAST::Node& name);
570 
cvQualify()571     GroupAST* cvQualify()
572     {
573         return m_cvQualify.get();
574     }
575     void setCvQualify(GroupAST::Node& cvQualify);
576 
cv2Qualify()577     GroupAST* cv2Qualify()
578     {
579         return m_cv2Qualify.get();
580     }
581     void setCv2Qualify(GroupAST::Node& cv2Qualify);
582 
583     virtual QString text() const;
584 
585 private:
586     NameAST::Node m_name;
587     GroupAST::Node m_cvQualify;
588     GroupAST::Node m_cv2Qualify;
589 
590 private:
591     TypeSpecifierAST(const TypeSpecifierAST& source);
592     void operator = (const TypeSpecifierAST& source);
593 };
594 
595 class BaseSpecifierAST: public AST
596 {
597 public:
598     typedef AUTO_PTR<BaseSpecifierAST> Node;
599     enum { Type = NodeType_BaseSpecifier };
600 
601     DECLARE_ALLOC(BaseSpecifierAST)
602 
603 public:
604     BaseSpecifierAST();
605 
isVirtual()606     AST* isVirtual()
607     {
608         return m_isVirtual.get();
609     }
610     void setIsVirtual(AST::Node& isVirtual);
611 
access()612     AST* access()
613     {
614         return m_access.get();
615     }
616     void setAccess(AST::Node& access);
617 
name()618     NameAST* name()
619     {
620         return m_name.get();
621     }
622     void setName(NameAST::Node& name);
623 
624 private:
625     AST::Node m_isVirtual;
626     AST::Node m_access;
627     NameAST::Node m_name;
628 
629 private:
630     BaseSpecifierAST(const BaseSpecifierAST& source);
631     void operator = (const BaseSpecifierAST& source);
632 };
633 
634 class BaseClauseAST: public AST
635 {
636 public:
637     typedef AUTO_PTR<BaseClauseAST> Node;
638     enum { Type = NodeType_BaseClause };
639 
640     DECLARE_ALLOC(BaseClauseAST)
641 
642 public:
643     BaseClauseAST();
644 
645     void addBaseSpecifier(BaseSpecifierAST::Node& baseSpecifier);
baseSpecifierList()646     QList<BaseSpecifierAST*> baseSpecifierList()
647     {
648         return m_baseSpecifierList;
649     }
650 
651 private:
652     QList<BaseSpecifierAST*> m_baseSpecifierList;
653 
654 private:
655     BaseClauseAST(const BaseClauseAST& source);
656     void operator = (const BaseClauseAST& source);
657 };
658 
659 class ClassSpecifierAST: public TypeSpecifierAST
660 {
661 public:
662     typedef AUTO_PTR<ClassSpecifierAST> Node;
663     enum { Type = NodeType_ClassSpecifier };
664 
665     DECLARE_ALLOC(ClassSpecifierAST)
666 
667 public:
668     ClassSpecifierAST();
669 
winDeclSpec()670     GroupAST* winDeclSpec()
671     {
672         return m_winDeclSpec.get();
673     }
674     void setWinDeclSpec(GroupAST::Node& winDeclSpec);
675 
classKey()676     AST* classKey()
677     {
678         return m_classKey.get();
679     }
680     void setClassKey(AST::Node& classKey);
681 
baseClause()682     BaseClauseAST* baseClause()
683     {
684         return m_baseClause.get();
685     }
686     void setBaseClause(BaseClauseAST::Node& baseClause);
687 
declarationList()688     QList<DeclarationAST*> declarationList()
689     {
690         return m_declarationList;
691     }
692     void addDeclaration(DeclarationAST::Node& declaration);
693 
694 private:
695     GroupAST::Node m_winDeclSpec;
696     AST::Node m_classKey;
697     BaseClauseAST::Node m_baseClause;
698     QList<DeclarationAST*> m_declarationList;
699 
700 private:
701     ClassSpecifierAST(const ClassSpecifierAST& source);
702     void operator = (const ClassSpecifierAST& source);
703 };
704 
705 class EnumeratorAST: public AST
706 {
707 public:
708     typedef AUTO_PTR<EnumeratorAST> Node;
709     enum { Type = NodeType_Enumerator };
710 
711     DECLARE_ALLOC(EnumeratorAST)
712 
713 public:
714     EnumeratorAST();
715 
id()716     AST* id()
717     {
718         return m_id.get();
719     }
720     void setId(AST::Node& id);
721 
expr()722     AST* expr()
723     {
724         return m_expr.get();
725     }
726     void setExpr(AST::Node& expr);
727 
728 private:
729     AST::Node m_id;
730     AST::Node m_expr;
731 
732 private:
733     EnumeratorAST(const EnumeratorAST& source);
734     void operator = (const EnumeratorAST& source);
735 };
736 
737 class EnumSpecifierAST: public TypeSpecifierAST
738 {
739 public:
740     typedef AUTO_PTR<EnumSpecifierAST> Node;
741     enum { Type = NodeType_EnumSpecifier };
742 
743     DECLARE_ALLOC(EnumSpecifierAST)
744 
745 public:
746     EnumSpecifierAST();
747 
748     void setClass(bool b);
isClass()749     bool isClass() const {
750         return m_isClass;
751     }
752 
753     void setEnumBase(TypeSpecifierAST::Node& enumBase);
enumBase()754     TypeSpecifierAST *enumBase() {
755         return m_enumBase.get();
756     }
757 
758     void addEnumerator(EnumeratorAST::Node& enumerator);
enumeratorList()759     QList<EnumeratorAST*> enumeratorList()
760     {
761         return m_enumeratorList;
762     }
763 
764 private:
765     bool m_isClass;
766     TypeSpecifierAST::Node m_enumBase;
767     QList<EnumeratorAST*> m_enumeratorList;
768 
769 private:
770     EnumSpecifierAST(const EnumSpecifierAST& source);
771     void operator = (const EnumSpecifierAST& source);
772 };
773 
774 class ElaboratedTypeSpecifierAST: public TypeSpecifierAST
775 {
776 public:
777     typedef AUTO_PTR<ElaboratedTypeSpecifierAST> Node;
778     enum { Type = NodeType_ElaboratedTypeSpecifier };
779 
780     DECLARE_ALLOC(ElaboratedTypeSpecifierAST)
781 
782 public:
783     ElaboratedTypeSpecifierAST();
784 
kind()785     AST* kind()
786     {
787         return m_kind.get();
788     }
789     void setKind(AST::Node& kind);
790 
791     virtual QString text() const;
792 
793 private:
794     AST::Node m_kind;
795 
796 private:
797     ElaboratedTypeSpecifierAST(const ElaboratedTypeSpecifierAST& source);
798     void operator = (const ElaboratedTypeSpecifierAST& source);
799 };
800 
801 class LinkageBodyAST: public AST
802 {
803 public:
804     typedef AUTO_PTR<LinkageBodyAST> Node;
805     enum { Type = NodeType_LinkageBody };
806 
807     DECLARE_ALLOC(LinkageBodyAST)
808 
809 public:
810     LinkageBodyAST();
811 
812     void addDeclaration(DeclarationAST::Node& ast);
declarationList()813     QList<DeclarationAST*> declarationList()
814     {
815         return m_declarationList;
816     }
817 
818 private:
819     QList<DeclarationAST*> m_declarationList;
820 
821 private:
822     LinkageBodyAST(const LinkageBodyAST& source);
823     void operator = (const LinkageBodyAST& source);
824 };
825 
826 class LinkageSpecificationAST: public DeclarationAST
827 {
828 public:
829     typedef AUTO_PTR<LinkageSpecificationAST> Node;
830     enum { Type = NodeType_LinkageSpecification };
831 
832     DECLARE_ALLOC(LinkageSpecificationAST)
833 
834 public:
835     LinkageSpecificationAST();
836 
externType()837     AST* externType()
838     {
839         return m_externType.get();
840     }
841     void setExternType(AST::Node& externType);
842 
linkageBody()843     LinkageBodyAST* linkageBody()
844     {
845         return m_linkageBody.get();
846     }
847     void setLinkageBody(LinkageBodyAST::Node& linkageBody);
848 
declaration()849     DeclarationAST* declaration()
850     {
851         return m_declaration.get();
852     }
853     void setDeclaration(DeclarationAST::Node& decl);
854 
855 private:
856     AST::Node m_externType;
857     LinkageBodyAST::Node m_linkageBody;
858     DeclarationAST::Node m_declaration;
859 
860 private:
861     LinkageSpecificationAST(const LinkageSpecificationAST& source);
862     void operator = (const LinkageSpecificationAST& source);
863 };
864 
865 class NamespaceAST: public DeclarationAST
866 {
867 public:
868     typedef AUTO_PTR<NamespaceAST> Node;
869     enum { Type = NodeType_Namespace };
870 
871     DECLARE_ALLOC(NamespaceAST)
872 
873 public:
874     NamespaceAST();
875 
namespaceName()876     AST* namespaceName()
877     {
878         return m_namespaceName.get();
879     }
880     void setNamespaceName(AST::Node& namespaceName);
881 
linkageBody()882     LinkageBodyAST* linkageBody()
883     {
884         return m_linkageBody.get();
885     }
886     void setLinkageBody(LinkageBodyAST::Node& linkageBody);
887 
888 private:
889     AST::Node m_namespaceName;
890     LinkageBodyAST::Node m_linkageBody;
891 
892 private:
893     NamespaceAST(const NamespaceAST& source);
894     void operator = (const NamespaceAST& source);
895 };
896 
897 class NamespaceAliasAST: public DeclarationAST
898 {
899 public:
900     typedef AUTO_PTR<NamespaceAliasAST> Node;
901     enum { Type = NodeType_NamespaceAlias };
902 
903     DECLARE_ALLOC(NamespaceAliasAST)
904 
905 public:
906     NamespaceAliasAST();
907 
namespaceName()908     AST* namespaceName()
909     {
910         return m_namespaceName.get();
911     }
912     void setNamespaceName(AST::Node& name);
913 
aliasName()914     NameAST* aliasName()
915     {
916         return m_aliasName.get();
917     }
918     void setAliasName(NameAST::Node& name);
919 
920 private:
921     AST::Node m_namespaceName;
922     NameAST::Node m_aliasName;
923 
924 private:
925     NamespaceAliasAST(const NamespaceAliasAST& source);
926     void operator = (const NamespaceAliasAST& source);
927 };
928 
929 class UsingAST: public DeclarationAST
930 {
931 public:
932     typedef AUTO_PTR<UsingAST> Node;
933     enum { Type = NodeType_Using };
934 
935     DECLARE_ALLOC(UsingAST)
936 
937 public:
938     UsingAST();
939 
typeName()940     AST* typeName()
941     {
942         return m_typeName.get();
943     }
944     void setTypeName(AST::Node& typeName);
945 
name()946     NameAST* name()
947     {
948         return m_name.get();
949     }
950     void setName(NameAST::Node& name);
951 
952 private:
953     AST::Node m_typeName;
954     NameAST::Node m_name;
955 
956 private:
957     UsingAST(const UsingAST& source);
958     void operator = (const UsingAST& source);
959 };
960 
961 class UsingDirectiveAST: public DeclarationAST
962 {
963 public:
964     typedef AUTO_PTR<UsingDirectiveAST> Node;
965     enum { Type = NodeType_UsingDirective };
966 
967     DECLARE_ALLOC(UsingDirectiveAST)
968 
969 public:
970     UsingDirectiveAST();
971 
name()972     NameAST* name()
973     {
974         return m_name.get();
975     }
976     void setName(NameAST::Node& name);
977 
978 private:
979     NameAST::Node m_name;
980 
981 private:
982     UsingDirectiveAST(const UsingDirectiveAST& source);
983     void operator = (const UsingDirectiveAST& source);
984 };
985 
986 class DeclaratorAST: public AST
987 {
988 public:
989     typedef AUTO_PTR<DeclaratorAST> Node;
990     enum { Type = NodeType_Declarator };
991 
992     DECLARE_ALLOC(DeclaratorAST)
993 
994 public:
995     DeclaratorAST();
996 
ptrOpList()997     QList<AST*> ptrOpList()
998     {
999         return m_ptrOpList;
1000     }
1001     void addPtrOp(AST::Node& ptrOp);
1002 
subDeclarator()1003     DeclaratorAST* subDeclarator()
1004     {
1005         return m_subDeclarator.get();
1006     }
1007     void setSubDeclarator(AUTO_PTR<DeclaratorAST>& subDeclarator);
1008 
declaratorId()1009     NameAST* declaratorId()
1010     {
1011         return m_declaratorId.get();
1012     }
1013     void setDeclaratorId(NameAST::Node& declaratorId);
1014 
bitfieldInitialization()1015     AST* bitfieldInitialization()
1016     {
1017         return m_bitfieldInitialization.get();
1018     }
1019     void setBitfieldInitialization(AST::Node& bitfieldInitialization);
1020 
arrayDimensionList()1021     QList<AST*> arrayDimensionList()
1022     {
1023         return m_arrayDimensionList;
1024     }
1025     void addArrayDimension(AST::Node& arrayDimension);
1026 
parameterDeclarationClause()1027     class ParameterDeclarationClauseAST* parameterDeclarationClause()
1028     {
1029         return m_parameterDeclarationClause.get();
1030     }
1031     void setParameterDeclarationClause(AUTO_PTR<class ParameterDeclarationClauseAST>& parameterDeclarationClause);
1032 
1033     // ### replace 'constant' with cvQualify
constant()1034     AST* constant()
1035     {
1036         return m_constant.get();
1037     }
1038     void setConstant(AST::Node& constant);
1039 
override()1040     AST* override()
1041     {
1042         return m_override.get();
1043     }
1044 
1045     void setOverride(AST::Node& override);
1046 
exceptionSpecification()1047     GroupAST* exceptionSpecification()
1048     {
1049         return m_exceptionSpecification.get();
1050     }
1051     void setExceptionSpecification(GroupAST::Node& exceptionSpecification);
1052 
1053 private:
1054     QList<AST*> m_ptrOpList;
1055     AUTO_PTR<DeclaratorAST> m_subDeclarator;
1056     NameAST::Node m_declaratorId;
1057     AST::Node m_bitfieldInitialization;
1058     QList<AST*> m_arrayDimensionList;
1059     AUTO_PTR<class ParameterDeclarationClauseAST> m_parameterDeclarationClause;
1060     AST::Node m_constant;
1061     AST::Node m_override;
1062     GroupAST::Node m_exceptionSpecification;
1063 
1064 private:
1065     DeclaratorAST(const DeclaratorAST& source);
1066     void operator = (const DeclaratorAST& source);
1067 };
1068 
1069 class ParameterDeclarationAST: public AST
1070 {
1071 public:
1072     typedef AUTO_PTR<ParameterDeclarationAST> Node;
1073     enum { Type = NodeType_ParameterDeclaration };
1074 
1075     DECLARE_ALLOC(ParameterDeclarationAST)
1076 
1077 public:
1078     ParameterDeclarationAST();
1079 
typeSpec()1080     TypeSpecifierAST* typeSpec()
1081     {
1082         return m_typeSpec.get();
1083     }
1084     void setTypeSpec(TypeSpecifierAST::Node& typeSpec);
1085 
declarator()1086     DeclaratorAST* declarator()
1087     {
1088         return m_declarator.get();
1089     }
1090     void setDeclarator(DeclaratorAST::Node& declarator);
1091 
expression()1092     AST* expression()
1093     {
1094         return m_expression.get();
1095     }
1096     void setExpression(AST::Node& expression);
1097 
1098     virtual QString text() const;
1099 
1100 private:
1101     TypeSpecifierAST::Node m_typeSpec;
1102     DeclaratorAST::Node m_declarator;
1103     AST::Node m_expression;
1104 
1105 private:
1106     ParameterDeclarationAST(const ParameterDeclarationAST& source);
1107     void operator = (const ParameterDeclarationAST& source);
1108 };
1109 
1110 class ParameterDeclarationListAST: public AST
1111 {
1112 public:
1113     typedef AUTO_PTR<ParameterDeclarationListAST> Node;
1114     enum { Type = NodeType_ParameterDeclarationList };
1115 
1116     DECLARE_ALLOC(ParameterDeclarationListAST)
1117 
1118 public:
1119     ParameterDeclarationListAST();
1120 
parameterList()1121     QList<ParameterDeclarationAST*> parameterList()
1122     {
1123         return m_parameterList;
1124     }
1125     void addParameter(ParameterDeclarationAST::Node& parameter);
1126 
1127     virtual QString text() const;
1128 
1129 private:
1130     QList<ParameterDeclarationAST*> m_parameterList;
1131 
1132 private:
1133     ParameterDeclarationListAST(const ParameterDeclarationListAST& source);
1134     void operator = (const ParameterDeclarationListAST& source);
1135 };
1136 
1137 class ParameterDeclarationClauseAST: public AST
1138 {
1139 public:
1140     typedef AUTO_PTR<ParameterDeclarationClauseAST> Node;
1141     enum { Type = NodeType_ParameterDeclarationClause };
1142 
1143     DECLARE_ALLOC(ParameterDeclarationClauseAST)
1144 
1145 public:
1146     ParameterDeclarationClauseAST();
1147 
parameterDeclarationList()1148     ParameterDeclarationListAST* parameterDeclarationList()
1149     {
1150         return m_parameterDeclarationList.get();
1151     }
1152     void setParameterDeclarationList(ParameterDeclarationListAST::Node& parameterDeclarationList);
1153 
ellipsis()1154     AST* ellipsis()
1155     {
1156         return m_ellipsis.get();
1157     }
1158     void setEllipsis(AST::Node& ellipsis);
1159 
1160     virtual QString text() const;
1161 
1162 private:
1163     ParameterDeclarationListAST::Node m_parameterDeclarationList;
1164     AST::Node m_ellipsis;
1165 
1166 private:
1167     ParameterDeclarationClauseAST(const ParameterDeclarationClauseAST& source);
1168     void operator = (const ParameterDeclarationClauseAST& source);
1169 };
1170 
1171 
1172 class InitDeclaratorAST: public AST
1173 {
1174 public:
1175     typedef AUTO_PTR<InitDeclaratorAST> Node;
1176     enum { Type = NodeType_InitDeclarator };
1177 
1178     DECLARE_ALLOC(InitDeclaratorAST)
1179 
1180 public:
1181     InitDeclaratorAST();
1182 
declarator()1183     DeclaratorAST* declarator()
1184     {
1185         return m_declarator.get();
1186     }
1187     void setDeclarator(DeclaratorAST::Node& declarator);
1188 
initializer()1189     AST* initializer()
1190     {
1191         return m_initializer.get();
1192     }
1193     void setInitializer(AST::Node& initializer);
1194 
1195 private:
1196     DeclaratorAST::Node m_declarator;
1197     AST::Node m_initializer;
1198 
1199 private:
1200     InitDeclaratorAST(const InitDeclaratorAST& source);
1201     void operator = (const InitDeclaratorAST& source);
1202 };
1203 
1204 class InitDeclaratorListAST: public AST
1205 {
1206 public:
1207     typedef AUTO_PTR<InitDeclaratorListAST> Node;
1208     enum { Type = NodeType_InitDeclaratorList };
1209 
1210     DECLARE_ALLOC(InitDeclaratorListAST)
1211 
1212 public:
1213     InitDeclaratorListAST();
1214 
initDeclaratorList()1215     QList<InitDeclaratorAST*> initDeclaratorList()
1216     {
1217         return m_initDeclaratorList;
1218     }
1219     void addInitDeclarator(InitDeclaratorAST::Node& decl);
1220 
1221 private:
1222     QList<InitDeclaratorAST*> m_initDeclaratorList;
1223 
1224 private:
1225     InitDeclaratorListAST(const InitDeclaratorListAST& source);
1226     void operator = (const InitDeclaratorListAST& source);
1227 };
1228 
1229 class TypedefAST: public DeclarationAST
1230 {
1231 public:
1232     typedef AUTO_PTR<TypedefAST> Node;
1233     enum { Type = NodeType_Typedef };
1234 
1235     DECLARE_ALLOC(TypedefAST)
1236 
1237 public:
1238     TypedefAST();
1239 
typeSpec()1240     TypeSpecifierAST* typeSpec()
1241     {
1242         return m_typeSpec.get();
1243     }
1244     void setTypeSpec(TypeSpecifierAST::Node& typeSpec);
1245 
initDeclaratorList()1246     InitDeclaratorListAST* initDeclaratorList()
1247     {
1248         return m_initDeclaratorList.get();
1249     }
1250     void setInitDeclaratorList(InitDeclaratorListAST::Node& initDeclaratorList);
1251 
1252 private:
1253     TypeSpecifierAST::Node m_typeSpec;
1254     InitDeclaratorListAST::Node m_initDeclaratorList;
1255 
1256 private:
1257     TypedefAST(const TypedefAST& source);
1258     void operator = (const TypedefAST& source);
1259 };
1260 
1261 class TemplateParameterAST: public AST
1262 {
1263 public:
1264     typedef AUTO_PTR<TemplateParameterAST> Node;
1265     enum { Type = NodeType_TemplateParameter };
1266 
1267     DECLARE_ALLOC(TemplateParameterAST)
1268 
1269 public:
1270     TemplateParameterAST();
1271 
typeParameter()1272     TypeParameterAST* typeParameter()
1273     {
1274         return m_typeParameter.get();
1275     }
1276     void setTypeParameter(TypeParameterAST::Node& typeParameter);
1277 
typeValueParameter()1278     ParameterDeclarationAST* typeValueParameter()
1279     {
1280         return m_typeValueParameter.get();
1281     }
1282     void setTypeValueParameter(ParameterDeclarationAST::Node& typeValueParameter);
1283 
1284 private:
1285     TypeParameterAST::Node m_typeParameter;
1286     ParameterDeclarationAST::Node m_typeValueParameter;
1287 
1288 private:
1289     TemplateParameterAST(const TemplateParameterAST& source);
1290     void operator = (const TemplateParameterAST& source);
1291 };
1292 
1293 class TemplateParameterListAST: public AST
1294 {
1295 public:
1296     typedef AUTO_PTR<TemplateParameterListAST> Node;
1297     enum { Type = NodeType_TemplateParameterList };
1298 
1299     DECLARE_ALLOC(TemplateParameterListAST)
1300 
1301 public:
1302     TemplateParameterListAST();
1303 
templateParameterList()1304     QList<TemplateParameterAST*> templateParameterList()
1305     {
1306         return m_templateParameterList;
1307     }
1308     void addTemplateParameter(TemplateParameterAST::Node& templateParameter);
1309 
1310 private:
1311     QList<TemplateParameterAST*> m_templateParameterList;
1312 
1313 private:
1314     TemplateParameterListAST(const TemplateParameterListAST& source);
1315     void operator = (const TemplateParameterListAST& source);
1316 };
1317 
1318 class TemplateDeclarationAST: public DeclarationAST
1319 {
1320 public:
1321     typedef AUTO_PTR<TemplateDeclarationAST> Node;
1322     enum { Type = NodeType_TemplateDeclaration };
1323 
1324     DECLARE_ALLOC(TemplateDeclarationAST)
1325 
1326 public:
1327     TemplateDeclarationAST();
1328 
exported()1329     AST* exported()
1330     {
1331         return m_exported.get();
1332     }
1333     void setExported(AST::Node& exported);
1334 
templateParameterList()1335     TemplateParameterListAST* templateParameterList()
1336     {
1337         return m_templateParameterList.get();
1338     }
1339     void setTemplateParameterList(TemplateParameterListAST::Node& templateParameterList);
1340 
declaration()1341     DeclarationAST* declaration()
1342     {
1343         return m_declaration.get();
1344     }
1345     void setDeclaration(DeclarationAST::Node& declaration);
1346 
1347 private:
1348     AST::Node m_exported;
1349     TemplateParameterListAST::Node m_templateParameterList;
1350     DeclarationAST::Node m_declaration;
1351 
1352 private:
1353     TemplateDeclarationAST(const TemplateDeclarationAST& source);
1354     void operator = (const TemplateDeclarationAST& source);
1355 };
1356 
1357 class SimpleDeclarationAST: public DeclarationAST
1358 {
1359 public:
1360     typedef AUTO_PTR<SimpleDeclarationAST> Node;
1361     enum { Type = NodeType_SimpleDeclaration };
1362 
1363     DECLARE_ALLOC(SimpleDeclarationAST)
1364 
1365 public:
1366     SimpleDeclarationAST();
1367 
functionSpecifier()1368     GroupAST* functionSpecifier()
1369     {
1370         return m_functionSpecifier.get();
1371     }
1372     void setFunctionSpecifier(GroupAST::Node& functionSpecifier);
1373 
storageSpecifier()1374     GroupAST* storageSpecifier()
1375     {
1376         return m_storageSpecifier.get();
1377     }
1378     void setStorageSpecifier(GroupAST::Node& storageSpecifier);
1379 
typeSpec()1380     TypeSpecifierAST* typeSpec()
1381     {
1382         return m_typeSpec.get();
1383     }
1384     void setTypeSpec(TypeSpecifierAST::Node& typeSpec);
1385 
initDeclaratorList()1386     InitDeclaratorListAST* initDeclaratorList()
1387     {
1388         return m_initDeclaratorList.get();
1389     }
1390     void setInitDeclaratorList(InitDeclaratorListAST::Node& initDeclaratorList);
1391 
winDeclSpec()1392     GroupAST* winDeclSpec()
1393     {
1394         return m_winDeclSpec.get();
1395     }
1396     void setWinDeclSpec(GroupAST::Node& winDeclSpec);
1397 
1398 private:
1399     GroupAST::Node m_functionSpecifier;
1400     GroupAST::Node m_storageSpecifier;
1401     TypeSpecifierAST::Node m_typeSpec;
1402     InitDeclaratorListAST::Node m_initDeclaratorList;
1403     GroupAST::Node m_winDeclSpec;
1404 
1405 private:
1406     SimpleDeclarationAST(const SimpleDeclarationAST& source);
1407     void operator = (const SimpleDeclarationAST& source);
1408 };
1409 
1410 class StatementAST: public AST
1411 {
1412 public:
1413     typedef AUTO_PTR<StatementAST> Node;
1414     enum { Type = NodeType_Statement };
1415 
1416     DECLARE_ALLOC(StatementAST)
1417 
1418 public:
1419     StatementAST();
1420 
1421 private:
1422     StatementAST(const StatementAST& source);
1423     void operator = (const StatementAST& source);
1424 };
1425 
1426 class ExpressionStatementAST: public StatementAST
1427 {
1428 public:
1429     typedef AUTO_PTR<ExpressionStatementAST> Node;
1430     enum { Type = NodeType_ExpressionStatement };
1431 
1432     DECLARE_ALLOC(ExpressionStatementAST)
1433 
1434 public:
1435     ExpressionStatementAST();
1436 
expression()1437     AST* expression()
1438     {
1439         return m_expression.get();
1440     }
1441     void setExpression(AST::Node& expression);
1442 
1443 private:
1444     AST::Node m_expression;
1445 
1446 private:
1447     ExpressionStatementAST(const ExpressionStatementAST& source);
1448     void operator = (const ExpressionStatementAST& source);
1449 };
1450 
1451 class ConditionAST: public AST
1452 {
1453 public:
1454     typedef AUTO_PTR<ConditionAST> Node;
1455     enum { Type = NodeType_Condition };
1456 
1457     DECLARE_ALLOC(ConditionAST)
1458 
1459 public:
1460     ConditionAST();
1461 
typeSpec()1462     TypeSpecifierAST* typeSpec()
1463     {
1464         return m_typeSpec.get();
1465     }
1466     void setTypeSpec(TypeSpecifierAST::Node& typeSpec);
1467 
declarator()1468     DeclaratorAST* declarator()
1469     {
1470         return m_declarator.get();
1471     }
1472     void setDeclarator(DeclaratorAST::Node& declarator);
1473 
expression()1474     AST* expression()
1475     {
1476         return m_expression.get();
1477     }
1478     void setExpression(AST::Node& expression);
1479 
1480 private:
1481     TypeSpecifierAST::Node m_typeSpec;
1482     DeclaratorAST::Node m_declarator;
1483     AST::Node m_expression;
1484 
1485 private:
1486     ConditionAST(const ConditionAST& source);
1487     void operator = (const ConditionAST& source);
1488 };
1489 
1490 class IfStatementAST: public StatementAST
1491 {
1492 public:
1493     typedef AUTO_PTR<IfStatementAST> Node;
1494     enum { Type = NodeType_IfStatement };
1495 
1496     DECLARE_ALLOC(IfStatementAST)
1497 
1498 public:
1499     IfStatementAST();
1500 
condition()1501     ConditionAST* condition() const
1502     {
1503         return m_condition.get();
1504     }
1505     void setCondition(ConditionAST::Node& condition);
1506 
statement()1507     StatementAST* statement()
1508     {
1509         return m_statement.get();
1510     }
1511     void setStatement(StatementAST::Node& statement);
1512 
elseStatement()1513     StatementAST* elseStatement()
1514     {
1515         return m_elseStatement.get();
1516     }
1517     void setElseStatement(StatementAST::Node& statement);
1518 
1519 private:
1520     ConditionAST::Node m_condition;
1521     StatementAST::Node m_statement;
1522     StatementAST::Node m_elseStatement;
1523 
1524 private:
1525     IfStatementAST(const IfStatementAST& source);
1526     void operator = (const IfStatementAST& source);
1527 };
1528 
1529 class WhileStatementAST: public StatementAST
1530 {
1531 public:
1532     typedef AUTO_PTR<WhileStatementAST> Node;
1533     enum { Type = NodeType_WhileStatement };
1534 
1535     DECLARE_ALLOC(WhileStatementAST)
1536 
1537 public:
1538     WhileStatementAST();
1539 
condition()1540     ConditionAST* condition() const
1541     {
1542         return m_condition.get();
1543     }
1544     void setCondition(ConditionAST::Node& condition);
1545 
statement()1546     StatementAST* statement()
1547     {
1548         return m_statement.get();
1549     }
1550     void setStatement(StatementAST::Node& statement);
1551 
1552 private:
1553     ConditionAST::Node m_condition;
1554     StatementAST::Node m_statement;
1555 
1556 private:
1557     WhileStatementAST(const WhileStatementAST& source);
1558     void operator = (const WhileStatementAST& source);
1559 };
1560 
1561 class DoStatementAST: public StatementAST
1562 {
1563 public:
1564     typedef AUTO_PTR<DoStatementAST> Node;
1565     enum { Type = NodeType_DoStatement };
1566 
1567     DECLARE_ALLOC(DoStatementAST)
1568 
1569 public:
1570     DoStatementAST();
1571 
condition()1572     ConditionAST* condition() const
1573     {
1574         return m_condition.get();
1575     }
1576     void setCondition(ConditionAST::Node& condition);
1577 
statement()1578     StatementAST* statement()
1579     {
1580         return m_statement.get();
1581     }
1582     void setStatement(StatementAST::Node& statement);
1583 
1584 private:
1585     ConditionAST::Node m_condition;
1586     StatementAST::Node m_statement;
1587 
1588 private:
1589     DoStatementAST(const DoStatementAST& source);
1590     void operator = (const DoStatementAST& source);
1591 };
1592 
1593 class ForStatementAST: public StatementAST
1594 {
1595 public:
1596     typedef AUTO_PTR<ForStatementAST> Node;
1597     enum { Type = NodeType_ForStatement };
1598 
1599     DECLARE_ALLOC(ForStatementAST)
1600 
1601 public:
1602     ForStatementAST();
1603 
initStatement()1604     StatementAST* initStatement()
1605     {
1606         return m_initStatement.get();
1607     }
1608     void setInitStatement(StatementAST::Node& statement);
1609 
condition()1610     ConditionAST* condition() const
1611     {
1612         return m_condition.get();
1613     }
1614     void setCondition(ConditionAST::Node& condition);
1615 
expression()1616     AST* expression() const
1617     {
1618         return m_expression.get();
1619     }
1620     void setExpression(AST::Node& expression);
1621 
statement()1622     StatementAST* statement()
1623     {
1624         return m_statement.get();
1625     }
1626     void setStatement(StatementAST::Node& statement);
1627 
1628 private:
1629     ConditionAST::Node m_condition;
1630     StatementAST::Node m_initStatement;
1631     StatementAST::Node m_statement;
1632     AST::Node m_expression;
1633 
1634 private:
1635     ForStatementAST(const ForStatementAST& source);
1636     void operator = (const ForStatementAST& source);
1637 };
1638 
1639 // qt4 [erbsland]
1640 class ForEachStatementAST: public StatementAST
1641 {
1642 public:
1643     typedef AUTO_PTR<ForEachStatementAST> Node;
1644     enum { Type = NodeType_ForEachStatement };
1645 
1646     DECLARE_ALLOC(ForEachStatementAST)
1647 
1648 public:
1649     ForEachStatementAST();
1650 
initStatement()1651     StatementAST* initStatement()
1652     {
1653         return m_initStatement.get();
1654     }
1655     void setInitStatement(StatementAST::Node& statement);
1656 
statement()1657     StatementAST* statement()
1658     {
1659         return m_statement.get();
1660     }
1661     void setStatement(StatementAST::Node& statement);
1662 
expression()1663     AST* expression() const
1664     {
1665         return m_expression.get();
1666     }
1667     void setExpression(AST::Node& expression);
1668 
1669 private:
1670     StatementAST::Node m_initStatement;
1671     StatementAST::Node m_statement;
1672     AST::Node m_expression;
1673 
1674 private:
1675     ForEachStatementAST(const ForEachStatementAST& source);
1676     void operator = (const ForEachStatementAST& source);
1677 };
1678 
1679 class SwitchStatementAST: public StatementAST
1680 {
1681 public:
1682     typedef AUTO_PTR<SwitchStatementAST> Node;
1683     enum { Type = NodeType_SwitchStatement };
1684 
1685     DECLARE_ALLOC(SwitchStatementAST)
1686 
1687 public:
1688     SwitchStatementAST();
1689 
condition()1690     ConditionAST* condition() const
1691     {
1692         return m_condition.get();
1693     }
1694     void setCondition(ConditionAST::Node& condition);
1695 
statement()1696     StatementAST* statement()
1697     {
1698         return m_statement.get();
1699     }
1700     void setStatement(StatementAST::Node& statement);
1701 
1702 private:
1703     ConditionAST::Node m_condition;
1704     StatementAST::Node m_statement;
1705 
1706 private:
1707     SwitchStatementAST(const SwitchStatementAST& source);
1708     void operator = (const SwitchStatementAST& source);
1709 };
1710 
1711 class StatementListAST: public StatementAST
1712 {
1713 public:
1714     typedef AUTO_PTR<StatementListAST> Node;
1715     enum { Type = NodeType_StatementList };
1716 
1717     DECLARE_ALLOC(StatementListAST)
1718 
1719 public:
1720     StatementListAST();
1721 
statementList()1722     QList<StatementAST*> statementList()
1723     {
1724         return m_statementList;
1725     }
1726     void addStatement(StatementAST::Node& statement);
1727 
1728 private:
1729     QList<StatementAST*> m_statementList;
1730 
1731 private:
1732     StatementListAST(const StatementListAST& source);
1733     void operator = (const StatementListAST& source);
1734 };
1735 
1736 class CatchStatementAST: public StatementAST
1737 {
1738 public:
1739     typedef AUTO_PTR<CatchStatementAST> Node;
1740     enum { Type = NodeType_CatchStatement };
1741 
1742     DECLARE_ALLOC(CatchStatementAST)
1743 
1744 public:
1745     CatchStatementAST();
1746 
condition()1747     ConditionAST* condition() const
1748     {
1749         return m_condition.get();
1750     }
1751     void setCondition(ConditionAST::Node& condition);
1752 
statement()1753     StatementAST* statement()
1754     {
1755         return m_statement.get();
1756     }
1757     void setStatement(StatementAST::Node& statement);
1758 
1759 private:
1760     ConditionAST::Node m_condition;
1761     StatementAST::Node m_statement;
1762 
1763 private:
1764     CatchStatementAST(const CatchStatementAST& source);
1765     void operator = (const CatchStatementAST& source);
1766 };
1767 
1768 class CatchStatementListAST: public StatementAST
1769 {
1770 public:
1771     typedef AUTO_PTR<CatchStatementListAST> Node;
1772     enum { Type = NodeType_CatchStatementList };
1773 
1774     DECLARE_ALLOC(CatchStatementListAST)
1775 
1776 public:
1777     CatchStatementListAST();
1778 
statementList()1779     QList<CatchStatementAST*> statementList()
1780     {
1781         return m_statementList;
1782     }
1783     void addStatement(CatchStatementAST::Node& statement);
1784 
1785 private:
1786     QList<CatchStatementAST*> m_statementList;
1787 
1788 private:
1789     CatchStatementListAST(const CatchStatementListAST& source);
1790     void operator = (const CatchStatementListAST& source);
1791 };
1792 
1793 class TryBlockStatementAST: public StatementAST
1794 {
1795 public:
1796     typedef AUTO_PTR<TryBlockStatementAST> Node;
1797     enum { Type = NodeType_TryBlockStatement };
1798 
1799     DECLARE_ALLOC(TryBlockStatementAST)
1800 
1801 public:
1802     TryBlockStatementAST();
1803 
statement()1804     StatementAST* statement()
1805     {
1806         return m_statement.get();
1807     }
1808     void setStatement(StatementAST::Node& statement);
1809 
catchStatementList()1810     CatchStatementListAST* catchStatementList()
1811     {
1812         return m_catchStatementList.get();
1813     }
1814     void setCatchStatementList(CatchStatementListAST::Node& statementList);
1815 
1816 private:
1817     StatementAST::Node m_statement;
1818     CatchStatementListAST::Node m_catchStatementList;
1819 
1820 private:
1821     TryBlockStatementAST(const TryBlockStatementAST& source);
1822     void operator = (const TryBlockStatementAST& source);
1823 };
1824 
1825 class DeclarationStatementAST: public StatementAST
1826 {
1827 public:
1828     typedef AUTO_PTR<DeclarationStatementAST> Node;
1829     enum { Type = NodeType_DeclarationStatement };
1830 
1831     DECLARE_ALLOC(DeclarationStatementAST)
1832 
1833 public:
1834     DeclarationStatementAST();
1835 
declaration()1836     DeclarationAST* declaration()
1837     {
1838         return m_declaration.get();
1839     }
1840     void setDeclaration(DeclarationAST::Node& declaration);
1841 
1842 private:
1843     DeclarationAST::Node m_declaration;
1844 
1845 private:
1846     DeclarationStatementAST(const DeclarationStatementAST& source);
1847     void operator = (const DeclarationStatementAST& source);
1848 };
1849 
1850 class FunctionDefinitionAST: public DeclarationAST
1851 {
1852 public:
1853     typedef AUTO_PTR<FunctionDefinitionAST> Node;
1854     enum { Type = NodeType_FunctionDefinition };
1855 
1856     DECLARE_ALLOC(FunctionDefinitionAST)
1857 
1858 public:
1859     FunctionDefinitionAST();
1860 
functionSpecifier()1861     GroupAST* functionSpecifier()
1862     {
1863         return m_functionSpecifier.get();
1864     }
1865     void setFunctionSpecifier(GroupAST::Node& functionSpecifier);
1866 
storageSpecifier()1867     GroupAST* storageSpecifier()
1868     {
1869         return m_storageSpecifier.get();
1870     }
1871     void setStorageSpecifier(GroupAST::Node& storageSpecifier);
1872 
typeSpec()1873     TypeSpecifierAST* typeSpec()
1874     {
1875         return m_typeSpec.get();
1876     }
1877     void setTypeSpec(TypeSpecifierAST::Node& typeSpec);
1878 
initDeclarator()1879     InitDeclaratorAST* initDeclarator()
1880     {
1881         return m_initDeclarator.get();
1882     }
1883     void setInitDeclarator(InitDeclaratorAST::Node& initDeclarator);
1884 
functionBody()1885     StatementListAST* functionBody()
1886     {
1887         return m_functionBody.get();
1888     }
1889     void setFunctionBody(StatementListAST::Node& functionBody);
1890 
winDeclSpec()1891     GroupAST* winDeclSpec()
1892     {
1893         return m_winDeclSpec.get();
1894     }
1895     void setWinDeclSpec(GroupAST::Node& winDeclSpec);
1896 
1897 private:
1898     GroupAST::Node m_functionSpecifier;
1899     GroupAST::Node m_storageSpecifier;
1900     TypeSpecifierAST::Node m_typeSpec;
1901     InitDeclaratorAST::Node m_initDeclarator;
1902     StatementListAST::Node m_functionBody;
1903     GroupAST::Node m_winDeclSpec;
1904 
1905 private:
1906     FunctionDefinitionAST(const FunctionDefinitionAST& source);
1907     void operator = (const FunctionDefinitionAST& source);
1908 };
1909 
1910 
1911 class TranslationUnitAST: public AST, public KShared
1912 {
1913 public:
1914     typedef KSharedPtr<TranslationUnitAST> Node;
1915     enum { Type = NodeType_TranslationUnit };
1916 
1917     DECLARE_ALLOC(TranslationUnitAST)
1918 
1919 public:
1920     TranslationUnitAST();
1921 
1922     void addDeclaration(DeclarationAST::Node& ast);
declarationList()1923     QList<DeclarationAST*> declarationList()
1924     {
1925         return m_declarationList;
1926     }
1927 
1928 private:
1929     QList<DeclarationAST*> m_declarationList;
1930 
1931 private:
1932     TranslationUnitAST(const TranslationUnitAST& source);
1933     void operator = (const TranslationUnitAST& source);
1934 };
1935 
1936 #endif
1937