SeExpr
ExprWalker.h
Go to the documentation of this file.
1/*
2 Copyright Disney Enterprises, Inc. All rights reserved.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License
6 and the following modification to it: Section 6 Trademarks.
7 deleted and replaced with:
8
9 6. Trademarks. This License does not grant permission to use the
10 trade names, trademarks, service marks, or product names of the
11 Licensor and its affiliates, except as required for reproducing
12 the content of the NOTICE file.
13
14 You may obtain a copy of the License at
15 http://www.apache.org/licenses/LICENSE-2.0
16*/
17
18#ifndef ExprWalker_h
19#define ExprWalker_h
20
21namespace SeExpr2 {
22
23template <class T, bool constnode>
24struct ADD_CONST {
25 typedef T TYPE;
26};
27template <class T>
28struct ADD_CONST<T, true> {
29 typedef const T TYPE;
30};
31
32template <bool constnode = false>
33class Examiner {
34 public:
36
37 virtual bool examine(T_NODE* examinee) = 0;
38 virtual void post(T_NODE* examinee) {}; // TODO: make this pure virt
39 virtual void reset() = 0;
40};
41
42template <bool constnode = false>
43class Walker {
44 public:
46 typedef typename T_EXAMINER::T_NODE T_NODE;
47
48 Walker(T_EXAMINER* examiner) : _examiner(examiner) {
50 };
51
53 void walk(T_NODE* examinee);
54
55 protected:
56 void internalWalk(T_NODE* examinee);
57 void walkChildren(T_NODE* parent);
58
59 private:
61};
62
65}
66#endif
virtual bool examine(T_NODE *examinee)=0
virtual void post(T_NODE *examinee)
Definition: ExprWalker.h:38
virtual void reset()=0
ADD_CONST< ExprNode, constnode >::TYPE T_NODE
Definition: ExprWalker.h:35
Examiner< constnode > T_EXAMINER
Definition: ExprWalker.h:45
void internalWalk(T_NODE *examinee)
Definition: ExprWalker.cpp:36
Walker(T_EXAMINER *examiner)
Definition: ExprWalker.h:48
void walkChildren(T_NODE *parent)
Definition: ExprWalker.cpp:43
void walk(T_NODE *examinee)
Preorder walk.
Definition: ExprWalker.cpp:30
T_EXAMINER * _examiner
Definition: ExprWalker.h:60
T_EXAMINER::T_NODE T_NODE
Definition: ExprWalker.h:46
Walker< true > ConstWalker
Definition: ExprWalker.h:64
Examiner< true > ConstExaminer
Definition: ExprWalker.h:63