ROSE
0.9.6a
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
Ast.h
Go to the documentation of this file.
1
// Author: Markus Schordan, Vienna University of Technology, 2004.
2
// $Id: Ast.h,v 1.4 2008/01/08 02:56:38 dquinlan Exp $
3
4
// WORK IN PROGRESS : only use the public interface (!)
5
// - currently only the forward iterator is supported
6
// - copy-by-value will be replaced by references and using const
7
// - null_iterator may also be added (including encountered null pointers)
8
9
#ifndef AST_H
10
#define AST_H
11
12
#include <vector>
13
#include "roseInternal.h"
14
//#include "sage3.h"
15
19
20
class
Ast
{
21
public
:
22
typedef
SgNode
elementType
;
23
typedef
elementType
*
pointer
;
24
typedef
elementType
&
reference
;
25
typedef
size_t
size_type
;
26
// no default constructor
27
29
Ast
(
SgNode
* astNode);
30
SgNode
*
operator*
();
31
32
class
iterator
{
33
private
:
34
friend
class
Ast
;
35
SgNode
*
findNextNode
(
SgNode
* p);
36
37
protected
:
38
// DQ (10/24/2004): Swapped order of declaration to avoid compiler warning
39
SgNode
*
node
;
40
SgNode
*
startNode
;
41
iterator
(
SgNode
* x) :
node
(x),
startNode
(x) {}
42
43
public
:
44
iterator
() {}
45
bool
operator==
(
const
iterator
& x)
const
{
return
node
== x.
node
; }
46
bool
operator!=
(
const
iterator
& x)
const
{
return
node
!= x.
node
; }
47
reference
operator*
()
const
{
return
(*
node
); }
48
iterator
&
operator++
();
49
iterator
operator++
(
int
) {
50
iterator
tmp = *
this
;
51
++*
this
;
52
return
tmp;
53
}
54
};
55
57
iterator
begin
() {
return
iterator
(
startNode
); }
59
iterator
end
() {
return
iterator
(0); }
60
61
protected
:
62
typedef
std::vector<SgNode*>
NodeList
;
63
static
NodeList
successors
(
SgNode
* astNode);
64
static
unsigned
int
numSuccessors
(
SgNode
* astNode);
65
static
NodeList
rightSiblings
(
SgNode
* astNode);
66
static
unsigned
int
numRightSiblings
(
SgNode
* astNode);
67
static
SgNode
*
nextRightSibling
(
SgNode
* astNode);
68
static
SgNode
*
parent
(
SgNode
* astNode);
69
private
:
70
static
SgNode
*
first
(
NodeList
l) {
return
*(l.begin()); }
71
SgNode
*
startNode
;
72
};
73
74
#endif
rose-edg4x
src
midend
astProcessing
Ast.h
Generated on Mon May 5 2014 17:28:49 for ROSE by
1.8.4