hclwrite: Allow constructing expressions from raw tokens #320
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We currently have functions for constructing new expressions from either constant values or from traversals, but some surgical updates require producing a more complex expression.
In the long run perhaps we'll have some mechanism for constructing valid expressions via a high-level AST-like API, similar to what we already have for structural constructs, but as a simpler first step here we add a mechanism to just write raw tokens directly into an expression, with the caller being responsible for making sure those tokens represent valid HCL expression syntax.
Since this new API treats the given tokens as unstructured, the resulting expression can't fully support the whole of the expression API, but it's good enough for writing in complex expressions without disturbing existing content elsewhere in the input file.