|
Yume
|
A helper template to walk the Abstract Syntax Tree (AST), utilizing the Curiously Recurring Template Pattern (CRTP). More...
#include <crtp_walker.hpp>

Public Member Functions | |
| auto | body_statement (ast::Stmt &stat, auto &&... args) |
| auto | body_expression (ast::Expr &expr, auto &&... args) |
A helper template to walk the Abstract Syntax Tree (AST), utilizing the Curiously Recurring Template Pattern (CRTP).
A class inheriting from CRTPWalker must declare the methods body_expression and body_statement, which take the base classes Expr and Stmt respectively. Those methods should delegate to the same methods defined in the CRTPWalker. Then, the class must define any number of template methods named expression and statement, which take a subclass of Expr and Stmt respectively. The way this is done in Compiler and TypeWalker is to define a template base in the header, with a fallback implementation (which should usually throw) for any cases that are unhandled. Then, for each AST node subclass that the deriving class knows how to handle, define a template specialization taking that specific subclass in the implementation file.
Definition at line 23 of file crtp_walker.hpp.
|
inline |
Definition at line 42 of file crtp_walker.hpp.
References yume::ast::K_Assign, yume::ast::K_BinaryLogic, yume::ast::K_Bool, yume::ast::K_Call, yume::ast::K_Char, yume::ast::K_Const, yume::ast::K_Ctor, yume::ast::K_FieldAccess, yume::ast::K_ImplicitCast, yume::ast::K_Lambda, yume::ast::K_Number, yume::ast::K_Slice, yume::ast::K_String, yume::ast::K_TypeExpr, yume::ast::K_Var, and yume::ast::AST::kind().
Referenced by yume::semantic::TypeWalker::body_expression(), and yume::Compiler::body_expression().
|
inline |
Definition at line 26 of file crtp_walker.hpp.
References yume::ast::K_Compound, yume::ast::K_ConstDecl, yume::ast::K_CtorDecl, yume::ast::K_FnDecl, yume::ast::K_If, yume::ast::K_Return, yume::ast::K_StructDecl, yume::ast::K_VarDecl, yume::ast::K_While, and yume::ast::AST::kind().
Referenced by yume::Compiler::body_statement(), and yume::semantic::TypeWalker::body_statement().