Add TextTape::from(Vec<TextToken>, bool) for Tape construction after token manipulation. - #181
Open
KitsuneDev wants to merge 1 commit into
Open
Add TextTape::from(Vec<TextToken>, bool) for Tape construction after token manipulation.#181KitsuneDev wants to merge 1 commit into
TextTape::from(Vec<TextToken>, bool) for Tape construction after token manipulation.#181KitsuneDev wants to merge 1 commit into
Conversation
Contributor
|
Looks good, let me think about if it makes sense to supply the bom marker in the constructor, as that should only surface from initial parsing 🤔 |
Contributor
|
A thought ocurred to me, is your use case covered by something like: // pseudo-code
impl TextTape {
pub fn tokens_mut(&mut self) -> &mut Vec<TextToken>
...
}
}A benefit is that you don't need to clone the tokens (that's how I'm assuming you are able to pass in a If that does work, it would be nice to include a rustdoc example and give the caveat that any modification needs to respect expected invariants or could otherwise risk object / array index corruption. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, there is no way to reconstruct a Tape after performing raw token manipulation.
A use case (which is what I have in a project I'm working on) is parsing scripted_variables files and replacing their reference tokens on, say, technologies with their actual values.