File: Synopsis/PTree/Lists.hh
  1//
  2// Copyright (C) 1997-2000 Shigeru Chiba
  3// Copyright (C) 2004 Stefan Seefeld
  4// All rights reserved.
  5// Licensed to the public under the terms of the GNU LGPL (>= 2),
  6// see the file COPYING for details.
  7//
  8#ifndef Synopsis_PTree_Lists_hh_
  9#define Synopsis_PTree_Lists_hh_
 10
 11#include <Synopsis/PTree/operations.hh>
 12#include <Synopsis/PTree/Encoding.hh>
 13
 14namespace Synopsis
 15{
 16namespace PTree
 17{
 18
 19class Brace : public List 
 20{
 21public:
 22  Brace(Node *p, Node *q) : List(p, q) {}
 23  Brace(Node *ob, Node *body, Node *cb) : List(ob, list(body, cb)) {}
 24  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 25};
 26
 27class Block : public Brace 
 28{
 29public:
 30  Block(Node *p, Node *q) : Brace(p, q) {}
 31  Block(Node *ob, Node *bdy, Node *cb) : Brace(ob, bdy, cb) {}
 32  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 33};
 34
 35class ClassBody : public Brace 
 36{
 37public:
 38  ClassBody(Node *p, Node *q) : Brace(p, q) {}
 39  ClassBody(Node *ob, Node *bdy, Node *cb) : Brace(ob, bdy, cb) {}
 40  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 41};
 42
 43class Typedef : public List
 44{
 45public:
 46  Typedef(Node *p) : List(p, 0) {}
 47  Typedef(Node *p, Node *q) : List(p, q) {}
 48  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 49};
 50
 51class TemplateDecl : public List
 52{
 53public:
 54  TemplateDecl(Node *p, Node *q) : List(p, q) {}
 55  TemplateDecl(Node *p) : List(p, 0) {}
 56  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 57};
 58
 59class TemplateInstantiation : public List
 60{
 61public:
 62  TemplateInstantiation(Node *p) : List(p, 0) {}
 63  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 64};
 65
 66class ExternTemplate : public List
 67{
 68public:
 69  ExternTemplate(Node *p, Node *q) : List(p, q) {}
 70  ExternTemplate(Node *p) : List(p, 0) {}
 71  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 72};
 73
 74class MetaclassDecl : public List
 75{
 76public:
 77  MetaclassDecl(Node *p, Node *q) : List(p, q) {}
 78  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 79};
 80
 81class LinkageSpec : public List
 82{
 83public:
 84  LinkageSpec(Node *p, Node *q) : List(p, q) {}
 85  virtual void accept(Visitor *visitor) { visitor->visit(this);}
 86};
 87
 88class NamespaceSpec : public List
 89{
 90public:
 91  NamespaceSpec(Node *p, Node *q) : List(p, q), my_comments(0) {}
 92  virtual void accept(Visitor *visitor) { visitor->visit(this);}  
 93  Node *get_comments() { return my_comments;}
 94  void set_comments(Node *c) { my_comments = c;}
 95
 96private:
 97  Node *my_comments;
 98};
 99
100class Declaration : public List
101{
102public:
103  Declaration(Node *p, Node *q) : List(p, q), my_comments(0) {}
104  virtual void accept(Visitor *visitor) { visitor->visit(this);}
105  Node *get_comments() { return my_comments;}
106  void set_comments(Node *c) { my_comments = c;}
107
108private:
109  Node *my_comments;
110};
111
112class UsingDirective : public Declaration
113{
114public:
115  UsingDirective(Node *p) : Declaration(p, 0) {}
116  virtual void accept(Visitor *visitor) { visitor->visit(this);}
117};
118
119class UsingDeclaration : public Declaration
120{
121public:
122  UsingDeclaration(Node *p, Node *q) : Declaration(p, q) {}
123  virtual void accept(Visitor *visitor) { visitor->visit(this);}
124};
125
126class NamespaceAlias : public Declaration
127{
128public:
129  NamespaceAlias(Node *p, Node *q) : Declaration(p, q) {}
130  virtual void accept(Visitor *visitor) { visitor->visit(this);}
131};
132
133class FunctionDefinition : public Declaration
134{
135public:
136  FunctionDefinition(Node *p, Node *q) : Declaration(p, q) {}
137  virtual void accept(Visitor *visitor) { visitor->visit(this);}
138};
139
140class ParameterDeclaration : public List 
141{
142public:
143  ParameterDeclaration(Node *mod, Node *type, Node *decl)
144    : List(mod, list(type, decl)) {}
145  virtual void accept(Visitor *visitor) { visitor->visit(this);}
146};
147
148class Declarator : public List
149{
150public:
151  Declarator(Node *);
152  Declarator(Node *, Encoding const&, Encoding const&, Node *);
153  Declarator(Encoding const&, Encoding const&, Node *);
154  Declarator(Node *, Node *, Encoding const&, Encoding const&, Node *);
155  Declarator(Node *, Encoding const&);
156  Declarator(Encoding const&);
157  Declarator(Declarator*, Node *, Node *);
158
159  virtual void accept(Visitor *visitor) { visitor->visit(this);}
160  Encoding encoded_type() const { return my_type;}
161  Encoding encoded_name() const { return my_name;}
162  void set_encoded_type(const Encoding &t) { my_type = t;}
163  Node *name() { return my_declared_name;}
164  Node *initializer();
165  Node *get_comments() { return my_comments;}
166  void set_comments(Node *c) { my_comments = c;}
167private:
168  Encoding my_type;
169  Encoding my_name;
170  Node    *my_declared_name;
171  Node    *my_comments;
172};
173
174class Name : public List
175{
176public:
177  Name(Node *, const Encoding &);
178  virtual void accept(Visitor *visitor) { visitor->visit(this);}
179  Encoding encoded_name() const { return my_name;}
180private:
181  Encoding my_name;
182};
183
184class FstyleCastExpr : public List
185{
186public:
187  FstyleCastExpr(const Encoding &, Node *, Node *);
188  virtual void accept(Visitor *visitor) { visitor->visit(this);}
189  Encoding encoded_type() const { return my_type;}
190private:
191  Encoding my_type;
192};
193
194class ClassSpec : public List
195{
196public:
197  ClassSpec(Node *, Node *, Node *);
198  ClassSpec(const Encoding &, Node *, Node *, Node *);
199  virtual void accept(Visitor *visitor) { visitor->visit(this);}
200  Encoding encoded_name() const { return my_name;}
201  void set_encoded_name(const Encoding &n) { my_name = n;}
202  Node *get_comments() { return my_comments;}
203  //. The list of base classes, i.e. [: [public A] , [public virtual B] ...]
204  Node const *base_clause() const 
205  { return static_cast<List const *>(PTree::third(this));}
206  //. The following assumes proper C++, i.e. no OpenC++ extension.
207  ClassBody *body();
208private:
209  Encoding my_name;
210  Node    *my_comments;
211};
212
213class EnumSpec : public List
214{
215public:
216  EnumSpec(Node *head) : List(head, 0) {}
217  virtual void accept(Visitor *visitor) { visitor->visit(this);}
218  Encoding encoded_name() const { return my_name;}
219  void set_encoded_name(const Encoding &n) { my_name = n;}
220private:
221  Encoding my_name;
222};
223
224class TypeParameter : public List 
225{
226public:
227  TypeParameter(Node *p, Node *q) : List(p, q) {}
228  virtual void accept(Visitor *visitor) { visitor->visit(this);}
229};
230
231class AccessSpec : public List
232{
233public:
234  AccessSpec(Node *p, Node *q, Node *c) : List(p, q), my_comments(c) {}
235  virtual void accept(Visitor *visitor) { visitor->visit(this);}
236  Node *get_comments() { return my_comments;}
237private:
238  Node *my_comments;
239};
240
241class AccessDecl : public List
242{
243public:
244  AccessDecl(Node *p, Node *q) : List(p, q) {}
245  virtual void accept(Visitor *visitor) { visitor->visit(this);}
246};
247
248class UserAccessSpec : public List
249{
250public:
251  UserAccessSpec(Node *p, Node *q) : List(p, q) {}
252  virtual void accept(Visitor *visitor) { visitor->visit(this);}
253};
254
255class UserdefKeyword : public List
256{
257public:
258  UserdefKeyword(Node *p, Node *q) : List(p, q) {}
259  virtual void accept(Visitor *visitor) { visitor->visit(this);}
260};
261
262template <typename T>
263class StatementT : public List
264{
265public:
266  StatementT(Node *p, Node *q) : List(p, q) {}
267  virtual void accept(Visitor *visitor) { visitor->visit(static_cast<T *>(this));}
268};
269
270class IfStatement : public StatementT<IfStatement> 
271{
272public:
273  IfStatement(Node *p, Node *q) : StatementT<IfStatement>(p, q) {} 
274};
275
276class SwitchStatement : public StatementT<SwitchStatement> 
277{
278public:
279  SwitchStatement(Node *p, Node *q) : StatementT<SwitchStatement>(p, q) {} 
280};
281
282class WhileStatement : public StatementT<WhileStatement> 
283{
284public:
285  WhileStatement(Node *p, Node *q) : StatementT<WhileStatement>(p, q) {} 
286};
287
288class DoStatement : public StatementT<DoStatement> 
289{
290public:
291  DoStatement(Node *p, Node *q) : StatementT<DoStatement>(p, q) {} 
292};
293
294class ForStatement : public StatementT<ForStatement> 
295{
296public:
297  ForStatement(Node *p, Node *q) : StatementT<ForStatement>(p, q) {} 
298};
299
300class TryStatement : public StatementT<TryStatement> 
301{
302public:
303  TryStatement(Node *p, Node *q) : StatementT<TryStatement>(p, q) {} 
304};
305
306class BreakStatement : public StatementT<BreakStatement> 
307{
308public:
309  BreakStatement(Node *p, Node *q) : StatementT<BreakStatement>(p, q) {} 
310};
311
312class ContinueStatement : public StatementT<ContinueStatement> 
313{
314public:
315  ContinueStatement(Node *p, Node *q) : StatementT<ContinueStatement>(p, q) {} 
316};
317
318class ReturnStatement : public StatementT<ReturnStatement> 
319{
320public:
321  ReturnStatement(Node *p, Node *q) : StatementT<ReturnStatement>(p, q) {} 
322};
323
324class GotoStatement : public StatementT<GotoStatement> 
325{
326public:
327  GotoStatement(Node *p, Node *q) : StatementT<GotoStatement>(p, q) {} 
328};
329
330class CaseStatement : public StatementT<CaseStatement> 
331{
332public:
333  CaseStatement(Node *p, Node *q) : StatementT<CaseStatement>(p, q) {} 
334};
335
336class DefaultStatement : public StatementT<DefaultStatement> 
337{
338public:
339  DefaultStatement(Node *p, Node *q) : StatementT<DefaultStatement>(p, q) {} 
340};
341
342class LabelStatement : public StatementT<LabelStatement> 
343{
344public:
345  LabelStatement(Node *p, Node *q) : StatementT<LabelStatement>(p, q) {} 
346};
347
348class ExprStatement : public StatementT<ExprStatement> 
349{
350public:
351  ExprStatement(Node *p, Node *q) : StatementT<ExprStatement>(p, q) {} 
352};
353
354class Expression : public List
355{
356public:
357  Expression(Node *p, Node *q) : List(p, q) {}
358  virtual void accept(Visitor *visitor) { visitor->visit(this);}
359};
360
361template <typename T>
362class ExpressionT : public List
363{
364public:
365  ExpressionT(Node *p, Node *q) : List(p, q) {}
366  virtual void accept(Visitor *visitor) { visitor->visit(static_cast<T *>(this));}
367};
368
369class AssignExpr : public ExpressionT<AssignExpr> 
370{
371public:
372  AssignExpr(Node *p, Node *q) : ExpressionT<AssignExpr>(p, q) {} 
373};
374
375class CondExpr : public ExpressionT<CondExpr> 
376{
377public:
378  CondExpr(Node *p, Node *q) : ExpressionT<CondExpr>(p, q) {} 
379};
380
381class InfixExpr : public ExpressionT<InfixExpr> 
382{
383public:
384  InfixExpr(Node *p, Node *q) : ExpressionT<InfixExpr>(p, q) {} 
385};
386
387class PmExpr : public ExpressionT<PmExpr> 
388{
389public:
390  PmExpr(Node *p, Node *q) : ExpressionT<PmExpr>(p, q) {} 
391};
392
393class CastExpr : public ExpressionT<CastExpr> 
394{
395public:
396  CastExpr(Node *p, Node *q) : ExpressionT<CastExpr>(p, q) {} 
397};
398
399class UnaryExpr : public ExpressionT<UnaryExpr> 
400{
401public:
402  UnaryExpr(Node *p, Node *q) : ExpressionT<UnaryExpr>(p, q) {} 
403};
404
405class ThrowExpr : public ExpressionT<ThrowExpr> 
406{
407public:
408  ThrowExpr(Node *p, Node *q) : ExpressionT<ThrowExpr>(p, q) {} 
409};
410
411class SizeofExpr : public ExpressionT<SizeofExpr> 
412{
413public:
414  SizeofExpr(Node *p, Node *q) : ExpressionT<SizeofExpr>(p, q) {} 
415};
416
417class OffsetofExpr : public ExpressionT<OffsetofExpr> 
418{
419public:
420  OffsetofExpr(Node *p, Node *q) : ExpressionT<OffsetofExpr>(p, q) {} 
421};
422
423class TypeidExpr : public ExpressionT<TypeidExpr> 
424{
425public:
426  TypeidExpr(Node *p, Node *q) : ExpressionT<TypeidExpr>(p, q) {} 
427};
428
429class TypeofExpr : public ExpressionT<TypeofExpr> 
430{
431public:
432  TypeofExpr(Node *p, Node *q) : ExpressionT<TypeofExpr>(p, q) {} 
433};
434
435class NewExpr : public ExpressionT<NewExpr> 
436{
437public:
438  NewExpr(Node *p, Node *q) : ExpressionT<NewExpr>(p, q) {} 
439};
440
441class DeleteExpr : public ExpressionT<DeleteExpr> 
442{
443public:
444  DeleteExpr(Node *p, Node *q) : ExpressionT<DeleteExpr>(p, q) {} 
445};
446
447class ArrayExpr : public ExpressionT<ArrayExpr> 
448{
449public:
450  ArrayExpr(Node *p, Node *q) : ExpressionT<ArrayExpr>(p, q) {} 
451};
452
453class FuncallExpr : public ExpressionT<FuncallExpr> 
454{
455public:
456  FuncallExpr(Node *p, Node *q) : ExpressionT<FuncallExpr>(p, q) {} 
457};
458
459class PostfixExpr : public ExpressionT<PostfixExpr> 
460{
461public:
462  PostfixExpr(Node *p, Node *q) : ExpressionT<PostfixExpr>(p, q) {} 
463};
464
465class UserStatementExpr : public ExpressionT<UserStatementExpr> 
466{
467public:
468  UserStatementExpr(Node *p, Node *q) : ExpressionT<UserStatementExpr>(p, q) {} 
469};
470
471class DotMemberExpr : public ExpressionT<DotMemberExpr> 
472{
473public:
474  DotMemberExpr(Node *p, Node *q) : ExpressionT<DotMemberExpr>(p, q) {} 
475};
476
477class ArrowMemberExpr : public ExpressionT<ArrowMemberExpr> 
478{
479public:
480  ArrowMemberExpr(Node *p, Node *q) : ExpressionT<ArrowMemberExpr>(p, q) {} 
481};
482
483class ParenExpr : public ExpressionT<ParenExpr> 
484{
485public:
486  ParenExpr(Node *p, Node *q) : ExpressionT<ParenExpr>(p, q) {} 
487};
488
489class StaticUserStatementExpr : public ExpressionT<StaticUserStatementExpr> 
490{
491public:
492  StaticUserStatementExpr(Node *p, Node *q) : ExpressionT<StaticUserStatementExpr>(p, q) {} 
493};
494
495}
496}
497
498#endif