Documentation
¶
Index ¶
- func AllNumberBinarySuffixNames() []string
- func MarshalNumberLitValue(v NumberLitValue) ([]byte, error)
- type AnyType
- type Arguments
- type AssertStmt
- type AssignStmt
- type AstIndex
- type AugAssignStmt
- type AugOp
- type BaseExpr
- type BaseStmt
- type BasicType
- type BasicTypeEnum
- type BinOp
- type BinaryExpr
- type BoolLiteralType
- type CallExpr
- type CheckExpr
- type CmpOp
- type Comment
- type CompClause
- type Compare
- type ConfigEntry
- type ConfigEntryOperation
- type ConfigExpr
- type ConfigIfEntryExpr
- type Decorator
- type DictComp
- type DictType
- type Expr
- type ExprContext
- type ExprStmt
- type FloatLiteralType
- type FloatNumberLitValue
- type FormattedValue
- type FunctionType
- type Identifier
- type IdentifierExpr
- type IfExpr
- type IfStmt
- type ImportStmt
- type Index
- type IntLiteralType
- type IntNumberLitValue
- type JoinedString
- type Keyword
- type LambdaExpr
- type ListComp
- type ListExpr
- type ListIfItemExpr
- type ListType
- type LiteralType
- type LiteralTypeValue
- type Member
- type MemberOrIndex
- type MissingExpr
- type Module
- type NameConstant
- type NameConstantLit
- type NamedType
- type Node
- type NumberBinarySuffix
- type NumberLit
- type NumberLitValue
- type ParenExpr
- type Pos
- type QuantExpr
- type QuantOperation
- type RuleStmt
- type SchemaAttr
- type SchemaConfig
- type SchemaExpr
- type SchemaIndexSignature
- type SchemaStmt
- type SelectorExpr
- type StarredExpr
- type Stmt
- type StrLiteralType
- type StringLit
- type Subscript
- type Target
- type TargetExpr
- type Type
- type TypeAliasStmt
- type UnaryExpr
- type UnaryOp
- type UnificationStmt
- type UnionType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllNumberBinarySuffixNames ¶ added in v0.11.0
func AllNumberBinarySuffixNames() []string
AllNumberBinarySuffixNames returns all names of NumberBinarySuffix
func MarshalNumberLitValue ¶ added in v0.11.0
func MarshalNumberLitValue(v NumberLitValue) ([]byte, error)
MarshalJSON implements custom JSON marshaling for NumberLitValue
Types ¶
type Arguments ¶ added in v0.11.0
type Arguments struct { Args []*Node[Identifier] `json:"args"` Defaults []*Node[Expr] `json:"defaults,omitempty"` // Slice can contain nil to represent Rust's Vec<Option<Node<Expr>>> TyList []*Node[Type] `json:"ty_list,omitempty"` // Slice can contain nil to represent Rust's Vec<Option<Node<Type>>> }
Arguments represents function arguments, e.g.
lambda x: int = 1, y: int = 1 { x + y }
func NewArguments ¶ added in v0.11.0
func NewArguments() *Arguments
NewArguments creates a new Arguments
func (*Arguments) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for Arguments
func (*Arguments) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for Arguments
type AssertStmt ¶ added in v0.11.0
type AssertStmt struct { BaseStmt Test *Node[Expr] `json:"test"` IfCond *Node[Expr] `json:"if_cond,omitempty"` Msg *Node[Expr] `json:"msg,omitempty"` }
AssertStmt represents an assert statement, e.g.
assert True if condition, "Assert failed message"
func NewAssertStmt ¶ added in v0.11.0
func NewAssertStmt() *AssertStmt
NewAssertStmt creates a new AssertStmt
func (*AssertStmt) MarshalJSON ¶ added in v0.11.0
func (a *AssertStmt) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for AssertStmt
func (*AssertStmt) UnmarshalJSON ¶ added in v0.11.0
func (a *AssertStmt) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for AssertStmt
type AssignStmt ¶ added in v0.11.0
type AssignStmt struct { BaseStmt Targets []*Node[Target] `json:"targets"` Value *Node[Expr] `json:"value"` Ty *Node[Type] `json:"ty"` }
AssignStmt represents an assignment, e.g.
a: int = 1
a = 1
a = b = 1
func NewAssignStmt ¶ added in v0.11.0
func NewAssignStmt() *AssignStmt
NewAssignStmt creates a new AssignStmt
func (*AssignStmt) MarshalJSON ¶ added in v0.11.0
func (a *AssignStmt) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for AssignStmt
func (*AssignStmt) UnmarshalJSON ¶ added in v0.11.0
func (a *AssignStmt) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for AssignStmt
type AugAssignStmt ¶ added in v0.11.0
type AugAssignStmt struct { BaseStmt Target *Node[Target] `json:"target"` Value *Node[Expr] `json:"value"` Op AugOp `json:"op"` }
AugAssignStmt represents an augmented assignment, e.g.
a += 1
a -= 1
func NewAugAssignStmt ¶ added in v0.11.0
func NewAugAssignStmt() *AugAssignStmt
NewAugAssignStmt creates a new AugAssignStmt
func (*AugAssignStmt) MarshalJSON ¶ added in v0.11.0
func (a *AugAssignStmt) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for AugAssignStmt
func (*AugAssignStmt) UnmarshalJSON ¶ added in v0.11.0
func (a *AugAssignStmt) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for AugAssignStmt
type AugOp ¶ added in v0.11.0
type AugOp string
AugOp represents augmented assignment operations
const ( AugOpAssign AugOp = "=" AugOpAdd AugOp = "+=" AugOpSub AugOp = "-=" AugOpMul AugOp = "*=" AugOpDiv AugOp = "/=" AugOpMod AugOp = "%=" AugOpPow AugOp = "**=" AugOpFloorDiv AugOp = "//=" AugOpLShift AugOp = "<<=" AugOpRShift AugOp = ">>=" AugOpBitXor AugOp = "^=" AugOpBitAnd AugOp = "&=" AugOpBitOr AugOp = "|=" )
type BaseExpr ¶ added in v0.11.0
type BaseExpr struct {
ExprType string `json:"type"`
}
BaseExpr is a struct that all expression types can embed to implement the Expr interface
type BaseStmt ¶ added in v0.11.0
type BaseStmt struct {
StmtType string `json:"type"`
}
BaseStmt is a struct that all statement types can embed to implement the Stmt interface
type BasicType ¶ added in v0.11.0
type BasicType struct {
Value BasicTypeEnum `json:"value"`
}
BasicType represents a basic type
type BasicTypeEnum ¶ added in v0.11.0
type BasicTypeEnum string
const ( Bool BasicTypeEnum = "Bool" Int BasicTypeEnum = "Int" Float BasicTypeEnum = "Float" Str BasicTypeEnum = "Str" )
type BinOp ¶ added in v0.11.0
type BinOp string
BinOp represents a binary operator
const ( BinOpAdd BinOp = "+" BinOpSub BinOp = "-" BinOpMul BinOp = "*" BinOpDiv BinOp = "/" BinOpMod BinOp = "%" BinOpPow BinOp = "**" BinOpFloorDiv BinOp = "//" BinOpLShift BinOp = "<<" BinOpRShift BinOp = ">>" BinOpBitXor BinOp = "^" BinOpBitAnd BinOp = "&" BinOpBitOr BinOp = "|" BinOpAnd BinOp = "and" BinOpOr BinOp = "or" BinOpAs BinOp = "as" )
func AllBinOps ¶ added in v0.11.0
func AllBinOps() []BinOp
AllBinOps returns all possible BinOp values
func BinOpFromSymbol ¶ added in v0.11.0
BinOpFromSymbol returns the BinOp corresponding to the given symbol
type BinaryExpr ¶ added in v0.11.0
type BinaryExpr struct { BaseExpr Left *Node[Expr] `json:"left"` Op BinOp `json:"op"` Right *Node[Expr] `json:"right"` }
BinaryExpr represents a binary expression, e.g.
1 + 1 3 - 2 5 / 2 a is None
func NewBinaryExpr ¶ added in v0.11.0
func NewBinaryExpr() *BinaryExpr
NewBinaryExpr creates a new BinaryExpr
type BoolLiteralType ¶ added in v0.11.0
type BoolLiteralType bool
BoolLiteralType represents a boolean literal type
func (*BoolLiteralType) LiteralTypeName ¶ added in v0.11.0
func (b *BoolLiteralType) LiteralTypeName() string
type CallExpr ¶ added in v0.11.0
type CallExpr struct { BaseExpr Func *Node[Expr] `json:"func"` Args []*Node[Expr] `json:"args"` Keywords []*Node[Keyword] `json:"keywords"` }
CallExpr represents a function call expression, e.g.
func1() func2(1) func3(x=2)
func (*CallExpr) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for CallExpr
func (*CallExpr) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for CallExpr
type CheckExpr ¶ added in v0.11.0
type CheckExpr struct { Test *Node[Expr] `json:"test"` IfCond *Node[Expr] `json:"if_cond,omitempty"` Msg *Node[Expr] `json:"msg,omitempty"` }
CheckExpr represents a check expression, e.g.
len(attr) > 3 if attr, "Check failed message"
func NewCheckExpr ¶ added in v0.11.0
func NewCheckExpr() *CheckExpr
NewCheckExpr creates a new CheckExpr
func (*CheckExpr) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for CheckExpr
func (*CheckExpr) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for CheckExpr
type CmpOp ¶ added in v0.11.0
type CmpOp string
CmpOp represents a comparison operator
func AllCmpOps ¶ added in v0.11.0
func AllCmpOps() []CmpOp
AllCmpOps returns all possible CmpOp values
func CmpOpFromString ¶ added in v0.11.0
CmpOpFromString returns the CmpOp corresponding to the given string
type CompClause ¶ added in v0.11.0
type CompClause struct { BaseExpr Targets []*Node[Identifier] `json:"targets"` Iter *Node[Expr] `json:"iter"` Ifs []*Node[Expr] `json:"ifs"` }
CompClause represents a comprehension clause, e.g.
i, a in [1, 2, 3] if i > 1 and a > 1
func NewCompClause ¶ added in v0.11.0
func NewCompClause() *CompClause
NewCompClause creates a new CompClause
func (*CompClause) MarshalJSON ¶ added in v0.11.0
func (c *CompClause) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for CompClause
func (*CompClause) UnmarshalJSON ¶ added in v0.11.0
func (c *CompClause) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for CompClause
type Compare ¶ added in v0.11.0
type Compare struct { BaseExpr Left *Node[Expr] `json:"left"` Ops []CmpOp `json:"ops"` Comparators []*Node[Expr] `json:"comparators"` }
Compare represents a comparison expression, e.g.
0 < a < 10 b is not None c != d
func (*Compare) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for Compare
func (*Compare) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for Compare
type ConfigEntry ¶ added in v0.11.0
type ConfigEntry struct { Key *Node[Expr] `json:"key"` Value *Node[Expr] `json:"value"` Operation ConfigEntryOperation `json:"operation"` }
ConfigEntry represents a configuration entry, e.g.
{ attr1 = 1 attr2 += [0, 1] attr3: {key = value} }
func NewConfigEntry ¶ added in v0.11.0
func NewConfigEntry() *ConfigEntry
NewConfigEntry creates a new ConfigEntry
func (*ConfigEntry) MarshalJSON ¶ added in v0.11.0
func (c *ConfigEntry) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for ConfigEntry
func (*ConfigEntry) UnmarshalJSON ¶ added in v0.11.0
func (c *ConfigEntry) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for ConfigEntry
type ConfigEntryOperation ¶ added in v0.11.0
type ConfigEntryOperation string
ConfigEntryOperation represents the operation of a configuration entry
const ( ConfigEntryOperationUnion ConfigEntryOperation = "Union" ConfigEntryOperationOverride ConfigEntryOperation = "Override" ConfigEntryOperationInsert ConfigEntryOperation = "Insert" )
func AllConfigEntryOperations ¶ added in v0.11.0
func AllConfigEntryOperations() []ConfigEntryOperation
AllConfigEntryOperations returns all possible ConfigEntryOperation values
func ConfigEntryOperationFromString ¶ added in v0.11.0
func ConfigEntryOperationFromString(s string) (ConfigEntryOperation, error)
ConfigEntryOperationFromString returns the ConfigEntryOperation corresponding to the given string
func (ConfigEntryOperation) String ¶ added in v0.11.0
func (c ConfigEntryOperation) String() string
String returns the string representation of the ConfigEntryOperation
func (ConfigEntryOperation) Symbol ¶ added in v0.11.0
func (c ConfigEntryOperation) Symbol() string
Symbol returns the symbol representation of the ConfigEntryOperation
func (ConfigEntryOperation) Value ¶ added in v0.11.0
func (c ConfigEntryOperation) Value() int
Value returns the integer value of the ConfigEntryOperation
type ConfigExpr ¶ added in v0.11.0
type ConfigExpr struct { BaseExpr Items []*Node[ConfigEntry] `json:"items"` }
ConfigExpr represents a configuration expression, e.g.
{ attr1 = 1 attr2 += [0, 1] attr3: {key = value} }
func NewConfigExpr ¶ added in v0.11.0
func NewConfigExpr() *ConfigExpr
NewConfigExpr creates a new ConfigExpr
func (*ConfigExpr) MarshalJSON ¶ added in v0.11.0
func (c *ConfigExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for ConfigExpr
func (*ConfigExpr) UnmarshalJSON ¶ added in v0.11.0
func (c *ConfigExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for ConfigExpr
type ConfigIfEntryExpr ¶ added in v0.11.0
type ConfigIfEntryExpr struct { BaseExpr IfCond *Node[Expr] `json:"if_cond"` Items []*Node[ConfigEntry] `json:"items"` Orelse *Node[Expr] `json:"orelse"` }
ConfigIfEntryExpr represents a conditional configuration entry, e.g.
{ k1 = 1 if condition: k2 = 2 }
func NewConfigIfEntryExpr ¶ added in v0.11.0
func NewConfigIfEntryExpr() *ConfigIfEntryExpr
NewConfigIfEntryExpr creates a new ConfigIfEntryExpr
func (*ConfigIfEntryExpr) MarshalJSON ¶ added in v0.11.0
func (c *ConfigIfEntryExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for ConfigIfEntryExpr
func (*ConfigIfEntryExpr) UnmarshalJSON ¶ added in v0.11.0
func (c *ConfigIfEntryExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for ConfigIfEntryExpr
type Decorator ¶ added in v0.11.0
type Decorator struct { Func *Node[Expr] `json:"func"` Args []*Node[Expr] `json:"args,omitempty"` Keywords []*Node[Keyword] `json:"keywords,omitempty"` }
Decorator represents a decorator, e.g.
deprecated(strict=True)
func NewDecorator ¶ added in v0.11.0
func NewDecorator() *Decorator
NewDecorator creates a new Decorator
func (*Decorator) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for Decorator
func (*Decorator) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for Decorator
type DictComp ¶ added in v0.11.0
type DictComp struct { BaseExpr Entry ConfigEntry `json:"entry"` Generators []*Node[CompClause] `json:"generators"` }
DictComp represents a dictionary comprehension expression, e.g.
{k: v + 1 for k, v in {k1 = 1, k2 = 2}}
func (*DictComp) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for DictComp
func (*DictComp) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for DictComp
type DictType ¶ added in v0.11.0
type DictType struct { Value struct { KeyType *Node[Type] `json:"key_type,omitempty"` ValueType *Node[Type] `json:"value_type,omitempty"` } `json:"value"` }
DictType represents a dictionary type
type Expr ¶ added in v0.11.0
type Expr interface {
Type() string
}
Expr is an interface for all expression types
func UnmarshalExpr ¶ added in v0.11.0
UnmarshalExprJSON implements custom JSON unmarshaling for Expr
type ExprContext ¶ added in v0.11.0
type ExprContext int
ExprContext denotes the value context in the expression. e.g.,
The context of 'a' in 'a = b' is Store
The context of 'b' in 'a = b' is Load
const ( Load ExprContext = iota Store )
func (ExprContext) MarshalJSON ¶ added in v0.11.0
func (e ExprContext) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for ExprContext
func (ExprContext) String ¶ added in v0.11.0
func (e ExprContext) String() string
String returns the string representation of ExprContext
func (*ExprContext) UnmarshalJSON ¶ added in v0.11.0
func (e *ExprContext) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for ExprContext
type ExprStmt ¶ added in v0.11.0
ExprStmt represents a expression statement, e.g.
1
"""A long string"""
'A string'
type FloatLiteralType ¶ added in v0.11.0
type FloatLiteralType float64
FloatLiteralType represents a float literal type
func (*FloatLiteralType) LiteralTypeName ¶ added in v0.11.0
func (f *FloatLiteralType) LiteralTypeName() string
type FloatNumberLitValue ¶ added in v0.11.0
type FloatNumberLitValue struct {
Value float64 `json:"value"`
}
FloatNumberLitValue represents a float number literal value
func (*FloatNumberLitValue) Type ¶ added in v0.11.0
func (f *FloatNumberLitValue) Type() string
Type returns the type of the number literal value
type FormattedValue ¶ added in v0.11.0
type FormattedValue struct { BaseExpr IsLongString bool `json:"is_long_string"` Value *Node[Expr] `json:"value"` FormatSpec string `json:"format_spec"` }
FormattedValue represents a formatted value, e.g. var1 and var2 in the string interpolation "${var1} abc ${var2}"
func NewFormattedValue ¶ added in v0.11.0
func NewFormattedValue() *FormattedValue
NewFormattedValue creates a new FormattedValue
func (*FormattedValue) MarshalJSON ¶ added in v0.11.0
func (f *FormattedValue) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for FormattedValue
func (*FormattedValue) UnmarshalJSON ¶ added in v0.11.0
func (f *FormattedValue) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for FormattedValue
type FunctionType ¶ added in v0.11.0
type FunctionType struct { Value struct { ParamsTy []*Node[Type] `json:"params_ty,omitempty"` RetTy *Node[Type] `json:"ret_ty,omitempty"` } `json:"value"` }
FunctionType represents a function type
func (*FunctionType) TypeName ¶ added in v0.11.0
func (f *FunctionType) TypeName() string
type Identifier ¶ added in v0.11.0
type Identifier struct { Names []*Node[string] `json:"names"` Pkgpath string `json:"pkgpath"` Ctx ExprContext `json:"ctx"` }
Identifier represents an identifier, e.g.
a b _c pkg.a
type IdentifierExpr ¶ added in v0.11.0
type IdentifierExpr struct { BaseExpr Identifier }
IdentifierExpr represents an identifier expression, e.g.
a b _c pkg.a
func NewIdentifierExpr ¶ added in v0.11.0
func NewIdentifierExpr() *IdentifierExpr
NewIdentifierExpr creates a new IdentifierExpr
func (*IdentifierExpr) MarshalJSON ¶ added in v0.11.0
func (i *IdentifierExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for IdentifierExpr
func (*IdentifierExpr) UnmarshalJSON ¶ added in v0.11.0
func (i *IdentifierExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for IdentifierExpr
type IfExpr ¶ added in v0.11.0
type IfExpr struct { BaseExpr Body *Node[Expr] `json:"body"` Cond *Node[Expr] `json:"cond"` Orelse *Node[Expr] `json:"orelse"` }
IfExpr represents an if expression, e.g.
1 if condition else 2
func (*IfExpr) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for IfExpr
func (*IfExpr) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for IfExpr
type IfStmt ¶ added in v0.11.0
type IfStmt struct { BaseStmt Body []*Node[Stmt] `json:"body"` Cond *Node[Expr] `json:"cond"` Orelse []*Node[Stmt] `json:"orelse,omitempty"` }
IfStmt represents an if statement, e.g.
if condition1:
if condition2: a = 1
elif condition3:
b = 2
else:
c = 3
func (*IfStmt) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for IfStmt
func (*IfStmt) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for IfStmt
type ImportStmt ¶ added in v0.11.0
type ImportStmt struct { BaseStmt Path *Node[string] `json:"path"` Rawpath string `json:"rawpath"` Name string `json:"name"` Asname *Node[string] `json:"asname,omitempty"` PkgName string `json:"pkg_name"` }
ImportStmt represents an import statement, e.g.
import pkg as pkg_alias
func NewImportStmt ¶ added in v0.11.0
func NewImportStmt() *ImportStmt
NewImportStmt creates a new ImportStmt
func (*ImportStmt) MarshalJSON ¶ added in v0.11.0
func (i *ImportStmt) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for ImportStmt
func (*ImportStmt) UnmarshalJSON ¶ added in v0.11.0
func (i *ImportStmt) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for ImportStmt
type IntLiteralType ¶ added in v0.11.0
type IntLiteralType struct { Value int `json:"value"` Suffix *NumberBinarySuffix `json:"binary_suffix,omitempty"` }
IntLiteralType represents an integer literal type
func (*IntLiteralType) LiteralTypeName ¶ added in v0.11.0
func (i *IntLiteralType) LiteralTypeName() string
type IntNumberLitValue ¶ added in v0.11.0
type IntNumberLitValue struct {
Value int64 `json:"value"`
}
IntNumberLitValue represents an integer number literal value
func (*IntNumberLitValue) Type ¶ added in v0.11.0
func (i *IntNumberLitValue) Type() string
Type returns the type of the number literal value
type JoinedString ¶ added in v0.11.0
type JoinedString struct { BaseExpr IsLongString bool `json:"is_long_string"` Values []*Node[Expr] `json:"values"` RawValue string `json:"raw_value"` }
JoinedString represents a joined string, e.g. abc in the string interpolation "${var1} abc ${var2}"
func NewJoinedString ¶ added in v0.11.0
func NewJoinedString() *JoinedString
NewJoinedString creates a new JoinedString
func (*JoinedString) MarshalJSON ¶ added in v0.11.0
func (j *JoinedString) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for JoinedString
func (*JoinedString) UnmarshalJSON ¶ added in v0.11.0
func (j *JoinedString) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for JoinedString
type Keyword ¶ added in v0.11.0
type Keyword struct { Arg *Node[Identifier] `json:"arg"` Value *Node[Expr] `json:"value"` }
Keyword represents a keyword argument, e.g.
arg = value
func (*Keyword) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for Keyword
func (*Keyword) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for Keyword
type LambdaExpr ¶ added in v0.11.0
type LambdaExpr struct { BaseExpr Args *Node[Arguments] `json:"args"` Body []*Node[Stmt] `json:"body"` ReturnTy *Node[Type] `json:"return_ty"` }
LambdaExpr represents a lambda expression, e.g.
lambda x, y { z = 2 * x z + y }
func NewLambdaExpr ¶ added in v0.11.0
func NewLambdaExpr() *LambdaExpr
NewLambdaExpr creates a new LambdaExpr
func (*LambdaExpr) MarshalJSON ¶ added in v0.11.0
func (l *LambdaExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for LambdaExpr
func (*LambdaExpr) UnmarshalJSON ¶ added in v0.11.0
func (l *LambdaExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for LambdaExpr
type ListComp ¶ added in v0.11.0
type ListComp struct { BaseExpr Elt *Node[Expr] `json:"elt"` Generators []*Node[CompClause] `json:"generators"` }
ListComp represents a list comprehension expression, e.g.
[x ** 2 for x in [1, 2, 3]]
func (*ListComp) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for ListComp
func (*ListComp) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for ListComp
type ListExpr ¶ added in v0.11.0
type ListExpr struct { BaseExpr Elts []*Node[Expr] `json:"elts"` Ctx ExprContext `json:"ctx"` }
ListExpr represents a list expression, e.g.
[1, 2, 3] [1, if True: 2, 3]
func (*ListExpr) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for ListExpr
func (*ListExpr) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for ListExpr
type ListIfItemExpr ¶ added in v0.11.0
type ListIfItemExpr struct { BaseExpr IfCond *Node[Expr] `json:"if_cond"` Exprs []*Node[Expr] `json:"exprs"` Orelse *Node[Expr] `json:"orelse"` }
ListIfItemExpr represents a list if-item expression, e.g.
[1, if True: 2, 3]
func NewListIfItemExpr ¶ added in v0.11.0
func NewListIfItemExpr() *ListIfItemExpr
NewListIfItemExpr creates a new ListIfItemExpr
func (*ListIfItemExpr) MarshalJSON ¶ added in v0.11.0
func (l *ListIfItemExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for ListIfItemExpr
func (*ListIfItemExpr) UnmarshalJSON ¶ added in v0.11.0
func (l *ListIfItemExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for ListIfItemExpr
type ListType ¶ added in v0.11.0
type ListType struct { Value struct { InnerType *Node[Type] `json:"inner_type,omitempty"` } `json:"value"` }
ListType represents a list type
type LiteralType ¶ added in v0.11.0
type LiteralType struct {
Value LiteralTypeValue `json:"value"`
}
LiteralType represents a literal type
func (*LiteralType) TypeName ¶ added in v0.11.0
func (l *LiteralType) TypeName() string
type LiteralTypeValue ¶ added in v0.11.0
type LiteralTypeValue interface {
LiteralTypeName() string
}
LiteralTypeValue is an interface for different literal types
type MemberOrIndex ¶ added in v0.11.0
type MemberOrIndex interface {
Type() string
}
MemberOrIndex is the base interface for member or index expression
a.<member> b[<index>]
func UnmarshalMemberOrIndex ¶ added in v0.11.0
func UnmarshalMemberOrIndex(data []byte) (MemberOrIndex, error)
UnmarshalMemberOrIndex is a helper function to unmarshal JSON into MemberOrIndex
type MissingExpr ¶ added in v0.11.0
type MissingExpr struct {
BaseExpr
}
MissingExpr is a placeholder for error recovery
func NewMissingExpr ¶ added in v0.11.0
func NewMissingExpr() *MissingExpr
NewMissingExpr creates a new MissingExpr
func (*MissingExpr) MarshalJSON ¶ added in v0.11.0
func (m *MissingExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for MissingExpr
func (*MissingExpr) UnmarshalJSON ¶ added in v0.11.0
func (m *MissingExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for MissingExpr
type Module ¶ added in v0.11.0
type Module struct { Filename string `json:"filename"` Pkg string `json:"pkg"` Doc *Node[string] `json:"doc"` Body []*Node[Stmt] `json:"body"` Comments []*Node[Comment] `json:"comments"` }
Module is an abstract syntax tree for a single KCL file.
type NameConstant ¶ added in v0.11.0
type NameConstant string
NameConstant represents a name constant, e.g.
True False None Undefined
const ( NameConstantTrue NameConstant = "True" NameConstantFalse NameConstant = "False" NameConstantNone NameConstant = "None" NameConstantUndefined NameConstant = "Undefined" )
func AllNameConstants ¶ added in v0.11.0
func AllNameConstants() []NameConstant
AllNameConstants returns all possible NameConstant values
func (NameConstant) JSONValue ¶ added in v0.11.0
func (n NameConstant) JSONValue() string
JSONValue returns the JSON value for each constant
func (NameConstant) MarshalJSON ¶ added in v0.11.0
func (n NameConstant) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for NameConstant
func (NameConstant) Symbol ¶ added in v0.11.0
func (n NameConstant) Symbol() string
Symbol returns the symbol for each constant
func (*NameConstant) UnmarshalJSON ¶ added in v0.11.0
func (n *NameConstant) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for NameConstant
type NameConstantLit ¶ added in v0.11.0
type NameConstantLit struct { BaseExpr Value NameConstant `json:"value"` }
NameConstantLit represents a name constant literal, e.g.
True False None Undefined
func NewNameConstantLit ¶ added in v0.11.0
func NewNameConstantLit() *NameConstantLit
NewNameConstantLit creates a new NameConstantLit
func (*NameConstantLit) MarshalJSON ¶ added in v0.11.0
func (n *NameConstantLit) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for NameConstantLit
func (*NameConstantLit) UnmarshalJSON ¶ added in v0.11.0
func (n *NameConstantLit) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for NameConstantLit
type NamedType ¶ added in v0.11.0
type NamedType struct { Value struct { Identifier *Identifier `json:"identifier"` } `json:"value"` }
NamedType represents a named type
type Node ¶
Node is the file, line and column number information that all AST nodes need to contain. In fact, column and end_column are the counts of character. For example, `\t` is counted as 1 character, so it is recorded as 1 here, but generally col is 4.
func (*Node[Stmt]) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements the json.Marshaler interface
func (*Node[T]) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements the json.Unmarshaler interface
type NumberBinarySuffix ¶ added in v0.11.0
type NumberBinarySuffix string
NumberBinarySuffix represents the binary suffix of a number
const ( NumberBinarySuffixN NumberBinarySuffix = "n" NumberBinarySuffixU NumberBinarySuffix = "u" NumberBinarySuffixM NumberBinarySuffix = "m" NumberBinarySuffixK NumberBinarySuffix = "k" NumberBinarySuffixKU NumberBinarySuffix = "K" NumberBinarySuffixMU NumberBinarySuffix = "M" NumberBinarySuffixG NumberBinarySuffix = "G" NumberBinarySuffixT NumberBinarySuffix = "T" NumberBinarySuffixP NumberBinarySuffix = "P" NumberBinarySuffixKi NumberBinarySuffix = "Ki" NumberBinarySuffixMi NumberBinarySuffix = "Mi" NumberBinarySuffixGi NumberBinarySuffix = "Gi" NumberBinarySuffixTi NumberBinarySuffix = "Ti" NumberBinarySuffixPi NumberBinarySuffix = "Pi" )
func AllNumberBinarySuffixes ¶ added in v0.11.0
func AllNumberBinarySuffixes() []NumberBinarySuffix
AllNumberBinarySuffixes returns all possible NumberBinarySuffix values
func NumberBinarySuffixFromString ¶ added in v0.11.0
func NumberBinarySuffixFromString(s string) (NumberBinarySuffix, bool)
NumberBinarySuffixFromString returns the NumberBinarySuffix corresponding to the given string
func (NumberBinarySuffix) Value ¶ added in v0.11.0
func (n NumberBinarySuffix) Value() string
Value returns the string representation of the NumberBinarySuffix
type NumberLit ¶ added in v0.11.0
type NumberLit struct { BaseExpr BinarySuffix *NumberBinarySuffix `json:"binary_suffix,omitempty"` Value NumberLitValue `json:"value"` }
NumberLit represents a number literal, e.g.
1 2.0 1m 1K 1Mi
func NewNumberLit ¶ added in v0.11.0
func NewNumberLit() *NumberLit
NewNumberLit creates a new NumberLit
func (*NumberLit) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for NumberLit
func (*NumberLit) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for NumberLit
type NumberLitValue ¶ added in v0.11.0
type NumberLitValue interface {
Type() string
}
NumberLitValue represents the value of a number literal
func UnmarshalNumberLitValue ¶ added in v0.11.0
func UnmarshalNumberLitValue(data []byte) (NumberLitValue, error)
UnmarshalNumberLitValue unmarshals JSON data into a NumberLitValue
type ParenExpr ¶ added in v0.11.0
ParenExpr represents a parenthesized expression, e.g.
1 + (2 - 3)
func NewParenExpr ¶ added in v0.11.0
func NewParenExpr() *ParenExpr
NewParenExpr creates a new ParenExpr
func (*ParenExpr) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for ParenExpr
func (*ParenExpr) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for ParenExpr
type Pos ¶
type Pos struct { Filename string `json:"filename,omitempty"` Line int64 `json:"line,omitempty"` Column int64 `json:"column,omitempty"` EndLine int64 `json:"end_line,omitempty"` EndColumn int64 `json:"end_column,omitempty"` }
Pos denotes the struct tuple (filename, line, column, end_line, end_column).
type QuantExpr ¶ added in v0.11.0
type QuantExpr struct { BaseExpr Target *Node[Expr] `json:"target"` Variables []*Node[Identifier] `json:"variables"` Op QuantOperation `json:"op"` Test *Node[Expr] `json:"test"` IfCond *Node[Expr] `json:"if_cond"` Ctx ExprContext `json:"ctx"` }
QuantExpr represents a quantifier expression, e.g.
all x in collection {x > 0} any y in collection {y < 0} map x in collection {x + 1} filter x in collection {x > 1}
func NewQuantExpr ¶ added in v0.11.0
func NewQuantExpr() *QuantExpr
NewQuantExpr creates a new QuantExpr
func (*QuantExpr) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for QuantExpr
func (*QuantExpr) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for QuantExpr
type QuantOperation ¶ added in v0.11.0
type QuantOperation string
QuantOperation represents the operation of a quantifier expression
const ( QuantOperationAll QuantOperation = "All" QuantOperationAny QuantOperation = "Any" QuantOperationFilter QuantOperation = "Filter" QuantOperationMap QuantOperation = "Map" )
func AllQuantOperations ¶ added in v0.11.0
func AllQuantOperations() []QuantOperation
AllQuantOperations returns all possible QuantOperation values
func QuantOperationFromString ¶ added in v0.11.0
func QuantOperationFromString(s string) (QuantOperation, bool)
QuantOperationFromString returns the QuantOperation corresponding to the given string
func (QuantOperation) String ¶ added in v0.11.0
func (qo QuantOperation) String() string
String returns the string representation of the QuantOperation
type RuleStmt ¶ added in v0.11.0
type RuleStmt struct { BaseStmt Doc *Node[string] `json:"doc,omitempty"` Name *Node[string] `json:"name"` ParentRules []*Node[Identifier] `json:"parent_rules,omitempty"` Decorators []*Node[Decorator] `json:"decorators,omitempty"` Checks []*Node[CheckExpr] `json:"checks,omitempty"` Args *Node[Arguments] `json:"args,omitempty"` ForHostName *Node[Identifier] `json:"for_host_name,omitempty"` }
RuleStmt represents a rule statement, e.g.
rule RuleExample:
a > 1 b < 0
func (*RuleStmt) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for RuleStmt
func (*RuleStmt) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for RuleStmt
type SchemaAttr ¶ added in v0.11.0
type SchemaAttr struct { BaseStmt Doc string `json:"doc,omitempty"` Name *Node[string] `json:"name"` Op AugOp `json:"op,omitempty"` Value *Node[Expr] `json:"value,omitempty"` IsOptional bool `json:"is_optional"` Decorators []*Node[Decorator] `json:"decorators,omitempty"` Ty *Node[Type] `json:"ty,omitempty"` }
SchemaAttr represents schema attribute definitions, e.g.
schema SchemaAttrExample:
x: int y: str
func NewSchemaAttr ¶ added in v0.11.0
func NewSchemaAttr() *SchemaAttr
NewSchemaAttr creates a new SchemaAttr
func (*SchemaAttr) MarshalJSON ¶ added in v0.11.0
func (s *SchemaAttr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for SchemaAttr
func (*SchemaAttr) UnmarshalJSON ¶ added in v0.11.0
func (s *SchemaAttr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for SchemaAttr
type SchemaConfig ¶ added in v0.11.0
type SchemaConfig struct { Name *Node[Identifier] `json:"name"` Args []*Node[Expr] `json:"args"` Kwargs []*Node[Keyword] `json:"kwargs"` Config *Node[Expr] `json:"config"` }
SchemaConfig represents a schema configuration, e.g.
ASchema(arguments) { attr1 = 1 attr2 = BSchema {attr3 = 2} }
func NewSchemaConfig ¶ added in v0.11.0
func NewSchemaConfig() *SchemaConfig
NewSchemaConfig creates a new SchemaConfig
func (*SchemaConfig) MarshalJSON ¶ added in v0.11.0
func (s *SchemaConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for SchemaConfig
func (*SchemaConfig) UnmarshalJSON ¶ added in v0.11.0
func (s *SchemaConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for SchemaConfig
type SchemaExpr ¶ added in v0.11.0
type SchemaExpr struct { BaseExpr Name *Node[Identifier] `json:"name"` Args []*Node[Expr] `json:"args"` Kwargs []*Node[Keyword] `json:"kwargs"` Config *Node[Expr] `json:"config"` }
SchemaExpr represents a schema expression, e.g.
ASchema(arguments) { attr1 = 1 attr2 = BSchema {attr3 = 2} }
func NewSchemaExpr ¶ added in v0.11.0
func NewSchemaExpr() *SchemaExpr
NewSchemaExpr creates a new SchemaExpr
func (*SchemaExpr) MarshalJSON ¶ added in v0.11.0
func (s *SchemaExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for SchemaExpr
func (*SchemaExpr) UnmarshalJSON ¶ added in v0.11.0
func (s *SchemaExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for SchemaExpr
type SchemaIndexSignature ¶ added in v0.11.0
type SchemaIndexSignature struct { KeyName *Node[string] `json:"key_name,omitempty"` Value *Node[Expr] `json:"value,omitempty"` AnyOther bool `json:"any_other"` KeyTy *Node[Type] `json:"key_ty,omitempty"` ValueTy *Node[Type] `json:"value_ty,omitempty"` }
SchemaIndexSignature represents a schema index signature, e.g.
schema SchemaIndexSignatureExample:
[str]: int
func NewSchemaIndexSignature ¶ added in v0.11.0
func NewSchemaIndexSignature() *SchemaIndexSignature
NewSchemaIndexSignature creates a new SchemaIndexSignature
func (*SchemaIndexSignature) MarshalJSON ¶ added in v0.11.0
func (s *SchemaIndexSignature) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for SchemaIndexSignature
func (*SchemaIndexSignature) UnmarshalJSON ¶ added in v0.11.0
func (s *SchemaIndexSignature) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for SchemaIndexSignature
type SchemaStmt ¶ added in v0.11.0
type SchemaStmt struct { BaseStmt Doc *Node[string] `json:"doc,omitempty"` Name *Node[string] `json:"name"` ParentName *Node[Identifier] `json:"parent_name,omitempty"` ForHostName *Node[Identifier] `json:"for_host_name,omitempty"` IsMixin bool `json:"is_mixin"` IsProtocol bool `json:"is_protocol"` Args *Node[Arguments] `json:"args,omitempty"` Mixins []*Node[Identifier] `json:"mixins,omitempty"` Body []*Node[Stmt] `json:"body,omitempty"` Decorators []*Node[Decorator] `json:"decorators,omitempty"` Checks []*Node[CheckExpr] `json:"checks,omitempty"` IndexSignature *Node[SchemaIndexSignature] `json:"index_signature,omitempty"` }
SchemaStmt represents a schema statement, e.g.
schema BaseSchema:
schema SchemaExample(BaseSchema)[arg: str]:
"""Schema documents""" attr?: str = arg check: len(attr) > 3 if attr, "Check failed message"
mixin MixinExample for ProtocolExample:
attr: int
protocol ProtocolExample:
attr: int
func NewSchemaStmt ¶ added in v0.11.0
func NewSchemaStmt() *SchemaStmt
NewSchemaStmt creates a new SchemaStmt
func (*SchemaStmt) MarshalJSON ¶ added in v0.11.0
func (s *SchemaStmt) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for SchemaStmt
func (*SchemaStmt) UnmarshalJSON ¶ added in v0.11.0
func (s *SchemaStmt) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for SchemaStmt
type SelectorExpr ¶ added in v0.11.0
type SelectorExpr struct { BaseExpr Value *Node[Expr] `json:"value"` Attr *Node[Identifier] `json:"attr"` Ctx ExprContext `json:"ctx"` HasQuestion bool `json:"has_question"` }
SelectorExpr represents a selector expression, e.g.
x.y x?.y
func (*SelectorExpr) MarshalJSON ¶ added in v0.11.0
func (s *SelectorExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for SelectorExpr
func (*SelectorExpr) UnmarshalJSON ¶ added in v0.11.0
func (s *SelectorExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for SelectorExpr
type StarredExpr ¶ added in v0.11.0
type StarredExpr struct { BaseExpr Value *Node[Expr] `json:"value"` Ctx ExprContext `json:"ctx"` }
StarredExpr represents a starred expression, e.g.
[1, 2, *[3, 4]]
func NewStarredExpr ¶ added in v0.11.0
func NewStarredExpr() *StarredExpr
NewStarredExpr creates a new StarredExpr
func (*StarredExpr) MarshalJSON ¶ added in v0.11.0
func (s *StarredExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for StarredExpr
func (*StarredExpr) UnmarshalJSON ¶ added in v0.11.0
func (s *StarredExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for StarredExpr
type Stmt ¶ added in v0.11.0
type Stmt interface {
Type() string
}
Stmt is an interface for all statement types
func UnmarshalStmt ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for Stmt
type StrLiteralType ¶ added in v0.11.0
type StrLiteralType string
StrLiteralType represents a string literal type
func (*StrLiteralType) LiteralTypeName ¶ added in v0.11.0
func (s *StrLiteralType) LiteralTypeName() string
type StringLit ¶ added in v0.11.0
type StringLit struct { BaseExpr IsLongString bool `json:"is_long_string"` RawValue string `json:"raw_value"` Value string `json:"value"` }
StringLit represents a string literal, e.g.
"string literal" """long string literal"""
func NewStringLit ¶ added in v0.11.0
func NewStringLit() *StringLit
NewStringLit creates a new StringLit with default values
func (*StringLit) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for StringLit
func (*StringLit) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for StringLit
type Subscript ¶ added in v0.11.0
type Subscript struct { BaseExpr Value *Node[Expr] `json:"value"` Index *Node[Expr] `json:"index"` Lower *Node[Expr] `json:"lower"` Upper *Node[Expr] `json:"upper"` Step *Node[Expr] `json:"step"` Ctx ExprContext `json:"ctx"` HasQuestion bool `json:"has_question"` }
Subscript represents a subscript expression, e.g.
a[0] b["k"] c?[1] d[1:2:n]
func NewSubscript ¶ added in v0.11.0
func NewSubscript() *Subscript
NewSubscript creates a new Subscript
func (*Subscript) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for Subscript
func (*Subscript) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for Subscript
type Target ¶ added in v0.11.0
type Target struct { Name *Node[string] `json:"name"` Pkgpath string `json:"pkgpath"` Paths []*MemberOrIndex `json:"paths"` }
Target represents a target in an assignment, e.g.
a b _c a["b"][0].c
func (*Target) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for Target
func (*Target) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for Target
type TargetExpr ¶ added in v0.11.0
type TargetExpr struct { BaseExpr Name *Node[string] `json:"name"` Pkgpath string `json:"pkgpath,omitempty"` Paths []MemberOrIndex `json:"paths,omitempty"` }
TargetExpr represents a target expression, e.g.
a b _c a["b"][0].c
func NewTargetExpr ¶ added in v0.11.0
func NewTargetExpr() *TargetExpr
NewTargetExpr creates a new TargetExpr
func (*TargetExpr) MarshalJSON ¶ added in v0.11.0
func (t *TargetExpr) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for TargetExpr
func (*TargetExpr) UnmarshalJSON ¶ added in v0.11.0
func (t *TargetExpr) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for TargetExpr
type Type ¶ added in v0.11.0
type Type interface {
TypeName() string
}
Type is the base interface for all AST types
func UnmarshalType ¶ added in v0.11.0
UnmarshalType is a helper function to unmarshal JSON into Type
type TypeAliasStmt ¶ added in v0.11.0
type TypeAliasStmt struct { BaseStmt TypeName *Node[Identifier] `json:"type_name"` TypeValue *Node[string] `json:"type_value"` Ty *Node[Type] `json:"ty"` }
TypeAliasStmt represents a type alias statement, e.g.
type StrOrInt = str | int
func NewTypeAliasStmt ¶ added in v0.11.0
func NewTypeAliasStmt() *TypeAliasStmt
NewTypeAliasStmt creates a new TypeAliasStmt
func (*TypeAliasStmt) MarshalJSON ¶ added in v0.11.0
func (t *TypeAliasStmt) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for TypeAliasStmt
func (*TypeAliasStmt) UnmarshalJSON ¶ added in v0.11.0
func (t *TypeAliasStmt) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for TypeAliasStmt
type UnaryExpr ¶ added in v0.11.0
UnaryExpr represents a unary expression, e.g.
+1 -2 ~3 not True
func NewUnaryExpr ¶ added in v0.11.0
func NewUnaryExpr() *UnaryExpr
NewUnaryExpr creates a new UnaryExpr
func (*UnaryExpr) MarshalJSON ¶ added in v0.11.0
MarshalJSON implements custom JSON marshaling for UnaryExpr
func (*UnaryExpr) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON implements custom JSON unmarshaling for UnaryExpr
type UnaryOp ¶ added in v0.11.0
type UnaryOp string
UnaryOp represents a unary operator
func AllUnaryOps ¶ added in v0.11.0
func AllUnaryOps() []UnaryOp
AllUnaryOps returns all possible UnaryOp values
func UnaryOpFromSymbol ¶ added in v0.11.0
UnaryOpFromSymbol returns the UnaryOp corresponding to the given symbol
type UnificationStmt ¶ added in v0.11.0
type UnificationStmt struct { BaseStmt Target *Node[Identifier] `json:"target"` Value *Node[SchemaConfig] `json:"value"` }
UnificationStmt represents a declare statement with the union operator, e.g.
data: ASchema {}
func NewUnificationStmt ¶ added in v0.11.0
func NewUnificationStmt() *UnificationStmt
NewUnificationStmt creates a new UnificationStmt