ReplMaker.jl
ReplMaker.jl copied to clipboard
raw string interpolation/unescaping?
Sorry for the spam.
It looks like REPL modes give raw strings to the input function. I'm making a ChatGPT REPL mode https://github.com/anandijain/OpenAIReplMode.jl and I think it would be really nice to be able to say
julia> x = "world"
chatgpt> hello $x
and have the string somehow get reinterpolated/unescaped?
Any recommendations for this?
This problem is equivalent to string-interpolation. So far, I'm only aware of being able to do it using Meta.parse (which would not work in this case) or writing your own parser. You'd return an expression like this:
julia> Meta.@dump "interpolate $x and $(y + 1)"
Expr
head: Symbol string
args: Array{Any}((4,))
1: String "interpolate "
2: Symbol x
3: String " and "
4: Expr
head: Symbol call
args: Array{Any}((3,))
1: Symbol +
2: Symbol y
3: Int64 1