package interpolate
import "github.com/purpleidea/mgmt/lang/interpolate"
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 )
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.
type Token ¶
type Token interface {
// contains filtered or unexported methods
}
Token is the interface that every token must implement.
type Variable ¶
type Variable struct { Name string }
Variable is a variable name that we have found after interpolation parsing.
Source Files ¶
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 4 days ago –
Tools for package owners.