Yume
Public Member Functions | List of all members
yume::CRTPWalker< Derived > Struct Template Reference

A helper template to walk the Abstract Syntax Tree (AST), utilizing the Curiously Recurring Template Pattern (CRTP). More...

#include <crtp_walker.hpp>

Inheritance diagram for yume::CRTPWalker< Derived >:
Inheritance graph
[legend]

Public Member Functions

auto body_statement (ast::Stmt &stat, auto &&... args)
 
auto body_expression (ast::Expr &expr, auto &&... args)
 

Detailed Description

template<typename Derived>
struct yume::CRTPWalker< Derived >

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.

Member Function Documentation

◆ body_expression()

template<typename Derived >
auto yume::CRTPWalker< Derived >::body_expression ( ast::Expr expr,
auto &&...  args 
)
inline

◆ body_statement()

template<typename Derived >
auto yume::CRTPWalker< Derived >::body_statement ( ast::Stmt stat,
auto &&...  args 
)
inline

The documentation for this struct was generated from the following file: