Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::IParser Class Reference

Integer-only variant of amrex::Parser. More...

#include <AMReX_IParser.H>

Public Member Functions

 IParser (std::string const &func_body)
 Construct a parser by immediately parsing func_body.
 
 IParser ()=default
 Default-construct; call define() before compile().
 
void define (std::string const &func_body)
 Parse and own a new integer expression, replacing any previous state.
 
 operator bool () const
 True when an expression has been parsed successfully.
 
void setConstant (std::string const &name, long long c)
 Bind a named integer constant.
 
void registerVariables (Vector< std::string > const &vars)
 Register the ordered list of integer variables referenced by the expression.
 
void print () const
 Print the parse tree to stdout for debugging.
 
int depth () const
 Return the maximum parse-tree depth.
 
int maxStackSize () const
 Return the maximum parser stack usage.
 
std::string expr () const
 Return the sanitized expression string.
 
std::set< std::string > symbols () const
 Return the set of symbols referenced by the expression.
 
template<int N>
IParserExecutor< N > compile () const
 Compile the expression into a host/device IParserExecutor.
 
template<int N>
IParserExecutor< N > compileHost () const
 Compile the expression into a host-only executor.
 

Detailed Description

Integer-only variant of amrex::Parser.

IParser parses expressions composed of integer literals, integer variables, and integer-returning functions. It emits executors that evaluate to long long on host or GPU.

Constructor & Destructor Documentation

◆ IParser() [1/2]

amrex::IParser::IParser ( std::string const &  func_body)

Construct a parser by immediately parsing func_body.

Parameters
func_bodyExpression to parse (empty to defer define()).

◆ IParser() [2/2]

amrex::IParser::IParser ( )
default

Default-construct; call define() before compile().

Member Function Documentation

◆ compile()

template<int N>
IParserExecutor< N > amrex::IParser::compile ( ) const

Compile the expression into a host/device IParserExecutor.

Template Parameters
NNumber of registered variables.

◆ compileHost()

template<int N>
IParserExecutor< N > amrex::IParser::compileHost ( ) const

Compile the expression into a host-only executor.

Template Parameters
NNumber of registered variables.

◆ define()

void amrex::IParser::define ( std::string const &  func_body)

Parse and own a new integer expression, replacing any previous state.

Parameters
func_bodyExpression text.

◆ depth()

int amrex::IParser::depth ( ) const

Return the maximum parse-tree depth.

Returns
Depth measured in tree levels (0 if undefined).

◆ expr()

std::string amrex::IParser::expr ( ) const

Return the sanitized expression string.

Returns
Copy of the parsed expression or an empty string if undefined.

◆ maxStackSize()

int amrex::IParser::maxStackSize ( ) const

Return the maximum parser stack usage.

Returns
Stack size required during execution (0 if undefined).

◆ operator bool()

amrex::IParser::operator bool ( ) const
explicit

True when an expression has been parsed successfully.

◆ print()

void amrex::IParser::print ( ) const

Print the parse tree to stdout for debugging.

◆ registerVariables()

void amrex::IParser::registerVariables ( Vector< std::string > const &  vars)

Register the ordered list of integer variables referenced by the expression.

Parameters
varsVariable names supplied in parser argument order.

◆ setConstant()

void amrex::IParser::setConstant ( std::string const &  name,
long long  c 
)

Bind a named integer constant.

Parameters
nameIdentifier referenced inside the expression.
cConstant value substituted during compilation.

◆ symbols()

std::set< std::string > amrex::IParser::symbols ( ) const

Return the set of symbols referenced by the expression.

Returns
Sorted symbol names.

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