| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- File List

AstWalker.h
1 /*
2 * Copyright (c) 2014, Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
10 #ifndef _EMBEDDED_RPC__ASTWALKER_H_
11 #define _EMBEDDED_RPC__ASTWALKER_H_
12
13 #include "AstNode.h"
14
16 // Classes
18
19 namespace erpcgen {
20
41 class AstWalker
42 {
43 public:
47 AstWalker() = default;
48
56 AstWalker(std::string inputFile)
57 : m_fileName(inputFile)
58 {
59 }
60
64 virtual ~AstWalker() = default;
65
74 virtual void startWalk(AstNode *node);
75
76 protected:
77 std::string m_fileName;
78 struct top_down
79 {
80 };
81 struct bottom_up
82 {
83 };
95 virtual void walk(AstNode *node);
96
111 template <typename D>
112 void dispatch(AstNode *node);
113
114 /*
115 * @name Top-down handlers
116 *
117 * @brief Top-down handlers types, which can be called.
118 */
120 virtual void handleRoot(AstNode *node, top_down) { (void)node; };
121 virtual AstNode *handleProgram(AstNode *node, top_down)
122 {
123 (void)node;
124 return nullptr;
125 }
126 virtual AstNode *handleConst(AstNode *node, top_down)
127 {
128 (void)node;
129 return nullptr;
130 }
131 virtual AstNode *handleChildren(AstNode *node, top_down)
132 {
133 (void)node;
134 return nullptr;
135 }
136 virtual AstNode *handleType(AstNode *node, top_down)
137 {
138 (void)node;
139 return nullptr;
140 }
141 virtual AstNode *handleEnum(AstNode *node, top_down)
142 {
143 (void)node;
144 return nullptr;
145 }
146 virtual AstNode *handleEnumMember(AstNode *node, top_down)
147 {
148 (void)node;
149 return nullptr;
150 }
151 virtual AstNode *handleStruct(AstNode *node, top_down)
152 {
153 (void)node;
154 return nullptr;
155 }
156 virtual AstNode *handleStructMember(AstNode *node, top_down)
157 {
158 (void)node;
159 return nullptr;
160 }
161 virtual AstNode *handleUnion(AstNode *node, top_down)
162 {
163 (void)node;
164 return nullptr;
165 }
166 virtual AstNode *handleUnionCase(AstNode *node, top_down)
167 {
168 (void)node;
169 return nullptr;
170 }
171 virtual AstNode *handleInterface(AstNode *node, top_down)
172 {
173 (void)node;
174 return nullptr;
175 }
176 virtual AstNode *handleFunction(AstNode *node, top_down)
177 {
178 (void)node;
179 return nullptr;
180 }
181 virtual AstNode *handleParam(AstNode *node, top_down)
182 {
183 (void)node;
184 return nullptr;
185 }
186 virtual AstNode *handleExpr(AstNode *node, top_down)
187 {
188 (void)node;
189 return nullptr;
190 }
191 virtual AstNode *handleBinaryOp(AstNode *node, top_down)
192 {
193 (void)node;
194 return nullptr;
195 }
196 virtual AstNode *handleUnaryOp(AstNode *node, top_down)
197 {
198 (void)node;
199 return nullptr;
200 }
201 virtual AstNode *handleAnnotation(AstNode *node, top_down)
202 {
203 (void)node;
204 return nullptr;
205 }
207
208 /*
209 * @name Bottom-up handlers
210 *
211 * @brief Bottom-up handlers types, which can be called.
212 */
214 virtual void handleRoot(AstNode *node, bottom_up) { (void)node; };
215 virtual AstNode *handleProgram(AstNode *node, bottom_up)
216 {
217 (void)node;
218 return nullptr;
219 }
220 virtual AstNode *handleConst(AstNode *node, bottom_up)
221 {
222 (void)node;
223 return nullptr;
224 }
225 virtual AstNode *handleChildren(AstNode *node, bottom_up)
226 {
227 (void)node;
228 return nullptr;
229 }
230 virtual AstNode *handleType(AstNode *node, bottom_up)
231 {
232 (void)node;
233 return nullptr;
234 }
235 virtual AstNode *handleEnum(AstNode *node, bottom_up)
236 {
237 (void)node;
238 return nullptr;
239 }
240 virtual AstNode *handleEnumMember(AstNode *node, bottom_up)
241 {
242 (void)node;
243 return nullptr;
244 }
245 virtual AstNode *handleStruct(AstNode *node, bottom_up)
246 {
247 (void)node;
248 return nullptr;
249 }
250 virtual AstNode *handleStructMember(AstNode *node, bottom_up)
251 {
252 (void)node;
253 return nullptr;
254 }
255 virtual AstNode *handleUnion(AstNode *node, bottom_up)
256 {
257 (void)node;
258 return nullptr;
259 }
260 virtual AstNode *handleUnionCase(AstNode *node, bottom_up)
261 {
262 (void)node;
263 return nullptr;
264 }
265 virtual AstNode *handleInterface(AstNode *node, bottom_up)
266 {
267 (void)node;
268 return nullptr;
269 }
270 virtual AstNode *handleFunction(AstNode *node, bottom_up)
271 {
272 (void)node;
273 return nullptr;
274 }
275 virtual AstNode *handleParam(AstNode *node, bottom_up)
276 {
277 (void)node;
278 return nullptr;
279 }
280 virtual AstNode *handleExpr(AstNode *node, bottom_up)
281 {
282 (void)node;
283 return nullptr;
284 }
285 virtual AstNode *handleBinaryOp(AstNode *node, bottom_up)
286 {
287 (void)node;
288 return nullptr;
289 }
290 virtual AstNode *handleUnaryOp(AstNode *node, bottom_up)
291 {
292 (void)node;
293 return nullptr;
294 }
295 virtual AstNode *handleAnnotation(AstNode *node, bottom_up)
296 {
297 (void)node;
298 return nullptr;
299 }
301 };
302
303 } // namespace erpcgen
304
305 #endif // _EMBEDDED_RPC__ASTWALKER_H_
erpcgen::AstWalker::m_fileName
std::string m_fileName
Stores name of file from which AST was built.
Definition: AstWalker.h:77
erpcgen::AstWalker::AstWalker
AstWalker()=default
default constructor
erpcgen::AstWalker::walk
virtual void walk(AstNode *node)
This function walk the AstNode depth-first and invoke handler methods.
Definition: AstWalker.cpp:30
erpcgen::AstWalker::~AstWalker
virtual ~AstWalker()=default
destructor
erpcgen::AstNode
Homogeneous AST node class.
Definition: AstNode.h:36
erpcgen::AstWalker
Performs a depth-first walk of an AST.
Definition: AstWalker.h:41
erpcgen::AstWalker::dispatch
void dispatch(AstNode *node)
This function invoke the appropriate handler method for the node&#39;s token type..
Definition: AstWalker.cpp:50
erpcgen::AstWalker::bottom_up
Specifier type to select bottom-up handler using ADL.
Definition: AstWalker.h:81
erpcgen::AstWalker::AstWalker
AstWalker(std::string inputFile)
Constructor.
Definition: AstWalker.h:56
erpcgen
Definition: AstNode.h:26
erpcgen::AstWalker::startWalk
virtual void startWalk(AstNode *node)
This function walk the AstNode depth-first and invoke handler methods.
Definition: AstWalker.cpp:21
erpcgen::AstWalker::top_down
Specifier type to select top-down handler using ADL.
Definition: AstWalker.h:78