Integer-only variant of amrex::Parser.
More...
#include <AMReX_IParser.H>
|
| | 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.
|
| |
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.
Different IParser objects may be constructed or defined concurrently from multiple host threads. For parallel evaluation, prefer sharing the compiled IParserExecutor across threads instead of constructing one IParser per thread.
◆ IParser() [1/2]
| amrex::IParser::IParser |
( |
std::string const & |
func_body | ) |
|
Construct a parser by immediately parsing func_body.
- Parameters
-
| func_body | Expression to parse (empty to defer define()). |
◆ IParser() [2/2]
| amrex::IParser::IParser |
( |
| ) |
|
|
default |
◆ compile()
Compile the expression into a host/device IParserExecutor.
- Template Parameters
-
| N | Number of registered variables. |
◆ compileHost()
Compile the expression into a host-only executor.
- Template Parameters
-
| N | Number 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_body | Expression 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
-
| vars | Variable names supplied in parser argument order. |
◆ setConstant()
| void amrex::IParser::setConstant |
( |
std::string const & |
name, |
|
|
long long |
c |
|
) |
| |
Bind a named integer constant.
- Parameters
-
| name | Identifier referenced inside the expression. |
| c | Constant 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: