syn icon indicating copy to clipboard operation
syn copied to clipboard

Ability to map subspans of a `LitStr` into subspans of the backing `Literal`

Open Nemo157 opened this issue 1 year ago • 0 comments

In order to create accurate subspans into a LitStr there needs to be some way to map offsets from the string value into offsets of the Literal. As an example for the literal r#"\x7Ba}" the string value is {a}, the a character has the range 1..2 which has to be mapped to 7..8, or the { character has the range 0..1 which has to be mapped to 3..7.

#621 is tangentially related, but that only applies if the literal is parsed through syn::Parse. If instead the string value is being parsed via another parser that is able to give back subranges those need to be manually mapped somehow.

Nemo157 avatar Sep 20 '22 16:09 Nemo157