30
// Common node interface
31
/** \class PreTree PreTree.h Puma/PreTree.h
32
* Base class for all C preprocessor syntax tree nodes. */
36
virtual void add_son (PreTree *);
37
virtual void replace_son (int, PreTree *);
38
virtual PreTree *son (int) const;
39
virtual int sons () const;
41
virtual void add_daughter (PreTree *);
42
virtual void replace_daughter (int, PreTree *);
43
virtual PreTree *daughter (int) const;
44
virtual int daughters () const;
46
40
virtual ~PreTree() {}
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;
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);
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;
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;
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;
55
83
} // namespace Puma
57
85
#endif /* __pre_syntax_tree__ */