eRPC Generator (erpcgen)  Rev. 1.12.0
NXP Semiconductors
erpcgen::AstWalker Class Reference

Performs a depth-first walk of an AST. More...

#include <AstWalker.hpp>

Inheritance diagram for erpcgen::AstWalker:
erpcgen::SymbolScanner

Classes

struct  bottom_up
 Specifier type to select bottom-up handler using ADL. More...
 
struct  top_down
 Specifier type to select top-down handler using ADL. More...
 

Public Member Functions

 AstWalker ()=default
 default constructor
 
 AstWalker (const std::string &inputFile)
 Constructor. More...
 
virtual ~AstWalker ()=default
 destructor
 
virtual void startWalk (AstNode *node)
 This function walk the AstNode depth-first and invoke handler methods. More...
 

Protected Member Functions

virtual void walk (AstNode *node)
 This function walk the AstNode depth-first and invoke handler methods. More...
 
template<typename D >
void dispatch (AstNode *node)
 This function invoke the appropriate handler method for the node's token type.. More...
 
virtual void handleRoot (AstNode *node, top_down)
 
virtual AstNodehandleProgram (AstNode *node, top_down)
 
virtual AstNodehandleConst (AstNode *node, top_down)
 
virtual AstNodehandleChildren (AstNode *node, top_down)
 
virtual AstNodehandleType (AstNode *node, top_down)
 
virtual AstNodehandleEnum (AstNode *node, top_down)
 
virtual AstNodehandleEnumMember (AstNode *node, top_down)
 
virtual AstNodehandleStruct (AstNode *node, top_down)
 
virtual AstNodehandleStructMember (AstNode *node, top_down)
 
virtual AstNodehandleUnion (AstNode *node, top_down)
 
virtual AstNodehandleUnionCase (AstNode *node, top_down)
 
virtual AstNodehandleInterface (AstNode *node, top_down)
 
virtual AstNodehandleFunction (AstNode *node, top_down)
 
virtual AstNodehandleParam (AstNode *node, top_down)
 
virtual AstNodehandleExpr (AstNode *node, top_down)
 
virtual AstNodehandleBinaryOp (AstNode *node, top_down)
 
virtual AstNodehandleUnaryOp (AstNode *node, top_down)
 
virtual AstNodehandleAnnotation (AstNode *node, top_down)
 
virtual void handleRoot (AstNode *node, bottom_up)
 
virtual AstNodehandleProgram (AstNode *node, bottom_up)
 
virtual AstNodehandleConst (AstNode *node, bottom_up)
 
virtual AstNodehandleChildren (AstNode *node, bottom_up)
 
virtual AstNodehandleType (AstNode *node, bottom_up)
 
virtual AstNodehandleEnum (AstNode *node, bottom_up)
 
virtual AstNodehandleEnumMember (AstNode *node, bottom_up)
 
virtual AstNodehandleStruct (AstNode *node, bottom_up)
 
virtual AstNodehandleStructMember (AstNode *node, bottom_up)
 
virtual AstNodehandleUnion (AstNode *node, bottom_up)
 
virtual AstNodehandleUnionCase (AstNode *node, bottom_up)
 
virtual AstNodehandleInterface (AstNode *node, bottom_up)
 
virtual AstNodehandleFunction (AstNode *node, bottom_up)
 
virtual AstNodehandleParam (AstNode *node, bottom_up)
 
virtual AstNodehandleExpr (AstNode *node, bottom_up)
 
virtual AstNodehandleBinaryOp (AstNode *node, bottom_up)
 
virtual AstNodehandleUnaryOp (AstNode *node, bottom_up)
 
virtual AstNodehandleAnnotation (AstNode *node, bottom_up)
 

Protected Attributes

std::string m_fileName
 Stores name of file from which AST was built.
 

Detailed Description

Performs a depth-first walk of an AST.

Handles these token types:

  • TOK_PROGRAM
  • TOK_CONST
  • TOK_ENUM
  • TOK_STRUCT
  • TOK_TYPE
  • TOK_INTERFACE
  • TOK_CHILDREN
  • TOK_ENUM_MEMBER
  • TOK_STRUCT_MEMBER
  • TOK_FUNCTION
  • TOK_PARAM
  • TOK_EXPR
  • TOK_ANNOTATION
  • TOK_LIST
  • TOK_ARRAY

Class Documentation

struct erpcgen::AstWalker::bottom_up

Specifier type to select bottom-up handler using ADL.

struct erpcgen::AstWalker::top_down

Specifier type to select top-down handler using ADL.

Constructor & Destructor Documentation

erpcgen::AstWalker::AstWalker ( const std::string &  inputFile)
inlineexplicit

Constructor.

This function initializes object attributes.

Parameters
[in]inputFileParsed file name.

Member Function Documentation

template<typename D >
void AstWalker::dispatch ( AstNode node)
protected

This function invoke the appropriate handler method for the node's token type..

This function call handle functions for AstNode, which is specified with node token. The template argument D specifies whether the top-down or bottom-up handler should be called, by passing either of the top_down or bottom_up typenames.

Parameters
[in]nodeNode to handle.
Exceptions
internal_errorThrown if handle function return new node, which want replace given node, but given node is root.
See also
void AstWalker::walk(AstNode * node)
void AstWalker::startWalk ( AstNode node)
virtual

This function walk the AstNode depth-first and invoke handler methods.

Parameters
[in]nodeThe root node of the tree to walk.
See also
void AstWalker::dispatch(AstNode * node)
void AstWalker::walk(AstNode * node)
void AstWalker::walk ( AstNode node)
protectedvirtual

This function walk the AstNode depth-first and invoke handler methods.

This function call for dispatch given node before and after calling walk function for node children.

Parameters
[in]nodeThe root node of the tree to walk.
See also
void AstWalker::dispatch(AstNode * node)

The documentation for this class was generated from the following files: