cue/ast: add Interpolation.Quotes helper
Three call sites (two in cue/format, one in internal/core/compile)
independently extracted the opening and closing BasicLit fragments of an
Interpolation to feed them to literal.ParseQuotes. Fold that pattern
into a method on *ast.Interpolation.
The method panics on invariant violations — an empty Elts slice or a
non-BasicLit boundary — rather than returning an ok flag, since a valid
Interpolation must always satisfy that contract. A single-element
Interpolation returns the same BasicLit for both first and last, which
keeps the method usable for forthcoming tagged interpolations.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I0e4b9ba19e62377049f807d1e75825902fe46d3d
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1236161
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>