We don't have an API like that in the scanner/parser, for two reasons:
a) Chunking -- data comes to the scanner in chunks (e.g. for streaming), and we do very little rewinding when parsing, so we want to be able to discard chunks once they're no longer needed.
b) Escaping -- you can have unicode escapes in strings and even in identifiers, and those should be treated as the equivalent unicode character.
So, for things like strings and identifiers, we actually copy the source data into a local buffer while scanning, to be able to turn them into heap strings after. It looks like you want to have a substring representation of the source instead? Would it make sense for you to store the start and end positions, and use those to get a substring of the script's source string?