~ubuntu-branches/ubuntu/jaunty/aspectc++/jaunty

« back to all changes in this revision

Viewing changes to Puma/src/cpp/PreTree.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-07-07 14:41:02 UTC
  • mfrom: (1.1.3 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080707144102-lzml7t07f3sl00r5
Tags: 1.0pre4~svn.20080711-1
* new upstream snapshot.
* include all upstream documentation. Clarifying emails regarding
  licensing has been included into debian/copyright.
* reformat description following recomendations of
  http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
  (Closes: #480316)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef __pre_syntax_tree__
20
20
#define __pre_syntax_tree__
21
21
 
22
 
// Syntax tree definition according to the composite pattern from [GoF].
 
22
/** \file 
 
23
 *  Base preprocessor syntax tree class. */
23
24
 
24
25
#include "Puma/PreVisitor.h"
25
26
#include "Puma/Token.h"
27
28
namespace Puma {
28
29
 
29
30
 
30
 
// Common node interface
 
31
/** \class PreTree PreTree.h Puma/PreTree.h
 
32
 *  Base class for all C preprocessor syntax tree nodes. */
31
33
class PreTree {
32
34
protected:
 
35
  /** Constructor. */
33
36
  PreTree () {};
34
37
 
35
38
public:
36
 
  virtual void add_son (PreTree *);
37
 
  virtual void replace_son (int, PreTree *);
38
 
  virtual PreTree *son (int) const;
39
 
  virtual int sons () const;
40
 
 
41
 
  virtual void add_daughter (PreTree *);
42
 
  virtual void replace_daughter (int, PreTree *);
43
 
  virtual PreTree *daughter (int) const;
44
 
  virtual int daughters () const;
45
 
 
 
39
  /** Destructor. */
46
40
  virtual ~PreTree() {}
 
41
 
 
42
  /** Check if the node is a leaf, i.e. it has no child nodes. */
47
43
  virtual bool isLeaf () const;
 
44
  /** Part of the tree visitor pattern. Calls the node
 
45
   *  visiting function suitable for the actual node type. */
48
46
  virtual void accept (PreVisitor &) = 0;
 
47
 
 
48
  /** Add a son (syntactic child node). 
 
49
   *  \param s The son to add. */
 
50
  virtual void add_son (PreTree *s);
 
51
  /** Replace the n-th son.
 
52
   *  \param n The index of the son to replace.
 
53
   *  \param new_s The new son. */
 
54
  virtual void replace_son (int n, PreTree *new_s);
 
55
  /** Get the n-th son. 
 
56
   *  \param n The index of the son. */
 
57
  virtual PreTree *son (int n) const;
 
58
  /** Get the number of sons. */
 
59
  virtual int sons () const;
 
60
 
 
61
  /** Add a daughter (semantic child node).
 
62
   *  \param d The daughter to add. */
 
63
  virtual void add_daughter (PreTree *d);
 
64
  /** Replace the n-th daughter.
 
65
   *  \param n The index of the daughter.
 
66
   *  \param new_d The new daughter. */
 
67
  virtual void replace_daughter (int n, PreTree *new_d);
 
68
  /** Get the n-th daughter.
 
69
   *  \param n The index of the daughter. */
 
70
  virtual PreTree *daughter (int n) const;
 
71
  /** Get the number of daughters. */
 
72
  virtual int daughters () const;
49
73
        
 
74
  /** Get the first token of the syntactic construct 
 
75
   *  represented by the sub-tree. */
50
76
  virtual Token *startToken () const;
 
77
  /** Get the last token of the syntactic construct
 
78
   *  represented by the sub-tree. */
51
79
  virtual Token *endToken () const;
52
80
};
53
81
 
54
 
 
 
82
 
55
83
} // namespace Puma
56
84
 
57
85
#endif /* __pre_syntax_tree__ */