Closed theoilie closed 3 months ago
Hi @theoilie, you may want to look at using the cel/inclining.go
approach for combining expressions. It should do what you want, at least for generating new ASTs
-Tristan
Hi @theoilie, you may want to look at using the
cel/inclining.go
approach for combining expressions. It should do what you want, at least for generating new ASTs-Tristan
This looks perfect -- thank you very much!
Feature request checklist
Change I'm wondering about a sort of AST replacement for sub-expressions. If my expression contains a variable which is a placeholder for another expression, then I replace it with the string before compiling. However, the variable in question would've already been compiled previously, so I already have its AST. I'm wondering if it's possible to use this AST instead of having to do manual string replacement.
Example Let's say expressions
a
andb
evaluate to doubles:Now for expression
a + b
could it be possible to use the already-compiled ASTs fora
andb
?Alternatives considered The alternative I'm doing works, but it involves having to re-compile an expression which was already previously compiled. Specifically, the alternative is: before compiling, recursively find all variable names and replace them with their string expressions so that the whole expression string gets compiled without any variables.