expression

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binary

type Binary struct {
	LHS      ast.Expression
	RHS      ast.Expression
	Token    token.Token
	TokenPos core.Pos
}

Binary represents a binary operator expression.

func (*Binary) End

func (e *Binary) End() core.Pos

func (*Binary) IsCallExpression

func (e *Binary) IsCallExpression() bool

func (*Binary) IsCompositeLiteral

func (e *Binary) IsCompositeLiteral() bool

func (*Binary) IsScalarLiteral

func (e *Binary) IsScalarLiteral() bool

func (*Binary) IsUndefinedLiteral

func (e *Binary) IsUndefinedLiteral() bool

func (*Binary) LiteralToValue

func (e *Binary) LiteralToValue() (core.Value, bool)

func (*Binary) Pos

func (e *Binary) Pos() core.Pos

func (*Binary) String

func (e *Binary) String() string

type Call

type Call struct {
	Func     ast.Expression
	LParen   core.Pos
	Args     []ast.Expression
	Ellipsis core.Pos
	RParen   core.Pos
}

Call represents a function call expression.

func (*Call) End

func (e *Call) End() core.Pos

func (*Call) IsCallExpression

func (e *Call) IsCallExpression() bool

func (*Call) IsCompositeLiteral

func (e *Call) IsCompositeLiteral() bool

func (*Call) IsScalarLiteral

func (e *Call) IsScalarLiteral() bool

func (*Call) IsUndefinedLiteral

func (e *Call) IsUndefinedLiteral() bool

func (*Call) LiteralToValue

func (e *Call) LiteralToValue() (core.Value, bool)

func (*Call) Pos

func (e *Call) Pos() core.Pos

func (*Call) String

func (e *Call) String() string

type FString

type FString struct {
	Parts    []FStringPart
	ValuePos core.Pos
	EndPos   core.Pos
	Literal  string // original source text, including surrounding quotes
}

FString represents f-string literal: f"text {expr:fspec} ...". All format specs and literal text segments are resolved at parse time so the runtime cost of an f-string is the cost of its expression evaluations plus per-interpolation Format calls and string concatenation.

func (*FString) End

func (e *FString) End() core.Pos

func (*FString) IsCallExpression

func (e *FString) IsCallExpression() bool

func (*FString) IsCompositeLiteral

func (e *FString) IsCompositeLiteral() bool

func (*FString) IsScalarLiteral

func (e *FString) IsScalarLiteral() bool

func (*FString) IsUndefinedLiteral

func (e *FString) IsUndefinedLiteral() bool

func (*FString) LiteralToValue

func (e *FString) LiteralToValue() (core.Value, bool)

func (*FString) Pos

func (e *FString) Pos() core.Pos

func (*FString) String

func (e *FString) String() string

type FStringPart

type FStringPart struct {
	// Literal text segment. Used when Expr == nil. Already unescaped from the f-string body (with `{{` / `}}` collapsed
	// to single braces and the usual `\n`, `\"`, ... escapes processed).
	Literal string

	// Interpolated expression (parsed Kavun expression). Nil for literal segments.
	Expr ast.Expression

	// Pre-parsed format spec for the interpolation. Always valid for static interpolation parts; for literal parts and
	// dynamic-spec interpolation parts it is the zero FormatSpec.
	Spec fspec.FormatSpec

	// Original spec text (the substring after the `:` inside `{...}`), without leading colon. Empty when no `:` was
	// present or when the fspec was empty. For dynamic specs this is the raw template (including `{...}` placeholders);
	// it is only used for de-duplication and disassembly.
	SpecText string

	// Dynamic format-spec template. Set only when the spec contains nested `{expr}` placeholders. The runtime spec
	// string is built by interleaving SpecLiterals[i] with str(SpecExprs[i]) and ending with
	// SpecLiterals[len(SpecExprs)]. When SpecExprs is non-empty, Spec is unused and the spec is parsed at run time.
	SpecLiterals []string
	SpecExprs    []ast.Expression
}

FStringPart is a single segment of an f-string. Exactly one of Literal or Expr is set: when Expr == nil the part is a verbatim literal text; when Expr != nil the part is an interpolation that must be Format()-ed with the pre-parsed Spec at run time.

type Function

type Function struct {
	Type *FunctionType
	Body *statement.Block
}

Function represents a function literal.

func (*Function) End

func (e *Function) End() core.Pos

func (*Function) IsCallExpression

func (e *Function) IsCallExpression() bool

func (*Function) IsCompositeLiteral

func (e *Function) IsCompositeLiteral() bool

func (*Function) IsScalarLiteral

func (e *Function) IsScalarLiteral() bool

func (*Function) IsUndefinedLiteral

func (e *Function) IsUndefinedLiteral() bool

func (*Function) LiteralToValue

func (e *Function) LiteralToValue() (core.Value, bool)

func (*Function) Pos

func (e *Function) Pos() core.Pos

func (*Function) String

func (e *Function) String() string

type FunctionType

type FunctionType struct {
	FuncPos core.Pos
	Params  *Identifiers

	// Result is the optional named return identifier:
	//   func(a, b) name { ... }
	// When non-nil, `name` is allocated as a local pre-initialized to undefined; bare `return` and exit-after-recover
	// return its current value.
	Result *Identifier
}

FunctionType represents a function type definition.

func (*FunctionType) End

func (e *FunctionType) End() core.Pos

func (*FunctionType) IsCallExpression

func (e *FunctionType) IsCallExpression() bool

func (*FunctionType) IsCompositeLiteral

func (e *FunctionType) IsCompositeLiteral() bool

func (*FunctionType) IsScalarLiteral

func (e *FunctionType) IsScalarLiteral() bool

func (*FunctionType) IsUndefinedLiteral

func (e *FunctionType) IsUndefinedLiteral() bool

func (*FunctionType) LiteralToValue

func (e *FunctionType) LiteralToValue() (core.Value, bool)

func (*FunctionType) Pos

func (e *FunctionType) Pos() core.Pos

func (*FunctionType) String

func (e *FunctionType) String() string

type Identifier

type Identifier struct {
	Name    string
	NamePos core.Pos
}

Identifier represents an identifier.

func (*Identifier) End

func (e *Identifier) End() core.Pos

func (*Identifier) IdentifierNode

func (e *Identifier) IdentifierNode()

func (*Identifier) IsCallExpression

func (e *Identifier) IsCallExpression() bool

func (*Identifier) IsCompositeLiteral

func (e *Identifier) IsCompositeLiteral() bool

func (*Identifier) IsScalarLiteral

func (e *Identifier) IsScalarLiteral() bool

func (*Identifier) IsUndefinedLiteral

func (e *Identifier) IsUndefinedLiteral() bool

func (*Identifier) LiteralToValue

func (e *Identifier) LiteralToValue() (core.Value, bool)

func (*Identifier) Pos

func (e *Identifier) Pos() core.Pos

func (*Identifier) String

func (e *Identifier) String() string

type Identifiers

type Identifiers struct {
	LParen  core.Pos
	VarArgs bool
	List    []*Identifier
	RParen  core.Pos
}

Identifiers represents a list of identifiers.

func (*Identifiers) End

func (e *Identifiers) End() core.Pos

func (*Identifiers) IsCallExpression

func (e *Identifiers) IsCallExpression() bool

func (*Identifiers) IsCompositeLiteral

func (e *Identifiers) IsCompositeLiteral() bool

func (*Identifiers) IsScalarLiteral

func (e *Identifiers) IsScalarLiteral() bool

func (*Identifiers) IsUndefinedLiteral

func (e *Identifiers) IsUndefinedLiteral() bool

func (*Identifiers) LiteralToValue

func (e *Identifiers) LiteralToValue() (core.Value, bool)

func (*Identifiers) NumFields

func (e *Identifiers) NumFields() int

func (*Identifiers) Pos

func (e *Identifiers) Pos() core.Pos

func (*Identifiers) String

func (e *Identifiers) String() string

type Immutable

type Immutable struct {
	Expr   ast.Expression
	IPos   core.Pos
	LParen core.Pos
	RParen core.Pos
}

Immutable represents an immutable expression

func (*Immutable) End

func (e *Immutable) End() core.Pos

func (*Immutable) IsCallExpression

func (e *Immutable) IsCallExpression() bool

func (*Immutable) IsCompositeLiteral

func (e *Immutable) IsCompositeLiteral() bool

func (*Immutable) IsScalarLiteral

func (e *Immutable) IsScalarLiteral() bool

func (*Immutable) IsUndefinedLiteral

func (e *Immutable) IsUndefinedLiteral() bool

func (*Immutable) LiteralToValue

func (e *Immutable) LiteralToValue() (core.Value, bool)

func (*Immutable) Pos

func (e *Immutable) Pos() core.Pos

func (*Immutable) String

func (e *Immutable) String() string

type Import

type Import struct {
	ModuleName string
	Token      token.Token
	TokenPos   core.Pos
}

Import represents an import expression

func (*Import) End

func (e *Import) End() core.Pos

func (*Import) IsCallExpression

func (e *Import) IsCallExpression() bool

func (*Import) IsCompositeLiteral

func (e *Import) IsCompositeLiteral() bool

func (*Import) IsScalarLiteral

func (e *Import) IsScalarLiteral() bool

func (*Import) IsUndefinedLiteral

func (e *Import) IsUndefinedLiteral() bool

func (*Import) LiteralToValue

func (e *Import) LiteralToValue() (core.Value, bool)

func (*Import) Pos

func (e *Import) Pos() core.Pos

func (*Import) String

func (e *Import) String() string

type Index

type Index struct {
	Expr   ast.Expression
	LBrack core.Pos
	Index  ast.Expression
	RBrack core.Pos
}

Index represents an index expression.

func (*Index) End

func (e *Index) End() core.Pos

func (*Index) IsCallExpression

func (e *Index) IsCallExpression() bool

func (*Index) IsCompositeLiteral

func (e *Index) IsCompositeLiteral() bool

func (*Index) IsScalarLiteral

func (e *Index) IsScalarLiteral() bool

func (*Index) IsUndefinedLiteral

func (e *Index) IsUndefinedLiteral() bool

func (*Index) LiteralToValue

func (e *Index) LiteralToValue() (core.Value, bool)

func (*Index) Pos

func (e *Index) Pos() core.Pos

func (*Index) String

func (e *Index) String() string

type Invalid

type Invalid struct {
	From core.Pos
	To   core.Pos
}

Invalid represents invalid expression.

func (*Invalid) End

func (e *Invalid) End() core.Pos

func (*Invalid) IsCallExpression

func (e *Invalid) IsCallExpression() bool

func (*Invalid) IsCompositeLiteral

func (e *Invalid) IsCompositeLiteral() bool

func (*Invalid) IsScalarLiteral

func (e *Invalid) IsScalarLiteral() bool

func (*Invalid) IsUndefinedLiteral

func (e *Invalid) IsUndefinedLiteral() bool

func (*Invalid) LiteralToValue

func (e *Invalid) LiteralToValue() (core.Value, bool)

func (*Invalid) Pos

func (e *Invalid) Pos() core.Pos

func (*Invalid) String

func (e *Invalid) String() string

type MethodCall

type MethodCall struct {
	Object     ast.Expression
	MethodName string
	MethodPos  core.Pos
	LParen     core.Pos
	Args       []ast.Expression
	Ellipsis   core.Pos
	RParen     core.Pos
}

MethodCall represents a method call expression.

func (*MethodCall) End

func (e *MethodCall) End() core.Pos

func (*MethodCall) IsCallExpression

func (e *MethodCall) IsCallExpression() bool

func (*MethodCall) IsCompositeLiteral

func (e *MethodCall) IsCompositeLiteral() bool

func (*MethodCall) IsScalarLiteral

func (e *MethodCall) IsScalarLiteral() bool

func (*MethodCall) IsUndefinedLiteral

func (e *MethodCall) IsUndefinedLiteral() bool

func (*MethodCall) LiteralToValue

func (e *MethodCall) LiteralToValue() (core.Value, bool)

func (*MethodCall) Pos

func (e *MethodCall) Pos() core.Pos

func (*MethodCall) String

func (e *MethodCall) String() string

type Parenthesis

type Parenthesis struct {
	Expr   ast.Expression
	LParen core.Pos
	RParen core.Pos
}

Parenthesis represents a parenthesis wrapped expression.

func (*Parenthesis) End

func (e *Parenthesis) End() core.Pos

