Documentation ¶
Overview ¶
Package interpolate contains the string interpolation parser and associated structs and code.
Index ¶
- Constants
- func HilInterpolate(str string, pos *interfaces.Pos, data *interfaces.Data) (interfaces.Expr, error)
- func RagelInterpolate(str string, pos *interfaces.Pos, data *interfaces.Data) (interfaces.Expr, error)
- func StrInterpolate(str string, pos *interfaces.Pos, data *interfaces.Data) (interfaces.Expr, error)
- type Literal
- type Stream
- type Token
- type Variable
Constants ¶
const ( // UseHilInterpolation specifies that we use the legacy Hil interpolate. // This can't properly escape a $ in the standard way. It's here in case // someone wants to play with it and examine how the AST stuff worked... UseHilInterpolation = false // UseOptimizedConcat uses a simpler to unify concat operator instead of // the normal + operator which uses fancy polymorphic type unification. UseOptimizedConcat = true )
Variables ¶
This section is empty.
Functions ¶
func HilInterpolate ¶
func HilInterpolate(str string, pos *interfaces.Pos, data *interfaces.Data) (interfaces.Expr, error)
HilInterpolate interpolates a string and returns the representative AST. This particular implementation uses the hashicorp hil library and syntax to do so.
func RagelInterpolate ¶
func RagelInterpolate(str string, pos *interfaces.Pos, data *interfaces.Data) (interfaces.Expr, error)
RagelInterpolate interpolates a string and returns the representative AST. It uses the ragel parser to perform the string interpolation.
func StrInterpolate ¶
func StrInterpolate(str string, pos *interfaces.Pos, data *interfaces.Data) (interfaces.Expr, error)
StrInterpolate interpolates a string and returns the representative AST.
Types ¶
type Literal ¶
type Literal struct {
Value string
}
Literal is a string literal that we have found after interpolation parsing.
type Stream ¶
type Stream []Token
Stream is the list of tokens that are produced after interpolating a string. It is created by using the generated Parse function. TODO: In theory a more advanced parser could produce an AST here instead.