![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Reaction expression compiler + Tier-1 evaluator (phase R2). More...
Go to the source code of this file.
Classes | |
| struct | openswmm::transport::RxSymbols |
| struct | openswmm::transport::RxEvalEnv |
| Evaluation environment: pre-gathered pointers, no lookups. More... | |
| struct | openswmm::transport::RxToken |
| struct | openswmm::transport::RxExprSpan |
| Compiled expression = span into the shared pool. len 0 ⇒ no expression. More... | |
Namespaces | |
| namespace | openswmm |
| namespace | openswmm::transport |
Enumerations | |
| enum class | openswmm::transport::RxHydVar |
Functions | |
| std::string | openswmm::transport::compileReactionExpression (const std::string &src, const RxSymbols &symbols, std::vector< RxToken > &pool, RxExprSpan &out, int &error_col) |
Compile src into the shared pool. | |
| int | openswmm::transport::reactionFunctionCount () |
| Number of built-in functions. | |
| bool | openswmm::transport::reactionFunctionInfo (int idx, const char **name, int *arity) |
Name + arity of function idx; false when out of range. | |
| int | openswmm::transport::reactionHydVarCount () |
| Number of built-in hydraulic variables. | |
| bool | openswmm::transport::reactionHydVarInfo (int idx, const char **name, const char **description) |
Name + one-line description of hydraulic variable idx. | |
| double | openswmm::transport::evalReactionExpression (const std::vector< RxToken > &pool, const RxExprSpan &span, const RxEvalEnv &env) noexcept |
| Tier-1 evaluation: one pass, fixed-depth stack, allocation-free. | |
Variables | |
| constexpr int | openswmm::transport::kRxMaxStackDepth |
Reaction expression compiler + Tier-1 evaluator (phase R2).
Shunting-yard compiler from the MSX-convention DSL to a FLAT token pool (LARD plan §16 D-L3 / reactions plan D-R2 Tier 1): all compiled expressions share one contiguous std::vector<RxToken>; each expression is a (begin, len) span. Operands carry PRE-RESOLVED indices (species slot, coefficient slot, term slot, hydraulic-variable code) so evaluation is a single allocation-free pass over the span with a fixed-depth value stack — no name lookups, no std::string, no heap.
Same shunting-yard family as quality/Treatment.cpp (D-R1: one compiler approach, two front doors); actual TU-level consolidation of the two VMs is the PROCESS_MODULARIZATION §10 decision and deliberately NOT forced here.
Grammar: numbers; identifiers (species | coefficient | term | hydraulic variable, resolved in that order); + - * / ^ with standard precedence, right-assoc ^; unary minus; parentheses; functions EXP LOG LOG10 SQRT ABS SGN STEP SIN COS TAN (unary), MIN MAX POW (binary, comma-separated). Term references are FORWARD-ONLY (a term may reference only earlier terms), so term evaluation is a simple in-order sweep with no cycle machinery.