func (*Parenthesis) IsCallExpression

func (e *Parenthesis) IsCallExpression() bool

func (*Parenthesis) IsCompositeLiteral

func (e *Parenthesis) IsCompositeLiteral() bool

func (*Parenthesis) IsScalarLiteral

func (e *Parenthesis) IsScalarLiteral() bool

func (*Parenthesis) IsUndefinedLiteral

func (e *Parenthesis) IsUndefinedLiteral() bool

func (*Parenthesis) LiteralToValue

func (e *Parenthesis) LiteralToValue() (core.Value, bool)

func (*Parenthesis) Pos

func (e *Parenthesis) Pos() core.Pos

func (*Parenthesis) String

func (e *Parenthesis) String() string

type Selector

type Selector struct {
	Expr ast.Expression
	Sel  ast.Expression
}

Selector represents a selector expression.

func (*Selector) End

func (e *Selector) End() core.Pos

func (*Selector) IsCallExpression

func (e *Selector) IsCallExpression() bool

func (*Selector) IsCompositeLiteral

func (e *Selector) IsCompositeLiteral() bool

func (*Selector) IsScalarLiteral

func (e *Selector) IsScalarLiteral() bool

func (*Selector) IsUndefinedLiteral

func (e *Selector) IsUndefinedLiteral() bool

func (*Selector) LiteralToValue

func (e *Selector) LiteralToValue() (core.Value, bool)

func (*Selector) Pos

func (e *Selector) Pos() core.Pos

func (*Selector) String

func (e *Selector) String() string

type Slice

type Slice struct {
	Expr   ast.Expression
	LBrack core.Pos
	Low    ast.Expression
	High   ast.Expression
	Step   ast.Expression
	RBrack core.Pos
}

Slice represents a slice expression.

func (*Slice) End

func (e *Slice) End() core.Pos

func (*Slice) IsCallExpression

func (e *Slice) IsCallExpression() bool

func (*Slice) IsCompositeLiteral

func (e *Slice) IsCompositeLiteral() bool

func (*Slice) IsScalarLiteral

func (e *Slice) IsScalarLiteral() bool

func (*Slice) IsUndefinedLiteral

func (e *Slice) IsUndefinedLiteral() bool

func (*Slice) LiteralToValue

func (e *Slice) LiteralToValue() (core.Value, bool)

func (*Slice) Pos

func (e *Slice) Pos() core.Pos

func (*Slice) String

func (e *Slice) String() string

type Ternary

type Ternary struct {
	Cond        ast.Expression
	True        ast.Expression
	False       ast.Expression
	QuestionPos core.Pos
	ColonPos    core.Pos
}

Ternary represents a ternary conditional expression.

func (*Ternary) End

func (e *Ternary) End() core.Pos

func (*Ternary) IsCallExpression

func (e *Ternary) IsCallExpression() bool

func (*Ternary) IsCompositeLiteral

func (e *Ternary) IsCompositeLiteral() bool

func (*Ternary) IsScalarLiteral

func (e *Ternary) IsScalarLiteral() bool

func (*Ternary) IsUndefinedLiteral

func (e *Ternary) IsUndefinedLiteral() bool

func (*Ternary) LiteralToValue

func (e *Ternary) LiteralToValue() (core.Value, bool)

func (*Ternary) Pos

func (e *Ternary) Pos() core.Pos

func (*Ternary) String

func (e *Ternary) String() string

type Unary

type Unary struct {
	Expr     ast.Expression
	Token    token.Token
	TokenPos core.Pos
}

Unary represents an unary operator expression.

func (*Unary) End

func (e *Unary) End() core.Pos

func (*Unary) IsCallExpression

func (e *Unary) IsCallExpression() bool

func (*Unary) IsCompositeLiteral

func (e *Unary) IsCompositeLiteral() bool

func (*Unary) IsScalarLiteral

func (e *Unary) IsScalarLiteral() bool

func (*Unary) IsUndefinedLiteral

func (e *Unary) IsUndefinedLiteral() bool

func (*Unary) LiteralToValue

func (e *Unary) LiteralToValue() (core.Value, bool)

func (*Unary) Pos

func (e *Unary) Pos() core.Pos

func (*Unary) String

func (e *Unary) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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