KSeExpr 6.0.0.0
ExprWalker.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2011-2019 Disney Enterprises, Inc.
2// SPDX-License-Identifier: LicenseRef-Apache-2.0
3// SPDX-FileCopyrightText: 2020 L. E. Segovia <amy@amyspark.me>
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6#pragma once
7
8#include <type_traits>
9
10#include "ExprNode.h"
11
12namespace KSeExpr {
13template<class T, bool constnode> struct conditional_const {
14 using type = typename std::conditional<constnode, typename std::add_const<T>::type, T>::type;
15};
16
17template <bool constnode = false>
18class Examiner {
19 public:
21
22 virtual bool examine(T_NODE *examinee) = 0;
23 virtual void post(T_NODE *examinee) = 0;
24 virtual void reset() = 0;
25};
26
27template <bool constnode = false>
28class Walker {
29 public:
31 using T_NODE = typename T_EXAMINER::T_NODE;
32
36
38 void walk(T_NODE* examinee);
39
40 protected:
42 void walkChildren(T_NODE* parent);
43
44 private:
46};
47
50} // namespace KSeExpr
virtual void post(T_NODE *examinee)=0
virtual void reset()=0
typename conditional_const< ExprNode, constnode >::type T_NODE
Definition ExprWalker.h:20
virtual bool examine(T_NODE *examinee)=0
typename T_EXAMINER::T_NODE T_NODE
Definition ExprWalker.h:31
Walker(T_EXAMINER *examiner)
Definition ExprWalker.h:33
void walk(T_NODE *examinee)
Preorder walk.
void internalWalk(T_NODE *examinee)
void walkChildren(T_NODE *parent)
T_EXAMINER * _examiner
Definition ExprWalker.h:45
typename std::conditional< constnode, typename std::add_const< T >::type, T >::type type
Definition ExprWalker.h:14