interpolate

package
v0.0.0-...-328360e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2024 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Overview

Package interpolate contains the string interpolation parser and associated structs and code.

Index

Constants

View Source
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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL