syntax

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoSyntax = noSyntax(0)

Functions

func AsNumber

func AsNumber[T NumberValue](v T) json.Number

AsNumber converts the input value to a json.Number.

Types

type BooleanNode

type BooleanNode struct {
	// contains filtered or unexported fields
}

A BooleanNode represents a boolean literal.

func Boolean

func Boolean(value bool) *BooleanNode

Boolean creates a new boolean literal node with the given value.

func BooleanSyntax

func BooleanSyntax(syntax Syntax, value bool) *BooleanNode

BooleanSyntax creates a new boolean literal node with the given value and associated syntax.

func (*BooleanNode) String

func (n *BooleanNode) String() string

func (*BooleanNode) Syntax

func (n *BooleanNode) Syntax() Syntax

func (*BooleanNode) Value

func (n *BooleanNode) Value() bool

Value returns the boolean literal's value.

type Diagnostic

type Diagnostic struct {
	hcl.Diagnostic

	// Whether the diagnostic has been shown to the user
	Shown bool
}

A Diagnostic represents a warning or an error to be presented to the user.

func Error

func Error(rng *hcl.Range, summary, detail string) *Diagnostic

Error creates a new error-level diagnostic from the given subject, summary, and detail.

func NodeError

func NodeError(node Node, summary, detail string) *Diagnostic

NodeError creates a new error-level diagnostic from the given node, summary, and detail. If the node is non-nil, the diagnostic will be associated with the range of its associated syntax, if any.

func Warning

func Warning(rng *hcl.Range, summary, detail string) *Diagnostic

Warning creates a new warning-level diagnostic from the given subject, summary, and detail.

func (Diagnostic) HCL

func (d Diagnostic) HCL() *hcl.Diagnostic

func (Diagnostic) WithContext

func (d Diagnostic) WithContext(rng *hcl.Range) *Diagnostic

WithContext adds context without mutating the receiver.

type Diagnostics

type Diagnostics []*Diagnostic

Diagnostics is a list of diagnostics.

func (Diagnostics) Error

func (d Diagnostics) Error() string

Error implements the error interface so that Diagnostics values may interoperate with APIs that use errors.

func (*Diagnostics) Extend

func (d *Diagnostics) Extend(diags ...*Diagnostic)

Extend appends the given list of diagnostics to the list.

func (*Diagnostics) HCL

func (d *Diagnostics) HCL() hcl.Diagnostics

func (Diagnostics) HasErrors

func (d Diagnostics) HasErrors() bool

HasErrors returns true if the list of diagnostics contains any error-level diagnostics.

func (Diagnostics) Unshown

func (d Diagnostics) Unshown() *Diagnostics

type ListNode

type ListNode struct {
	// contains filtered or unexported fields
}

A ListNode represents a list of nodes.

func List

func List(elements ...Node) *ListNode

List creates a new list node with the given elements.

func ListSyntax

func ListSyntax(syntax Syntax, elements ...Node) *ListNode

ListSyntax creates a new list node with the given elements and associated syntax.

func (*ListNode) Index

func (n *ListNode) Index(i int) Node

Index returns the i'th element of the list.

func (*ListNode) Len

func (n *ListNode) Len() int

Len returns the number of elements in the list.

func (*ListNode) String

func (n *ListNode) String() string

func (*ListNode) Syntax

func (n *ListNode) Syntax() Syntax

type Node

type Node interface {
	fmt.Stringer

	Syntax() Syntax
	// contains filtered or unexported methods
}

A Node represents a single node in an object tree.

type NullNode

type NullNode struct {
	// contains filtered or unexported fields
}

A NullNode represents a null literal.

func Null

func Null() *NullNode

Null creates a new null literal node.

func NullSyntax

func NullSyntax(syntax Syntax) *NullNode

NullSyntax creates a new null literal node with associated syntax.

func (*NullNode) String

func (*NullNode) String() string

func (*NullNode) Syntax

func (n *NullNode) Syntax() Syntax

type NumberNode

type NumberNode struct {
	// contains filtered or unexported fields
}

A NumberNode represents a number literal.

func Number

func Number[T NumberValue](value T) *NumberNode

Number creates a new number literal node with the given value.

func NumberSyntax

func NumberSyntax[T NumberValue](syntax Syntax, value T) *NumberNode

NumberSyntax creates a new number literal node with the given value and associated syntax.

func (*NumberNode) String

func (n *NumberNode) String() string

func (*NumberNode) Syntax

func (n *NumberNode) Syntax() Syntax

func (*NumberNode) Value

func (n *NumberNode) Value() json.Number

Value returns the number literal's value.

type NumberValue

type NumberValue interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr | float32 | float64 | json.Number
}

NumberValue describes the set of types that can be represented as a number.

type ObjectNode

type ObjectNode struct {
	// contains filtered or unexported fields
}

An ObjectNode represents an object. An object is a list of key-value pairs where the keys are string literals and the values are arbitrary nodes.

func Object

func Object(entries ...ObjectPropertyDef) *ObjectNode

Object creates a new object node with the given properties.

func ObjectSyntax

func ObjectSyntax(syntax Syntax, entries ...ObjectPropertyDef) *ObjectNode

ObjectSyntax creates a new object node with the given properties and associated syntax.

func (*ObjectNode) Index

func (n *ObjectNode) Index(i int) ObjectPropertyDef

Index returns the i'th property of the object.

func (*ObjectNode) Len

func (n *ObjectNode) Len() int

Len returns the number of properties in the object.

func (*ObjectNode) String

func (n *ObjectNode) String() string

func (*ObjectNode) Syntax

func (n *ObjectNode) Syntax() Syntax

type ObjectPropertyDef

type ObjectPropertyDef struct {
	Syntax Syntax      // The syntax associated with the property, if any.
	Key    *StringNode // The name of the property.
	Value  Node        // The value of the property.
}

An ObjectPropertyDef represents a property definition in an object.

func ObjectProperty

func ObjectProperty(key *StringNode, value Node) ObjectPropertyDef

ObjectProperty creates a new object property definition with the given key and value.

func ObjectPropertySyntax

func ObjectPropertySyntax(syntax Syntax, key *StringNode, value Node) ObjectPropertyDef

ObjectPropertySyntax creates a new object property definition with the given key, value, and associated syntax.

type StringNode

type StringNode struct {
	// contains filtered or unexported fields
}

A StringNode represents a string literal.

func String

func String(value string) *StringNode

String creates a new string literal node with the given value.

func StringSyntax

func StringSyntax(syntax Syntax, value string) *StringNode

String creates a new string literal node with the given value and associated syntax.

func (*StringNode) String

func (n *StringNode) String() string

String returns the string literal's value.

func (*StringNode) Syntax

func (n *StringNode) Syntax() Syntax

func (*StringNode) Value

func (n *StringNode) Value() string

Value returns the string literal's value.

type Syntax

type Syntax interface {
	Range() *hcl.Range
}

type Trivia

type Trivia interface {
	Syntax

	HeadComment() string
	LineComment() string
	FootComment() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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