Documentation
¶
Index ¶
- Constants
- func Code(n Coder, opt ...CodeOption) string
- func CodeW(w io.Writer, n Coder, opt ...CodeOption)
- func FormatFuncReturn(ret []*TypedIdentExpr) string
- func IsExpr(n Node) (ok bool)
- func IsStatement(v Node) (ok bool)
- func Lit(value string, pos source.Pos) ast.Literal
- func WithCallArgs[T interface{ ... }](e T, do func(args *CallArgs)) T
- func WriteFuncReturn(ctx *CodeWriteContext, ret []*TypedIdentExpr)
- type ArgVarLit
- type ArgsKeywordExpr
- type ArgsList
- type ArrayComprehension
- type ArrayExpr
- type AssignStmt
- type BadDecl
- type BadExpr
- type BadStmt
- type BinaryExpr
- type BlockExpr
- type BlockStmt
- type BoolExpr
- type BoolLit
- type BranchStmt
- type BytesLit
- type BytesLitPrefix
- type CallArgs
- func (c *CallArgs) Arg(e ...Expr) *CallArgs
- func (c *CallArgs) ArgVar(pos source.Pos, e Expr) *CallArgs
- func (c *CallArgs) End() source.Pos
- func (c *CallArgs) NamedFlag(e ...Expr) *CallArgs
- func (c *CallArgs) NamedValue(e ...Expr) *CallArgs
- func (c *CallArgs) Pos() source.Pos
- func (c *CallArgs) String() string
- func (c *CallArgs) StringArg(w io.Writer, lbrace, rbrace string)
- func (c *CallArgs) StringW(w io.Writer)
- func (c *CallArgs) ToFuncParams() (fp *FuncParams, err error)
- func (c *CallArgs) WriteCode(ctx *CodeWriteContext)
- func (c *CallArgs) WriteCodeBrace(ctx *CodeWriteContext, lbrace, rbrace string)
- type CallExpr
- type CallExprNamedArgs
- func (a *CallExprNamedArgs) Append(name *NamedArgExpr, value Expr) *CallExprNamedArgs
- func (a *CallExprNamedArgs) AppendE(name Expr, value Expr) *CallExprNamedArgs
- func (a *CallExprNamedArgs) AppendFlagE(name Expr) *CallExprNamedArgs
- func (a *CallExprNamedArgs) AppendFlags(name ...string) *CallExprNamedArgs
- func (a *CallExprNamedArgs) AppendS(name string, value Expr) *CallExprNamedArgs
- func (a *CallExprNamedArgs) Get(name NamedArgExpr) (index int, value Expr)
- func (a *CallExprNamedArgs) NamesExpr() (r []Expr)
- func (a *CallExprNamedArgs) Prepend(name *NamedArgExpr, value Expr) *CallExprNamedArgs
- func (a *CallExprNamedArgs) String() string
- func (a *CallExprNamedArgs) Valid() bool
- func (a *CallExprNamedArgs) Var() *NamedArgExpr
- func (a *CallExprNamedArgs) WriteCode(ctx *CodeWriteContext, inNewLime, hasPositional bool)
- func (a *CallExprNamedArgs) WriteCodeWithFlag(inNewLine, hasPositional bool, ctx *CodeWriteContext)
- type CallExprPositionalArgs
- type CalleeKeywordExpr
- type CatchStmt
- type CharLit
- type ClassExpr
- type ClassFieldExpr
- type ClassMemberExpr
- type ClassParentExpr
- type ClassStmt
- type ClosureExpr
- type CodeBeginStmt
- type CodeEndStmt
- type CodeOption
- func CodeFormat() CodeOption
- func CodeNewLineCalc(maxColumns int) CodeOption
- func CodeTranspile(v *TranspileOptions) CodeOption
- func CodeWithComments(f *source.File, groups []*ast.CommentGroup) CodeOption
- func CodeWithFlags(flag CodeWriteContextFlag) CodeOption
- func CodeWithPrefix(prefix string) CodeOption
- type CodeStrLit
- type CodeWriteContext
- func (ctx CodeWriteContext) Buffer(do func(ctx *CodeWriteContext)) string
- func (ctx *CodeWriteContext) Column() int
- func (ctx *CodeWriteContext) CurrentPrefix() string
- func (ctx *CodeWriteContext) DecideNewLine(flag CodeWriteContextFlag, count int, inlineSep string, closing int, ...) bool
- func (ctx *CodeWriteContext) DecideNewLineFunc(flag CodeWriteContextFlag, count, closing int, renderInline func()) bool
- func (ctx *CodeWriteContext) HasPrefix() bool
- func (ctx *CodeWriteContext) Pop()
- func (ctx *CodeWriteContext) PrevPrefix() string
- func (ctx *CodeWriteContext) Printf(format string, args ...interface{})
- func (ctx *CodeWriteContext) Push(n ast.Node)
- func (ctx *CodeWriteContext) Top() ast.Node
- func (ctx *CodeWriteContext) With(n ast.Node, cb func() error) (err error)
- func (ctx CodeWriteContext) WithoutPrefix() *CodeWriteContext
- func (ctx *CodeWriteContext) WriteExprs(sep string, expr ...Expr)
- func (ctx *CodeWriteContext) WriteGreedy(count int, itemSep, breakConnector string, do func(i int))
- func (ctx *CodeWriteContext) WriteItems(inNewLine bool, count int, do func(i int), done func(newLine bool))
- func (ctx *CodeWriteContext) WriteItemsSep(inNewLine bool, count int, inlineSep, newLineSep string, do func(i int), ...)
- func (ctx *CodeWriteContext) WriteLeadDoc(g *ast.CommentGroup) bool
- func (ctx *CodeWriteContext) WriteLine(s string)
- func (ctx *CodeWriteContext) WritePrefix()
- func (ctx *CodeWriteContext) WritePrefixedLine()
- func (ctx *CodeWriteContext) WritePrevPrefix()
- func (ctx *CodeWriteContext) WriteSecondLine()
- func (ctx *CodeWriteContext) WriteSemi()
- func (ctx *CodeWriteContext) WriteSemiOrDoubleLine()
- func (ctx *CodeWriteContext) WriteStmts(stmt ...Stmt)
- func (ctx *CodeWriteContext) WriteTrailingDoc(g *ast.CommentGroup) bool
- type CodeWriteContextFlag
- func (b *CodeWriteContextFlag) Clear(flag CodeWriteContextFlag) *CodeWriteContextFlag
- func (b CodeWriteContextFlag) Has(flag ...CodeWriteContextFlag) bool
- func (b *CodeWriteContextFlag) Set(flag CodeWriteContextFlag) *CodeWriteContextFlag
- func (b *CodeWriteContextFlag) Toggle(flag CodeWriteContextFlag) *CodeWriteContextFlag
- type CodeWriteSkiper
- type CodeWriter
- type Coder
- type ComprehensionClause
- type ComputedExpr
- type CondExpr
- type ConfigOptions
- type ConfigStmt
- type DateTimeLit
- type DateTimeLitKind
- type DecimalLit
- type Decl
- type DeclStmt
- type DeferStmt
- type DeferVariant
- type DictComprehension
- type DictElementFuncExprs
- type DictElementLit
- func (e *DictElementLit) BuildKeyExpr() Expr
- func (e *DictElementLit) End() source.Pos
- func (e *DictElementLit) ExprNode()
- func (e *DictElementLit) Func() (f *FuncDefLit)
- func (e *DictElementLit) IsFunc() (ok bool)
- func (e *DictElementLit) Pos() source.Pos
- func (e *DictElementLit) String() string
- func (e *DictElementLit) WriteCode(ctx *CodeWriteContext)
- type DictExpr
- type DotFileLit
- type DotFileNameLit
- type DurationLit
- type EmbedExpr
- func (e *EmbedExpr) ConfigFile() string
- func (e *EmbedExpr) End() source.Pos
- func (e *EmbedExpr) Excludes() []string
- func (e *EmbedExpr) ExcludesRe() []string
- func (e *EmbedExpr) ExprNode()
- func (e *EmbedExpr) Includes() []string
- func (e *EmbedExpr) IncludesRe() []string
- func (e *EmbedExpr) Path() (s string)
- func (e *EmbedExpr) Pos() source.Pos
- func (e *EmbedExpr) Sources() []string
- func (e *EmbedExpr) String() string
- func (e *EmbedExpr) Tree() bool
- func (e *EmbedExpr) WriteCode(ctx *CodeWriteContext)
- type EmptyStmt
- type EnumExpr
- type EnumFieldExpr
- type EnumStmt
- type ExportStmt
- type Expr
- type ExprSelector
- type ExprStmt
- type Exprs
- type FinallyStmt
- type FlagLit
- type FloatLit
- type ForInStmt
- type ForStmt
- type FuncDefLit
- type FuncExpr
- type FuncHeader
- type FuncHeaderExpr
- type FuncMethod
- type FuncParams
- type FuncStmt
- type FuncType
- type FuncWithMethodsExpr
- func (e *FuncWithMethodsExpr) End() source.Pos
- func (e *FuncWithMethodsExpr) ExprNode()
- func (e *FuncWithMethodsExpr) Funcs() (f Exprs)
- func (e *FuncWithMethodsExpr) NameIdent() *IdentExpr
- func (e *FuncWithMethodsExpr) Pos() source.Pos
- func (e *FuncWithMethodsExpr) String() string
- func (e *FuncWithMethodsExpr) WriteCode(ctx *CodeWriteContext)
- type FuncWithMethodsStmt
- type GenDecl
- type GlobalsLit
- type HeredocLit
- func (e *HeredocLit) ContentPos() source.Pos
- func (e *HeredocLit) End() source.Pos
- func (e *HeredocLit) ExprNode()
- func (e *HeredocLit) Pos() source.Pos
- func (e *HeredocLit) RawContent() string
- func (e *HeredocLit) String() string
- func (e *HeredocLit) StripCount() int
- func (e *HeredocLit) Value() string
- func (e *HeredocLit) WriteCode(ctx *CodeWriteContext)
- type IdentExpr
- type IdentList
- type IfStmt
- type ImportExpr
- type IncDecStmt
- type IndexExpr
- type IntLit
- type InterfaceExpr
- type InterfaceMemberExpr
- type InterfaceMemberKind
- type InterfaceMethodExpr
- type InterfaceStmt
- type IsMainLit
- type KeyValueArrayLit
- type KeyValueLit
- type KeyValuePairLit
- func (e *KeyValuePairLit) End() source.Pos
- func (e *KeyValuePairLit) ExprNode()
- func (e *KeyValuePairLit) Func() (f *FuncDefLit)
- func (e *KeyValuePairLit) IsFunc() (ok bool)
- func (e *KeyValuePairLit) Pos() source.Pos
- func (e *KeyValuePairLit) String() string
- func (e *KeyValuePairLit) WriteCode(ctx *CodeWriteContext)
- type MatchArm
- type MatchExpr
- type MethodExpr
- type MethodInterfaceExpr
- type MethodInterfaceStmt
- type MixedTextExpr
- type MixedTextStmt
- func (s *MixedTextStmt) End() source.Pos
- func (s *MixedTextStmt) ExprNode()
- func (s *MixedTextStmt) Pos() source.Pos
- func (s *MixedTextStmt) StmtNode()
- func (s *MixedTextStmt) String() string
- func (s *MixedTextStmt) TrimLinePrefix(prefix string)
- func (s *MixedTextStmt) ValidLit() ast.Literal
- func (s *MixedTextStmt) Value() string
- func (s *MixedTextStmt) WriteCode(ctx *CodeWriteContext)
- type MixedTextStmtFlag
- type MixedValueStmt
- type ModuleLit
- type MultiParenExpr
- func (e *MultiParenExpr) End() source.Pos
- func (e *MultiParenExpr) ExprNode()
- func (e *MultiParenExpr) Pos() source.Pos
- func (e *MultiParenExpr) String() string
- func (e *MultiParenExpr) ToCallArgs(strict bool) (args *CallArgs, err *NodeError)
- func (e *MultiParenExpr) ToFuncHeaderParams() (FuncParams, *NodeError)
- func (e *MultiParenExpr) ToFuncParams() (params FuncParams, err *NodeError)
- func (e *MultiParenExpr) ToMultiParenExpr() *MultiParenExpr
- func (e *MultiParenExpr) WriteCode(ctx *CodeWriteContext)
- type NamedArgBuilder
- type NamedArgExpr
- type NamedArgVarLit
- type NamedArgsKeywordExpr
- type NamedArgsList
- type NamedParamSpec
- type NilLit
- type Node
- type NodeError
- type NullishCallExpr
- func (e *NullishCallExpr) CallPos() source.Pos
- func (e *NullishCallExpr) End() source.Pos
- func (e *NullishCallExpr) ExprNode()
- func (e *NullishCallExpr) GetCallArgs() *CallArgs
- func (e *NullishCallExpr) Pos() source.Pos
- func (e *NullishCallExpr) String() string
- func (e *NullishCallExpr) WriteCode(ctx *CodeWriteContext)
- type NullishSelectorExpr
- func (e *NullishSelectorExpr) End() source.Pos
- func (e *NullishSelectorExpr) ExprNode()
- func (e *NullishSelectorExpr) GetX() Expr
- func (e *NullishSelectorExpr) GetY() Expr
- func (e *NullishSelectorExpr) Pos() source.Pos
- func (e *NullishSelectorExpr) String() string
- func (e *NullishSelectorExpr) WriteCode(ctx *CodeWriteContext)
- type OrExpr
- type ParamSpec
- type ParenExpr
- type PropExpr
- type PropStmt
- type Ptr
- type RawHeredocLit
- func (e *RawHeredocLit) ContentPos() source.Pos
- func (e *RawHeredocLit) End() source.Pos
- func (e *RawHeredocLit) ExprNode()
- func (e *RawHeredocLit) Pos() source.Pos
- func (e *RawHeredocLit) RawContent() string
- func (e *RawHeredocLit) String() string
- func (e *RawHeredocLit) StripCount() int
- func (e *RawHeredocLit) Value() string
- func (e *RawHeredocLit) WriteCode(ctx *CodeWriteContext)
- type RawStrLit
- type RegexLit
- type Return
- type ReturnExpr
- type ReturnStmt
- type SelectorExpr
- type SliceExpr
- type Spec
- type StdErrLit
- type StdInLit
- type StdOutLit
- type Stmt
- type Stmts
- func (s *Stmts) Append(n ...Stmt)
- func (s Stmts) Each(f func(i int, sep bool, s Stmt))
- func (s Stmts) Filter(f func(i int, s Stmt) bool) (l Stmts)
- func (s Stmts) Map(f func(i int, s Stmt) Stmt) (l Stmts)
- func (s *Stmts) Prepend(n ...Stmt)
- func (s Stmts) String() string
- func (s Stmts) WriteCode(ctx *CodeWriteContext)
- type StmtsExpr
- type StrLit
- type SymbolLit
- type TemplateLit
- func (e *TemplateLit) Build(sourceStmts Stmts) (expr Expr, err error)
- func (e *TemplateLit) End() source.Pos
- func (e *TemplateLit) ExprNode()
- func (e *TemplateLit) Pos() source.Pos
- func (e *TemplateLit) String() string
- func (e *TemplateLit) StringValue() string
- func (e *TemplateLit) StringValuePos() source.Pos
- func (e *TemplateLit) WriteCode(ctx *CodeWriteContext)
- type TestKind
- type TestStmt
- type ThrowExpr
- type ThrowStmt
- type ToMultiParenConverter
- type ToRaw
- type Token
- type TokenLit
- type TranspileOptions
- type TryStmt
- type TypeExpr
- type TypedIdentExpr
- type UintLit
- type UnaryExpr
- type ValueSpec
- type WithBind
- type WithExpr
- type WithStmt
Constants ¶
const DefaultMaxColumns = 80
DefaultMaxColumns is the line-width budget used by the NEW_LINE_CALC formatting mode when no explicit MaxColumns is set.
Variables ¶
This section is empty.
Functions ¶
func Code ¶
func Code(n Coder, opt ...CodeOption) string
func FormatFuncReturn ¶ added in v0.0.2
func FormatFuncReturn(ret []*TypedIdentExpr) string
FormatFuncReturn renders an optional function return-type list as " <T1, T2, ...>". It returns an empty string when there are no return types.
func IsStatement ¶
IsStatement returns true if given value is implements interface{ StmtNode() }.
func WithCallArgs ¶ added in v0.0.2
func WriteFuncReturn ¶ added in v0.0.2
func WriteFuncReturn(ctx *CodeWriteContext, ret []*TypedIdentExpr)
WriteFuncReturn is the WriteCode counterpart of FormatFuncReturn: it renders the return-type list applying the union spacing rule (` | ` around each `|`), inline within the `< >`.
Types ¶
type ArgVarLit ¶
ArgVarLit represents an variadic of argument.
func (*ArgVarLit) WriteCode ¶
func (e *ArgVarLit) WriteCode(ctx *CodeWriteContext)
type ArgsKeywordExpr ¶
func ArgsKW ¶
func ArgsKW(pos source.Pos) *ArgsKeywordExpr
func (*ArgsKeywordExpr) End ¶
func (c *ArgsKeywordExpr) End() source.Pos
func (*ArgsKeywordExpr) ExprNode ¶
func (c *ArgsKeywordExpr) ExprNode()
func (*ArgsKeywordExpr) Pos ¶
func (c *ArgsKeywordExpr) Pos() source.Pos
func (*ArgsKeywordExpr) String ¶
func (c *ArgsKeywordExpr) String() string
func (*ArgsKeywordExpr) WriteCode ¶
func (c *ArgsKeywordExpr) WriteCode(ctx *CodeWriteContext)
type ArgsList ¶
type ArgsList struct {
Var *TypedIdentExpr
Values []*TypedIdentExpr
}
ArgsList represents a list of identifiers.
func (*ArgsList) PrependValue ¶
func (n *ArgsList) PrependValue(v ...*TypedIdentExpr)
type ArrayComprehension ¶ added in v0.0.2
type ArrayComprehension struct {
LBrack source.Pos
Element Expr
Clauses []*ComprehensionClause
RBrack source.Pos
}
ArrayComprehension represents `[elem for x in it if cond ...]`.
func (*ArrayComprehension) End ¶ added in v0.0.2
func (e *ArrayComprehension) End() source.Pos
End returns the position of first character immediately after the node.
func (*ArrayComprehension) ExprNode ¶ added in v0.0.2
func (e *ArrayComprehension) ExprNode()
func (*ArrayComprehension) Pos ¶ added in v0.0.2
func (e *ArrayComprehension) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*ArrayComprehension) String ¶ added in v0.0.2
func (e *ArrayComprehension) String() string
func (*ArrayComprehension) WriteCode ¶ added in v0.0.2
func (e *ArrayComprehension) WriteCode(ctx *CodeWriteContext)
type ArrayExpr ¶
ArrayExpr represents an array literal.
func (*ArrayExpr) WriteCode ¶
func (e *ArrayExpr) WriteCode(ctx *CodeWriteContext)
type AssignStmt ¶
AssignStmt represents an assignment statement.
func (*AssignStmt) End ¶
func (s *AssignStmt) End() source.Pos
End returns the position of first character immediately after the node.
func (*AssignStmt) Pos ¶
func (s *AssignStmt) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*AssignStmt) StmtNode ¶
func (s *AssignStmt) StmtNode()
func (*AssignStmt) String ¶
func (s *AssignStmt) String() string
func (*AssignStmt) WriteCode ¶
func (s *AssignStmt) WriteCode(ctx *CodeWriteContext)
type BadDecl ¶
A BadDecl node is a placeholder for declarations containing syntax errors for which no correct declaration nodes can be created.
func (*BadDecl) WriteCode ¶
func (d *BadDecl) WriteCode(ctx *CodeWriteContext)
type BadExpr ¶
BadExpr represents a bad expression.
func (*BadExpr) WriteCode ¶
func (e *BadExpr) WriteCode(ctx *CodeWriteContext)
type BadStmt ¶
BadStmt represents a bad statement.
func (*BadStmt) WriteCode ¶
func (s *BadStmt) WriteCode(ctx *CodeWriteContext)
type BinaryExpr ¶
BinaryExpr represents a binary operator expression.
func (*BinaryExpr) End ¶
func (e *BinaryExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*BinaryExpr) ExprNode ¶
func (e *BinaryExpr) ExprNode()
func (*BinaryExpr) Pos ¶
func (e *BinaryExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*BinaryExpr) String ¶
func (e *BinaryExpr) String() string
func (*BinaryExpr) WriteCode ¶
func (e *BinaryExpr) WriteCode(ctx *CodeWriteContext)
func (*BinaryExpr) WriteCodeWithParen ¶ added in v0.0.2
func (e *BinaryExpr) WriteCodeWithParen(ctx *CodeWriteContext, paren bool)
type BlockStmt ¶
type BlockStmt struct {
Stmts Stmts
LBrace ast.Literal
RBrace ast.Literal
Scoped bool
// DeferClaimed marks a function body whose `defer` statements have already
// been claimed by an enclosing defer wrapper, so it must not be wrapped
// again (its defers register to the outer $__defers list).
DeferClaimed bool
}
BlockStmt represents a block statement.
func (*BlockStmt) WriteCode ¶
func (s *BlockStmt) WriteCode(ctx *CodeWriteContext)
type BoolLit ¶
BoolLit represents a boolean literal.
func (*BoolLit) WriteCode ¶
func (e *BoolLit) WriteCode(ctx *CodeWriteContext)
type BranchStmt ¶
BranchStmt represents a branch statement.
func SBreak ¶
func SBreak(pos source.Pos) *BranchStmt
func SContinue ¶
func SContinue(pos source.Pos) *BranchStmt
func (*BranchStmt) End ¶
func (s *BranchStmt) End() source.Pos
End returns the position of first character immediately after the node.
func (*BranchStmt) Pos ¶
func (s *BranchStmt) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*BranchStmt) StmtNode ¶
func (s *BranchStmt) StmtNode()
func (*BranchStmt) String ¶
func (s *BranchStmt) String() string
func (*BranchStmt) WriteCode ¶
func (s *BranchStmt) WriteCode(ctx *CodeWriteContext)
type BytesLit ¶ added in v0.0.2
type BytesLit struct {
// Prefix is the literal prefix (BytesLitHex or BytesLitRaw).
Prefix BytesLitPrefix
// PrefixPos is the position of the prefix letter.
PrefixPos source.Pos
// Str is the underlying string literal node (*StrLit, *RawStrLit,
// *HeredocLit or *RawHeredocLit).
Str Expr
}
BytesLit represents a prefixed string literal that evaluates to a byte slice.
The prefix is a single letter immediately preceding the opening string delimiter (no whitespace): h for a hexadecimal sequence (h"ffccf1c2") and b for the raw UTF-8 bytes of the content (b"Hello"). Any string form may be used as the body: a regular string, a raw string, a heredoc or a raw heredoc.
func (*BytesLit) Bytes ¶ added in v0.0.2
Bytes decodes the literal into its byte slice value. For BytesLitHex the content is parsed as hexadecimal (whitespace ignored); for BytesLitRaw the UTF-8 bytes of the content are returned unchanged.
func (*BytesLit) End ¶ added in v0.0.2
End returns the position immediately after the underlying string literal.
func (*BytesLit) StrValue ¶ added in v0.0.2
StrValue returns the decoded string content of the underlying string literal.
func (*BytesLit) WriteCode ¶ added in v0.0.2
func (e *BytesLit) WriteCode(ctx *CodeWriteContext)
type BytesLitPrefix ¶ added in v0.0.2
type BytesLitPrefix string
BytesLitPrefix identifies how a BytesLit's underlying string is decoded into a byte slice.
const ( // BytesLitHex decodes the string content as a hexadecimal byte sequence, // e.g. h"ffccf1c2". Whitespace inside the string is ignored. BytesLitHex BytesLitPrefix = "h" // BytesLitRaw uses the UTF-8 bytes of the string content as-is, // e.g. b"Hello". BytesLitRaw BytesLitPrefix = "b" )
type CallArgs ¶
type CallArgs struct {
LParen source.Pos
RParen source.Pos
Args CallExprPositionalArgs
NamedArgs CallExprNamedArgs
}
func (*CallArgs) NamedValue ¶ added in v0.0.2
func (*CallArgs) ToFuncParams ¶
func (c *CallArgs) ToFuncParams() (fp *FuncParams, err error)
func (*CallArgs) WriteCode ¶
func (c *CallArgs) WriteCode(ctx *CodeWriteContext)
func (*CallArgs) WriteCodeBrace ¶
func (c *CallArgs) WriteCodeBrace(ctx *CodeWriteContext, lbrace, rbrace string)
type CallExpr ¶
CallExpr represents a function call expression.
func ECallProxy ¶
func (*CallExpr) GetCallArgs ¶ added in v0.0.2
func (*CallExpr) WriteCode ¶
func (e *CallExpr) WriteCode(ctx *CodeWriteContext)
type CallExprNamedArgs ¶
type CallExprNamedArgs struct {
Names []*NamedArgExpr
Values []Expr
}
CallExprNamedArgs represents a call expression keyword arguments.
func NewCallExprNamedArgs ¶
func NewCallExprNamedArgs( names []*NamedArgExpr, values []Expr, ) (ce *CallExprNamedArgs)
func (*CallExprNamedArgs) Append ¶
func (a *CallExprNamedArgs) Append(name *NamedArgExpr, value Expr) *CallExprNamedArgs
func (*CallExprNamedArgs) AppendE ¶ added in v0.0.2
func (a *CallExprNamedArgs) AppendE(name Expr, value Expr) *CallExprNamedArgs
func (*CallExprNamedArgs) AppendFlagE ¶ added in v0.0.2
func (a *CallExprNamedArgs) AppendFlagE(name Expr) *CallExprNamedArgs
func (*CallExprNamedArgs) AppendFlags ¶ added in v0.0.2
func (a *CallExprNamedArgs) AppendFlags(name ...string) *CallExprNamedArgs
func (*CallExprNamedArgs) AppendS ¶
func (a *CallExprNamedArgs) AppendS(name string, value Expr) *CallExprNamedArgs
func (*CallExprNamedArgs) Get ¶
func (a *CallExprNamedArgs) Get(name NamedArgExpr) (index int, value Expr)
func (*CallExprNamedArgs) NamesExpr ¶
func (a *CallExprNamedArgs) NamesExpr() (r []Expr)
func (*CallExprNamedArgs) Prepend ¶
func (a *CallExprNamedArgs) Prepend(name *NamedArgExpr, value Expr) *CallExprNamedArgs
func (*CallExprNamedArgs) String ¶
func (a *CallExprNamedArgs) String() string
func (*CallExprNamedArgs) Valid ¶
func (a *CallExprNamedArgs) Valid() bool
func (*CallExprNamedArgs) Var ¶
func (a *CallExprNamedArgs) Var() *NamedArgExpr
func (*CallExprNamedArgs) WriteCode ¶
func (a *CallExprNamedArgs) WriteCode(ctx *CodeWriteContext, inNewLime, hasPositional bool)
func (*CallExprNamedArgs) WriteCodeWithFlag ¶ added in v0.0.2
func (a *CallExprNamedArgs) WriteCodeWithFlag(inNewLine, hasPositional bool, ctx *CodeWriteContext)
type CallExprPositionalArgs ¶ added in v0.0.2
CallExprPositionalArgs represents a call expression arguments.
func NewCallExprArgs ¶
func NewCallExprArgs( argVar *ArgVarLit, args ...Expr, ) (ce CallExprPositionalArgs)
func (*CallExprPositionalArgs) AppendValues ¶ added in v0.0.2
func (a *CallExprPositionalArgs) AppendValues(e ...Expr)
func (*CallExprPositionalArgs) String ¶ added in v0.0.2
func (a *CallExprPositionalArgs) String() string
func (*CallExprPositionalArgs) Valid ¶ added in v0.0.2
func (a *CallExprPositionalArgs) Valid() bool
func (*CallExprPositionalArgs) WriteCodeWithNamed ¶ added in v0.0.2
func (a *CallExprPositionalArgs) WriteCodeWithNamed(ctx *CodeWriteContext, inNewLine, hasNamed bool)
type CalleeKeywordExpr ¶
func CaleeKW ¶
func CaleeKW(pos source.Pos) *CalleeKeywordExpr
func (*CalleeKeywordExpr) End ¶
func (c *CalleeKeywordExpr) End() source.Pos
func (*CalleeKeywordExpr) ExprNode ¶
func (c *CalleeKeywordExpr) ExprNode()
func (*CalleeKeywordExpr) Pos ¶
func (c *CalleeKeywordExpr) Pos() source.Pos
func (*CalleeKeywordExpr) String ¶
func (c *CalleeKeywordExpr) String() string
func (*CalleeKeywordExpr) WriteCode ¶
func (c *CalleeKeywordExpr) WriteCode(ctx *CodeWriteContext)
type CatchStmt ¶
type CatchStmt struct {
CatchPos source.Pos
Ident *IdentExpr // can be nil if ident is missing
Body *BlockStmt
}
CatchStmt represents an catch statement.
func (*CatchStmt) WriteCode ¶
func (s *CatchStmt) WriteCode(ctx *CodeWriteContext)
type CharLit ¶
CharLit represents a character literal.
func (*CharLit) WriteCode ¶
func (e *CharLit) WriteCode(ctx *CodeWriteContext)
type ClassExpr ¶ added in v0.0.2
type ClassExpr struct {
ClassToken TokenLit
NameExpr Expr
Parents []*ClassParentExpr
ExtendsDoc *ast.CommentGroup
Fields []*ClassFieldExpr
Props []*ClassMemberExpr
PropsDoc *ast.CommentGroup
New []*FuncMethod
NewDoc *ast.CommentGroup
Methods []*ClassMemberExpr
MethodsDoc *ast.CommentGroup
LBrace source.Pos
RBrace source.Pos
Doc *ast.CommentGroup // doc comment preceding the class; or nil
}
ClassExpr is a class literal:
class [Name] { *P, …, fields, props {…}, new …, methods {…} }
Parent classes are `*Parent` spread body items (optionally aliased as `*Parent: Alias`), alongside fields and the `props`/`new`/`methods` groups. It lowers (in the compiler) to a
Class(name; define=(Type, define) => define(; extends=…, fields=…,
properties=…, methods=…, new=…))
call. The `define` callback binds `Type` to the in-construction class so each method, property accessor and constructor can take a typed `this Type` first parameter (injected by the compiler). NameExpr is nil for an anonymous, expression-form class.
func (*ClassExpr) WriteCode ¶ added in v0.0.2
func (e *ClassExpr) WriteCode(ctx *CodeWriteContext)
type ClassFieldExpr ¶ added in v0.0.2
type ClassFieldExpr struct {
Name *TypedIdentExpr
Assign source.Pos
Value Expr // default value; nil when none
Doc *ast.CommentGroup // doc comment preceding the field; or nil
}
ClassFieldExpr is a declared field in a class body: `name`, `name = value`, `name Type = value`, or a computed default `name = (= expr)` (Value is then a *ComputedExpr, evaluated per instance).
func (*ClassFieldExpr) End ¶ added in v0.0.2
func (e *ClassFieldExpr) End() source.Pos
func (*ClassFieldExpr) ExprNode ¶ added in v0.0.2
func (e *ClassFieldExpr) ExprNode()
func (*ClassFieldExpr) Pos ¶ added in v0.0.2
func (e *ClassFieldExpr) Pos() source.Pos
func (*ClassFieldExpr) String ¶ added in v0.0.2
func (e *ClassFieldExpr) String() string
func (*ClassFieldExpr) WriteCode ¶ added in v0.0.2
func (e *ClassFieldExpr) WriteCode(ctx *CodeWriteContext)
type ClassMemberExpr ¶ added in v0.0.2
type ClassMemberExpr struct {
NameExpr Expr
Methods []*FuncMethod
Block bool // written in the brace-block form `name { (…) … }`
LBrace source.Pos
RBrace source.Pos
Doc *ast.CommentGroup // doc comment preceding the member; or nil
}
ClassMemberExpr is a named method (or, inside `props {}`, a property) in a class body: a name plus one (single form) or several (brace-block form) FuncMethod overloads, sharing the func-with-methods/prop body syntax.
func (*ClassMemberExpr) End ¶ added in v0.0.2
func (e *ClassMemberExpr) End() source.Pos
func (*ClassMemberExpr) ExprNode ¶ added in v0.0.2
func (e *ClassMemberExpr) ExprNode()
func (*ClassMemberExpr) Pos ¶ added in v0.0.2
func (e *ClassMemberExpr) Pos() source.Pos
func (*ClassMemberExpr) String ¶ added in v0.0.2
func (e *ClassMemberExpr) String() string
func (*ClassMemberExpr) WriteCode ¶ added in v0.0.2
func (e *ClassMemberExpr) WriteCode(ctx *CodeWriteContext)
type ClassParentExpr ¶ added in v0.0.2
type ClassParentExpr struct {
Type Expr
Alias *IdentExpr // optional; nil when written without `: alias`
}
ClassParentExpr is one parent class, written as a `*Parent` spread body item: a parent type expression (an IdentExpr or SelectorExpr) with an optional alias written after a colon (`*Base: B`).
func (*ClassParentExpr) End ¶ added in v0.0.2
func (e *ClassParentExpr) End() source.Pos
func (*ClassParentExpr) Pos ¶ added in v0.0.2
func (e *ClassParentExpr) Pos() source.Pos
func (*ClassParentExpr) String ¶ added in v0.0.2
func (e *ClassParentExpr) String() string
func (*ClassParentExpr) WriteCode ¶ added in v0.0.2
func (e *ClassParentExpr) WriteCode(ctx *CodeWriteContext)
type ClassStmt ¶ added in v0.0.2
type ClassStmt struct {
ClassExpr
}
ClassStmt is the statement form `class Name { … }`. It compiles to `const Name = <class expression>`.
type ClosureExpr ¶
type ClosureExpr struct {
ast.NodeData
Params FuncParams
Return []*TypedIdentExpr
Lambda Token
Body Expr
}
ClosureExpr represents a function closure literal.
func EClosure ¶
func EClosure(params *FuncParams, lambdaPos source.Pos, lambdaToken token.Token, body Expr) *ClosureExpr
func (*ClosureExpr) End ¶
func (e *ClosureExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*ClosureExpr) ExprNode ¶
func (e *ClosureExpr) ExprNode()
func (*ClosureExpr) Pos ¶
func (e *ClosureExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*ClosureExpr) String ¶
func (e *ClosureExpr) String() string
func (*ClosureExpr) WriteCode ¶
func (e *ClosureExpr) WriteCode(ctx *CodeWriteContext)
type CodeBeginStmt ¶
type CodeBeginStmt struct {
Lit ast.Literal
RemoveSpace bool
// RemoveAllSpace reports the double-dash trim suffix (`{%--`), which strips
// ALL trailing whitespace (newlines included) from the preceding text.
RemoveAllSpace bool
}
CodeBeginStmt is the opening delimiter of a mixed/template code block, e.g. `{%` (or `{%-`). Lit holds the literal delimiter; RemoveSpace reports the `-` trim suffix (`{%-`), which strips trailing whitespace from the preceding text at run time. The statements that follow, up to the matching CodeEndStmt, are ordinary Gad code.
func SCodeBegin ¶
func SCodeBegin(lit ast.Literal, removeSpace bool) *CodeBeginStmt
func (CodeBeginStmt) End ¶
func (s CodeBeginStmt) End() source.Pos
func (CodeBeginStmt) Pos ¶
func (s CodeBeginStmt) Pos() source.Pos
func (CodeBeginStmt) SkipCode ¶ added in v0.0.2
func (CodeBeginStmt) SkipCode(ctx *CodeWriteContext) bool
func (CodeBeginStmt) StmtNode ¶
func (s CodeBeginStmt) StmtNode()
func (CodeBeginStmt) String ¶
func (s CodeBeginStmt) String() string
func (*CodeBeginStmt) WriteCode ¶
func (s *CodeBeginStmt) WriteCode(ctx *CodeWriteContext)
type CodeEndStmt ¶
type CodeEndStmt struct {
Lit ast.Literal
RemoveSpace bool
// RemoveAllSpace reports the double-dash trim prefix (`--%}`), which strips
// ALL leading whitespace (newlines included) from the following text.
RemoveAllSpace bool
}
CodeEndStmt is the closing delimiter of a mixed/template code block, e.g. `%}` (or `-%}`). Lit holds the literal delimiter; RemoveSpace reports the `-` trim prefix (`-%}`), which strips leading whitespace from the following text at run time.
func (CodeEndStmt) End ¶
func (s CodeEndStmt) End() source.Pos
func (CodeEndStmt) Pos ¶
func (s CodeEndStmt) Pos() source.Pos
func (CodeEndStmt) SkipCode ¶ added in v0.0.2
func (CodeEndStmt) SkipCode(ctx *CodeWriteContext) bool
func (CodeEndStmt) StmtNode ¶
func (s CodeEndStmt) StmtNode()
func (CodeEndStmt) String ¶
func (s CodeEndStmt) String() string
func (*CodeEndStmt) WriteCode ¶
func (s *CodeEndStmt) WriteCode(ctx *CodeWriteContext)
type CodeOption ¶
type CodeOption func(ctx *CodeWriteContext)
func CodeFormat ¶ added in v0.0.2
func CodeFormat() CodeOption
func CodeNewLineCalc ¶ added in v0.0.2
func CodeNewLineCalc(maxColumns int) CodeOption
CodeNewLineCalc enables the column-aware (NEW_LINE_CALC) formatting mode with the given column budget (<= 0 uses DefaultMaxColumns). List constructs stay inline unless they would overflow the budget.
func CodeTranspile ¶
func CodeTranspile(v *TranspileOptions) CodeOption
func CodeWithComments ¶ added in v0.0.2
func CodeWithComments(f *source.File, groups []*ast.CommentGroup) CodeOption
CodeWithComments threads the source comments (collected by parsing with ParseComments) into the formatter so they are preserved in the output. The file is required for line lookups (to tell trailing same-line comments from own-line ones).
func CodeWithFlags ¶ added in v0.0.2
func CodeWithFlags(flag CodeWriteContextFlag) CodeOption
func CodeWithPrefix ¶
func CodeWithPrefix(prefix string) CodeOption
type CodeStrLit ¶ added in v0.0.2
CodeStrLit represents a `code … end` code-string literal: a heredoc-like form whose body is captured verbatim (it is NOT parsed or template-interpolated) and compiled to a plain Str. The `code`/`end` fences signal to editors that the body is Gad source. Two forms are accepted, a block form
code
<body>
end
and the single-line form `code <body> end`. For the block form Value strips the least-indented body line's common indentation from every line (like a squiggly heredoc) so the embedded source dedents to its own baseline.
func (*CodeStrLit) End ¶ added in v0.0.2
func (e *CodeStrLit) End() source.Pos
End returns the position immediately after the closing `end`.
func (*CodeStrLit) ExprNode ¶ added in v0.0.2
func (e *CodeStrLit) ExprNode()
func (*CodeStrLit) Pos ¶ added in v0.0.2
func (e *CodeStrLit) Pos() source.Pos
Pos returns the position of the opening `code` keyword.
func (*CodeStrLit) String ¶ added in v0.0.2
func (e *CodeStrLit) String() string
func (*CodeStrLit) Value ¶ added in v0.0.2
func (e *CodeStrLit) Value() string
Value returns the body of the code-string with the fences removed and, for the block form, the common (minimum) body indentation stripped from each line.
func (*CodeStrLit) WriteCode ¶ added in v0.0.2
func (e *CodeStrLit) WriteCode(ctx *CodeWriteContext)
type CodeWriteContext ¶
type CodeWriteContext struct {
Stack []ast.Node
Depth int
Prefix string
Flags CodeWriteContextFlag
// MaxColumns is the line-width budget for the NEW_LINE_CALC mode (0 uses
// DefaultMaxColumns).
MaxColumns int
Transpile *TranspileOptions
CodeWriter
// contains filtered or unexported fields
}
func NewCodeWriteContext ¶
func NewCodeWriteContext(codeWriter CodeWriter, opt ...CodeOption) *CodeWriteContext
func (CodeWriteContext) Buffer ¶
func (ctx CodeWriteContext) Buffer(do func(ctx *CodeWriteContext)) string
func (*CodeWriteContext) Column ¶ added in v0.0.2
func (ctx *CodeWriteContext) Column() int
Column returns the current cursor column (0 when unknown).
func (*CodeWriteContext) CurrentPrefix ¶
func (ctx *CodeWriteContext) CurrentPrefix() string
func (*CodeWriteContext) DecideNewLine ¶ added in v0.0.2
func (ctx *CodeWriteContext) DecideNewLine(flag CodeWriteContextFlag, count int, inlineSep string, closing int, do func(i int)) bool
DecideNewLine reports whether a list construct's items should be written one per line. Without NEW_LINE_CALC it honours the per-construct force `flag`. With NEW_LINE_CALC it renders the items inline (separated by inlineSep) and wraps only when they would overflow MaxColumns (or already contain a newline). `closing` is the width of the trailing delimiter (e.g. 1 for `)`).
func (*CodeWriteContext) DecideNewLineFunc ¶ added in v0.0.2
func (ctx *CodeWriteContext) DecideNewLineFunc(flag CodeWriteContextFlag, count, closing int, renderInline func()) bool
DecideNewLineFunc is DecideNewLine for constructs whose inline form does not map to a uniform per-item callback: renderInline writes the whole inline body (to a throwaway writer during measurement).
func (*CodeWriteContext) HasPrefix ¶ added in v0.0.2
func (ctx *CodeWriteContext) HasPrefix() bool
func (*CodeWriteContext) Pop ¶
func (ctx *CodeWriteContext) Pop()
func (*CodeWriteContext) PrevPrefix ¶
func (ctx *CodeWriteContext) PrevPrefix() string
func (*CodeWriteContext) Printf ¶
func (ctx *CodeWriteContext) Printf(format string, args ...interface{})
func (*CodeWriteContext) Push ¶
func (ctx *CodeWriteContext) Push(n ast.Node)
func (*CodeWriteContext) Top ¶
func (ctx *CodeWriteContext) Top() ast.Node
func (*CodeWriteContext) With ¶
func (ctx *CodeWriteContext) With(n ast.Node, cb func() error) (err error)
func (CodeWriteContext) WithoutPrefix ¶
func (ctx CodeWriteContext) WithoutPrefix() *CodeWriteContext
func (*CodeWriteContext) WriteExprs ¶
func (ctx *CodeWriteContext) WriteExprs(sep string, expr ...Expr)
func (*CodeWriteContext) WriteGreedy ¶ added in v0.0.2
func (ctx *CodeWriteContext) WriteGreedy(count int, itemSep, breakConnector string, do func(i int))
WriteGreedy renders count items using the column-aware overflow rule: items are packed onto the current line with itemSep between them and continue on a new line only when the next item would overflow MaxColumns. breakConnector is appended to the line just before a wrap newline (e.g. "" to drop a comma, or " |" to keep a union bar). Continuation lines are written at the current ctx.Depth, so a caller wanting an extra indent level bumps Depth before calling. The caller positions the cursor for item 0 (this writes no leading newline).
func (*CodeWriteContext) WriteItems ¶ added in v0.0.2
func (ctx *CodeWriteContext) WriteItems(inNewLine bool, count int, do func(i int), done func(newLine bool))
func (*CodeWriteContext) WriteItemsSep ¶ added in v0.0.2
func (*CodeWriteContext) WriteLeadDoc ¶ added in v0.0.2
func (ctx *CodeWriteContext) WriteLeadDoc(g *ast.CommentGroup) bool
WriteLeadDoc emits g as a lead doc — the documented construct follows on its own (prefixed) line — when g has been claimed for node-based emission. It returns true when it emitted the doc. Nodes call this at the start of their WriteCode so the doc travels with the node.
func (*CodeWriteContext) WriteLine ¶
func (ctx *CodeWriteContext) WriteLine(s string)
func (*CodeWriteContext) WritePrefix ¶
func (ctx *CodeWriteContext) WritePrefix()
func (*CodeWriteContext) WritePrefixedLine ¶
func (ctx *CodeWriteContext) WritePrefixedLine()
func (*CodeWriteContext) WritePrevPrefix ¶
func (ctx *CodeWriteContext) WritePrevPrefix()
func (*CodeWriteContext) WriteSecondLine ¶
func (ctx *CodeWriteContext) WriteSecondLine()
func (*CodeWriteContext) WriteSemi ¶
func (ctx *CodeWriteContext) WriteSemi()
func (*CodeWriteContext) WriteSemiOrDoubleLine ¶
func (ctx *CodeWriteContext) WriteSemiOrDoubleLine()
func (*CodeWriteContext) WriteStmts ¶
func (ctx *CodeWriteContext) WriteStmts(stmt ...Stmt)
func (*CodeWriteContext) WriteTrailingDoc ¶ added in v0.0.2
func (ctx *CodeWriteContext) WriteTrailingDoc(g *ast.CommentGroup) bool
WriteTrailingDoc emits g as a trailing inline doc (` /// …`) on the current line when g is a claimed doc. Inline docs are kept on one line regardless of width. Returns true when it emitted the doc.
type CodeWriteContextFlag ¶ added in v0.0.2
type CodeWriteContextFlag uint16
const ( CodeWriteContextFlagNone CodeWriteContextFlag = 1 << iota CodeWriteContextFlagFormatArrayItemInNewLine CodeWriteContextFlagFormatDictItemInNewLine CodeWriteContextFlagFormatKeyValueArrayItemInNewLine CodeWriteContextFlagFormatCallParamsInNewLine CodeWriteContextFlagFormatParemValuesInNewLine CodeWriteContextFlagFormatDeclItemInNewLine CodeWriteContextFlagFormatMatchExprArmsInNewLine CodeWriteContextFlagFormatMatchStmtArmsInNewLine CodeWriteContextFlagFormatMethodInterfaceInNewLine // CodeWriteContextFlagFormatNewLineCalc (NEW_LINE_CALC) switches the // formatter from "force all to new lines" to column-aware wrapping: a list // construct stays inline unless it would overflow ctx.MaxColumns. It is not // part of CodeWriteContextFlagFormat. CodeWriteContextFlagFormatNewLineCalc CodeWriteContextFlagFormat = CodeWriteContextFlagFormatArrayItemInNewLine | CodeWriteContextFlagFormatDictItemInNewLine | CodeWriteContextFlagFormatKeyValueArrayItemInNewLine | CodeWriteContextFlagFormatCallParamsInNewLine | CodeWriteContextFlagFormatParemValuesInNewLine | CodeWriteContextFlagFormatDeclItemInNewLine | CodeWriteContextFlagFormatMatchExprArmsInNewLine | CodeWriteContextFlagFormatMatchStmtArmsInNewLine | CodeWriteContextFlagFormatMethodInterfaceInNewLine )
func (*CodeWriteContextFlag) Clear ¶ added in v0.0.2
func (b *CodeWriteContextFlag) Clear(flag CodeWriteContextFlag) *CodeWriteContextFlag
func (CodeWriteContextFlag) Has ¶ added in v0.0.2
func (b CodeWriteContextFlag) Has(flag ...CodeWriteContextFlag) bool
func (*CodeWriteContextFlag) Set ¶ added in v0.0.2
func (b *CodeWriteContextFlag) Set(flag CodeWriteContextFlag) *CodeWriteContextFlag
func (*CodeWriteContextFlag) Toggle ¶ added in v0.0.2
func (b *CodeWriteContextFlag) Toggle(flag CodeWriteContextFlag) *CodeWriteContextFlag
type CodeWriteSkiper ¶ added in v0.0.2
type CodeWriteSkiper interface {
SkipCode(ctx *CodeWriteContext) bool
}
type CodeWriter ¶
type CodeWriter interface {
io.Writer
WriteString(s ...string)
WriteSingleByte(b byte)
WriteRune(b rune)
WriteLine(s ...string)
WriteLines(l ...string)
}
func NewCodeWriter ¶
func NewCodeWriter(w io.Writer) CodeWriter
type Coder ¶
type Coder interface {
WriteCode(ctx *CodeWriteContext)
}
type ComprehensionClause ¶ added in v0.0.2
type ComprehensionClause struct {
For bool
Key *IdentExpr // for k, v in ...; nil when only a value var is given
Value *IdentExpr // for v in ...
Iterable Expr
Cond Expr // if cond
}
ComprehensionClause is one clause of a comprehension: a `for k, v in iter` generator (For == true) or an `if cond` filter (For == false).
func (*ComprehensionClause) String ¶ added in v0.0.2
func (c *ComprehensionClause) String() string
func (*ComprehensionClause) WriteCode ¶ added in v0.0.2
func (c *ComprehensionClause) WriteCode(ctx *CodeWriteContext)
type ComputedExpr ¶ added in v0.0.2
func (*ComputedExpr) End ¶ added in v0.0.2
func (e *ComputedExpr) End() source.Pos
func (*ComputedExpr) ExprNode ¶ added in v0.0.2
func (e *ComputedExpr) ExprNode()
func (*ComputedExpr) Pos ¶ added in v0.0.2
func (e *ComputedExpr) Pos() source.Pos
func (*ComputedExpr) String ¶ added in v0.0.2
func (e *ComputedExpr) String() string
func (*ComputedExpr) WriteCode ¶ added in v0.0.2
func (e *ComputedExpr) WriteCode(ctx *CodeWriteContext)
type CondExpr ¶
CondExpr represents a ternary conditional expression.
func (*CondExpr) WriteCode ¶
func (e *CondExpr) WriteCode(ctx *CodeWriteContext)
type ConfigOptions ¶
type ConfigStmt ¶
type ConfigStmt struct {
ConfigPos source.Pos
Elements []*KeyValuePairLit
Options ConfigOptions
}
func SConfig ¶
func SConfig(start source.Pos, opts ...*KeyValuePairLit) *ConfigStmt
func (*ConfigStmt) End ¶
func (c *ConfigStmt) End() source.Pos
func (*ConfigStmt) ParseElements ¶
func (c *ConfigStmt) ParseElements()
func (*ConfigStmt) Pos ¶
func (c *ConfigStmt) Pos() source.Pos
func (*ConfigStmt) SkipCode ¶ added in v0.0.2
func (c *ConfigStmt) SkipCode(ctx *CodeWriteContext) bool
func (*ConfigStmt) StmtNode ¶
func (c *ConfigStmt) StmtNode()
func (*ConfigStmt) String ¶
func (c *ConfigStmt) String() string
func (*ConfigStmt) WriteCode ¶
func (c *ConfigStmt) WriteCode(ctx *CodeWriteContext)
type DateTimeLit ¶ added in v0.0.2
type DateTimeLit struct {
// ValuePos is the position of the first digit.
ValuePos source.Pos
// Body is the numeric literal without the suffix letter.
Body string
// Kind selects the date/time/unix interpretation.
Kind DateTimeLitKind
}
DateTimeLit is a digit-suffix date/time literal: `20260131D` (date), `235955T` (time) or `1781609136U` (unix time). Body holds the numeric body without the suffix letter; it folds to a date or time value at compile time.
func (*DateTimeLit) End ¶ added in v0.0.2
func (e *DateTimeLit) End() source.Pos
End returns the position immediately after the suffix letter.
func (*DateTimeLit) ExprNode ¶ added in v0.0.2
func (e *DateTimeLit) ExprNode()
func (*DateTimeLit) Pos ¶ added in v0.0.2
func (e *DateTimeLit) Pos() source.Pos
Pos returns the position of the first digit.
func (*DateTimeLit) String ¶ added in v0.0.2
func (e *DateTimeLit) String() string
func (*DateTimeLit) WriteCode ¶ added in v0.0.2
func (e *DateTimeLit) WriteCode(ctx *CodeWriteContext)
type DateTimeLitKind ¶ added in v0.0.2
type DateTimeLitKind uint8
DateTimeLitKind discriminates the digit-suffix date/time literal forms.
const ( // CalendarDateLitKind is a `2006-01-02D` calendar-date literal. CalendarDateLitKind DateTimeLitKind = iota // TimeLitKind is a `2006-01-02T` time literal (midnight UTC, zoned). TimeLitKind // CalendarTimeLitKind is a `2006-01-02t` zone-less calendar-time literal. CalendarTimeLitKind // UnixTimeLitKind is a unix-seconds literal with a `U` suffix. UnixTimeLitKind )
func (DateTimeLitKind) Suffix ¶ added in v0.0.2
func (k DateTimeLitKind) Suffix() string
Suffix returns the source suffix letter for the kind.
type DecimalLit ¶
DecimalLit represents a floating point literal.
func (*DecimalLit) End ¶
func (e *DecimalLit) End() source.Pos
End returns the position of first character immediately after the node.
func (*DecimalLit) ExprNode ¶
func (e *DecimalLit) ExprNode()
func (*DecimalLit) Pos ¶
func (e *DecimalLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*DecimalLit) String ¶
func (e *DecimalLit) String() string
func (*DecimalLit) WriteCode ¶
func (e *DecimalLit) WriteCode(ctx *CodeWriteContext)
type DeclStmt ¶
type DeclStmt struct {
Decl // *GenDecl with VAR token
}
A DeclStmt node represents a declaration in a statement list.
type DeferStmt ¶ added in v0.0.2
type DeferStmt struct {
DeferPos source.Pos
Variant DeferVariant
Body *BlockStmt
Call Expr
// Block reports a `deferb*` statement, which runs at the end of the
// enclosing block instead of the enclosing function.
Block bool
// Inline reports that Body holds a single braceless shortcut statement
// (e.g. `defer x += 1`), rendered without surrounding braces.
Inline bool
}
DeferStmt represents a `defer`, `defer_ok` or `defer_err` statement. Exactly one of Body (`defer { ... }`) or Call (`defer handler` / `defer handler(x)`) is set. The handler runs when the enclosing function returns; inside it the locals `$ret` (return value) and `$err` (caught error) are available and may be modified.
func (*DeferStmt) End ¶ added in v0.0.2
End returns the position of first character immediately after the node.
func (*DeferStmt) Keyword ¶ added in v0.0.2
Keyword returns the source keyword for this statement (defer / defer_ok / deferb_err / ...).
func (*DeferStmt) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*DeferStmt) WriteCode ¶ added in v0.0.2
func (s *DeferStmt) WriteCode(ctx *CodeWriteContext)
type DeferVariant ¶ added in v0.0.2
type DeferVariant int
DeferVariant selects when a deferred handler runs.
const ( DeferAlways DeferVariant = iota // defer DeferOnOk // defer_ok: only when no error DeferOnErr // defer_err: only when an error occurred )
func (DeferVariant) String ¶ added in v0.0.2
func (v DeferVariant) String() string
type DictComprehension ¶ added in v0.0.2
type DictComprehension struct {
LBrace source.Pos
Elements []*DictElementLit
Clauses []*ComprehensionClause
RBrace source.Pos
}
DictComprehension represents `{k1: v1, [ke]: ve, ... for x in it if cond}`. Each iteration assigns every element into the dict being built; element keys may be static (`name:`) or computed (`[expr]:`). Inside value expressions the special variable `_` refers to the dict being built.
func (*DictComprehension) End ¶ added in v0.0.2
func (e *DictComprehension) End() source.Pos
End returns the position of first character immediately after the node.
func (*DictComprehension) ExprNode ¶ added in v0.0.2
func (e *DictComprehension) ExprNode()
func (*DictComprehension) Pos ¶ added in v0.0.2
func (e *DictComprehension) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*DictComprehension) String ¶ added in v0.0.2
func (e *DictComprehension) String() string
func (*DictComprehension) WriteCode ¶ added in v0.0.2
func (e *DictComprehension) WriteCode(ctx *CodeWriteContext)
type DictElementFuncExprs ¶ added in v0.0.2
type DictElementFuncExprs []*FuncDefLit
func (DictElementFuncExprs) Sort ¶ added in v0.0.2
func (l DictElementFuncExprs) Sort()
type DictElementLit ¶
type DictElementLit struct {
Key Expr
ColonPos source.Pos
Value Expr
// Spread, when set, marks a `*expr` merge element (`{a:1, *b}`); Key and
// Value are nil in that case.
Spread Expr
Doc *ast.CommentGroup // doc comment preceding the element; or nil
}
DictElementLit represents a map element.
func EDictElement ¶ added in v0.0.2
func EDictElement(key Expr, colonPos source.Pos, value Expr) *DictElementLit
func EDictElementStr ¶ added in v0.0.2
func EDictElementStr(key string, keyPos, colonPos source.Pos, value Expr) *DictElementLit
func (*DictElementLit) BuildKeyExpr ¶ added in v0.0.2
func (e *DictElementLit) BuildKeyExpr() Expr
func (*DictElementLit) End ¶
func (e *DictElementLit) End() source.Pos
End returns the position of first character immediately after the node.
func (*DictElementLit) ExprNode ¶
func (e *DictElementLit) ExprNode()
func (*DictElementLit) Func ¶
func (e *DictElementLit) Func() (f *FuncDefLit)
func (*DictElementLit) IsFunc ¶
func (e *DictElementLit) IsFunc() (ok bool)
func (*DictElementLit) Pos ¶
func (e *DictElementLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*DictElementLit) String ¶
func (e *DictElementLit) String() string
func (*DictElementLit) WriteCode ¶
func (e *DictElementLit) WriteCode(ctx *CodeWriteContext)
type DictExpr ¶
type DictExpr struct {
LBrace source.Pos
Elements []*DictElementLit
RBrace source.Pos
}
DictExpr represents a map literal.
func (*DictExpr) WriteCode ¶
func (e *DictExpr) WriteCode(ctx *CodeWriteContext)
type DotFileLit ¶
DotFileLit represents an @name literal.
func (*DotFileLit) End ¶
func (e *DotFileLit) End() source.Pos
End DotFileLit the position of first character immediately after the node.
func (*DotFileLit) ExprNode ¶
func (e *DotFileLit) ExprNode()
func (*DotFileLit) Pos ¶
func (e *DotFileLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*DotFileLit) String ¶
func (e *DotFileLit) String() string
func (*DotFileLit) WriteCode ¶
func (e *DotFileLit) WriteCode(ctx *CodeWriteContext)
type DotFileNameLit ¶
DotFileNameLit represents an @name literal.
func (*DotFileNameLit) End ¶
func (e *DotFileNameLit) End() source.Pos
End DotFileNameLit the position of first character immediately after the node.
func (*DotFileNameLit) ExprNode ¶
func (e *DotFileNameLit) ExprNode()
func (*DotFileNameLit) Pos ¶
func (e *DotFileNameLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*DotFileNameLit) String ¶
func (e *DotFileNameLit) String() string
func (*DotFileNameLit) WriteCode ¶
func (e *DotFileNameLit) WriteCode(ctx *CodeWriteContext)
type DurationLit ¶ added in v0.0.2
type DurationLit struct {
// PrefixPos is the position of the `dur` keyword.
PrefixPos source.Pos
// Body is the bare duration string (without the `dur ` prefix).
Body string
}
DurationLit is a `dur 1h25s` duration literal whose body is a bare Go duration string (e.g. "1h30m"). It compiles to a Duration value.
func (*DurationLit) End ¶ added in v0.0.2
func (e *DurationLit) End() source.Pos
End returns the position immediately after the duration body.
func (*DurationLit) ExprNode ¶ added in v0.0.2
func (e *DurationLit) ExprNode()
func (*DurationLit) Pos ¶ added in v0.0.2
func (e *DurationLit) Pos() source.Pos
Pos returns the position of the `dur` keyword.
func (*DurationLit) StrValue ¶ added in v0.0.2
func (e *DurationLit) StrValue() string
StrValue returns the duration string content.
func (*DurationLit) String ¶ added in v0.0.2
func (e *DurationLit) String() string
func (*DurationLit) WriteCode ¶ added in v0.0.2
func (e *DurationLit) WriteCode(ctx *CodeWriteContext)
type EmbedExpr ¶
EmbedExpr represents an embed expression that embeds external files or directories into the compiled program at compile time. It resolves to an EmbeddedNodeFS at runtime.
Syntax: embed(path [; namedParams...])
The path must be a single string or symbol literal specifying the file or directory to embed.
Named parameters (all optional):
- sources: array of string/symbol literals specifying source paths
- includes: array of string/symbol literals for file inclusion patterns
- excludes: array of string/symbol literals for file exclusion patterns
- includes_re: array of string/symbol literals for regex file inclusion patterns
- excludes_re: array of string/symbol literals for regex file exclusion patterns
- config_file: string/symbol literal pointing to a YAML config file with the above named params
- tree: flag (no value) to embed directory tree recursively
Example:
embed("file.txt")
embed("dir"; tree)
embed("dir"; includes=["*.go"], excludes=["*_test.go"])
embed("dir"; sources=["a", "b"], tree)
embed("dir"; config_file="embed.yaml")
func (*EmbedExpr) ConfigFile ¶ added in v0.0.2
ConfigFile returns the config file path from the "config_file" named parameter.
func (*EmbedExpr) Excludes ¶ added in v0.0.2
Excludes returns the list of exclusion patterns from the "excludes" named parameter.
func (*EmbedExpr) ExcludesRe ¶ added in v0.0.2
ExcludesRe returns the list of regex exclusion patterns from the "excludes_re" named parameter.
func (*EmbedExpr) Includes ¶ added in v0.0.2
Includes returns the list of inclusion patterns from the "includes" named parameter.
func (*EmbedExpr) IncludesRe ¶ added in v0.0.2
IncludesRe returns the list of regex inclusion patterns from the "includes_re" named parameter.
func (*EmbedExpr) Path ¶
Path returns the file or directory path specified as the first argument to embed.
func (*EmbedExpr) Sources ¶ added in v0.0.2
Sources returns the list of source paths from the "sources" named parameter.
func (*EmbedExpr) Tree ¶ added in v0.0.2
Tree returns true if the "tree" flag is set, indicating recursive directory embedding.
func (*EmbedExpr) WriteCode ¶
func (e *EmbedExpr) WriteCode(ctx *CodeWriteContext)
type EmptyStmt ¶
EmptyStmt represents an empty statement.
func (*EmptyStmt) WriteCode ¶
func (s *EmptyStmt) WriteCode(*CodeWriteContext)
type EnumExpr ¶ added in v0.0.2
type EnumExpr struct {
EnumToken TokenLit
NameExpr Expr
Fields []*EnumFieldExpr
LBrace source.Pos
RBrace source.Pos
Doc *ast.CommentGroup // doc comment preceding the enum; or nil
}
EnumExpr is an enum literal: `enum [Name] { field, … }`. It compiles to an Enum constant whose field values are computed at compile time (incrementing integers by default, bit flags under `bit`, or explicit expressions). NameExpr is nil for an anonymous, expression-form enum.
func (*EnumExpr) WriteCode ¶ added in v0.0.2
func (e *EnumExpr) WriteCode(ctx *CodeWriteContext)
type EnumFieldExpr ¶ added in v0.0.2
type EnumFieldExpr struct {
Bit bool // written with a leading `bit`
Sign token.Token // token.Add, token.Sub, or token.Illegal for none
SignPos source.Pos
Name *IdentExpr
Assign source.Pos
Value Expr // explicit value; nil when defaulted
Doc *ast.CommentGroup // doc comment preceding the field; or nil
}
EnumFieldExpr is one field of an enum body: an optional `bit` prefix, an optional `+`/`-` sign, the field Name (`_` is a placeholder that advances the running value but is not added to the enum) and an optional explicit `= Value` (which may reference earlier fields, e.g. `All = Read | Write`).
func (*EnumFieldExpr) End ¶ added in v0.0.2
func (e *EnumFieldExpr) End() source.Pos
func (*EnumFieldExpr) ExprNode ¶ added in v0.0.2
func (e *EnumFieldExpr) ExprNode()
func (*EnumFieldExpr) Pos ¶ added in v0.0.2
func (e *EnumFieldExpr) Pos() source.Pos
func (*EnumFieldExpr) String ¶ added in v0.0.2
func (e *EnumFieldExpr) String() string
func (*EnumFieldExpr) WriteCode ¶ added in v0.0.2
func (e *EnumFieldExpr) WriteCode(ctx *CodeWriteContext)
type EnumStmt ¶ added in v0.0.2
type EnumStmt struct {
EnumExpr
}
EnumStmt is the statement form `enum Name { … }`. It compiles to `const Name = <enum expression>`.
type ExportStmt ¶ added in v0.0.2
type ExportStmt struct {
TokenPos source.Pos
KeyExpr Expr
ValueExpr Expr
Doc *ast.CommentGroup // doc comment preceding the export; or nil
}
func (*ExportStmt) End ¶ added in v0.0.2
func (s *ExportStmt) End() source.Pos
func (*ExportStmt) Pos ¶ added in v0.0.2
func (s *ExportStmt) Pos() source.Pos
func (*ExportStmt) StmtNode ¶ added in v0.0.2
func (s *ExportStmt) StmtNode()
func (*ExportStmt) String ¶ added in v0.0.2
func (s *ExportStmt) String() string
func (*ExportStmt) WriteCode ¶ added in v0.0.2
func (s *ExportStmt) WriteCode(ctx *CodeWriteContext)
type ExprSelector ¶
type ExprStmt ¶
type ExprStmt struct {
Expr Expr
}
ExprStmt represents an expression statement.
func (*ExprStmt) WriteCode ¶
func (s *ExprStmt) WriteCode(ctx *CodeWriteContext)
type FinallyStmt ¶
FinallyStmt represents an finally statement.
func (*FinallyStmt) End ¶
func (s *FinallyStmt) End() source.Pos
End returns the position of first character immediately after the node.
func (*FinallyStmt) Pos ¶
func (s *FinallyStmt) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*FinallyStmt) StmtNode ¶
func (s *FinallyStmt) StmtNode()
func (*FinallyStmt) String ¶
func (s *FinallyStmt) String() string
func (*FinallyStmt) WriteCode ¶
func (s *FinallyStmt) WriteCode(ctx *CodeWriteContext)
type FlagLit ¶
FlagLit represents a yes literal.
func (*FlagLit) WriteCode ¶
func (e *FlagLit) WriteCode(ctx *CodeWriteContext)
type FloatLit ¶
FloatLit represents a floating point literal.
func (*FloatLit) WriteCode ¶
func (e *FloatLit) WriteCode(ctx *CodeWriteContext)
type ForInStmt ¶
type ForInStmt struct {
ForPos source.Pos
Key *IdentExpr
Value *IdentExpr
Iterable Expr
Body *BlockStmt
Else *BlockStmt
}
ForInStmt represents a for-in statement.
func (*ForInStmt) WriteCode ¶
func (s *ForInStmt) WriteCode(ctx *CodeWriteContext)
type ForStmt ¶
ForStmt represents a for statement.
func (*ForStmt) WriteCode ¶
func (s *ForStmt) WriteCode(ctx *CodeWriteContext)
type FuncDefLit ¶ added in v0.0.2
type FuncDefLit struct {
Expr
}
func EDictElementClosure ¶
func EDictElementClosure(c *ClosureExpr) *FuncDefLit
func EDictElementFunc ¶
func EDictElementFunc(f *FuncExpr) *FuncDefLit
func (*FuncDefLit) Closure ¶ added in v0.0.2
func (e *FuncDefLit) Closure() (c *ClosureExpr)
func (*FuncDefLit) Func ¶ added in v0.0.2
func (e *FuncDefLit) Func() (f *FuncExpr)
func (*FuncDefLit) Params ¶ added in v0.0.2
func (e *FuncDefLit) Params() *FuncParams
type FuncExpr ¶
type FuncExpr struct {
Type *FuncType
Body *BlockStmt
LambdaPos source.Pos
BodyExpr Expr
Doc *ast.CommentGroup // associated doc comment (`/?`, `/??`, `/???`); or nil
// Override reports whether a `met` declaration was written `met ~name(…)`,
// so re-adding an existing method signature replaces it instead of erroring.
Override bool
}
FuncExpr represents a function literal.
func (*FuncExpr) WriteCode ¶
func (e *FuncExpr) WriteCode(ctx *CodeWriteContext)
type FuncHeader ¶ added in v0.0.2
type FuncHeader struct {
NameExpr Expr
Params FuncParams
Return []*TypedIdentExpr
}
FuncHeader is the shared shape of a function/method signature: an optional name, a parameter list and an optional return-type list. It is embedded in FuncType and FuncHeaderExpr.
func (*FuncHeader) End ¶ added in v0.0.2
func (e *FuncHeader) End() source.Pos
End returns the position of first character immediately after the node.
func (*FuncHeader) Name ¶ added in v0.0.2
func (e *FuncHeader) Name() string
func (*FuncHeader) NameIdent ¶ added in v0.0.2
func (e *FuncHeader) NameIdent() *IdentExpr
func (*FuncHeader) Pos ¶ added in v0.0.2
func (e *FuncHeader) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*FuncHeader) String ¶ added in v0.0.2
func (e *FuncHeader) String() string
func (*FuncHeader) WriteCode ¶ added in v0.0.2
func (e *FuncHeader) WriteCode(ctx *CodeWriteContext)
WriteCode renders the header (name + params + return) routing the parameter list through FuncParams.WriteCode so it participates in formatting.
type FuncHeaderExpr ¶ added in v0.0.2
type FuncHeaderExpr struct {
OpenPos source.Pos // `<`
ClosePos source.Pos // `>`
Doc *ast.CommentGroup // doc comment preceding the header (in a meti); or nil
FuncHeader
}
FuncHeaderExpr is a function-header value expression written between angle brackets: `<()>`, `<(v int)>`, `<(v int) <x uint|int>>`. It evaluates to a FunctionHeader value describing a signature.
func (*FuncHeaderExpr) End ¶ added in v0.0.2
func (e *FuncHeaderExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*FuncHeaderExpr) ExprNode ¶ added in v0.0.2
func (e *FuncHeaderExpr) ExprNode()
func (*FuncHeaderExpr) Pos ¶ added in v0.0.2
func (e *FuncHeaderExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*FuncHeaderExpr) String ¶ added in v0.0.2
func (e *FuncHeaderExpr) String() string
func (*FuncHeaderExpr) WriteCode ¶ added in v0.0.2
func (e *FuncHeaderExpr) WriteCode(ctx *CodeWriteContext)
type FuncMethod ¶ added in v0.0.2
type FuncMethod struct {
Params FuncParams
Return []*TypedIdentExpr
Body *BlockStmt
LambdaPos source.Pos
BodyExpr Expr
Doc *ast.CommentGroup // doc comment preceding the method header; or nil
// Override reports whether the method header was prefixed with `~`, so
// re-adding an existing signature replaces it instead of erroring.
Override bool
}
func (*FuncMethod) End ¶ added in v0.0.2
func (m *FuncMethod) End() source.Pos
func (*FuncMethod) Func ¶ added in v0.0.2
func (m *FuncMethod) Func() *FuncExpr
func (*FuncMethod) Pos ¶ added in v0.0.2
func (m *FuncMethod) Pos() source.Pos
func (*FuncMethod) String ¶ added in v0.0.2
func (m *FuncMethod) String() string
func (*FuncMethod) WriteCode ¶ added in v0.0.2
func (m *FuncMethod) WriteCode(ctx *CodeWriteContext)
type FuncParams ¶
type FuncParams struct {
LParen source.Pos
Args ArgsList
NamedArgs NamedArgsList
RParen source.Pos
}
FuncParams represents a function paramsw.
func NewFuncParams ¶ added in v0.0.2
func NewFuncParams(lparen, rparen source.Pos, v ...any) *FuncParams
func (*FuncParams) Caller ¶
func (n *FuncParams) Caller() (c *CallArgs)
func (*FuncParams) End ¶
func (n *FuncParams) End() (pos source.Pos)
End returns the position of first character immediately after the node.
func (*FuncParams) Pos ¶
func (n *FuncParams) Pos() (pos source.Pos)
Pos returns the position of first character belonging to the node.
func (*FuncParams) String ¶
func (n *FuncParams) String() string
func (FuncParams) WithNamedValuesNil ¶
func (n FuncParams) WithNamedValuesNil() (c *FuncParams)
func (*FuncParams) WriteCode ¶ added in v0.0.2
func (n *FuncParams) WriteCode(ctx *CodeWriteContext)
WriteCode renders the parameter list, wrapping one parameter per line when NEW_LINE_CALC decides it overflows (no comma between wrapped items). The named section is introduced by `;`; a typed param keeps its ident and type on one line (each item is a single rendered string).
type FuncStmt ¶ added in v0.0.2
type FuncStmt struct {
Func *FuncExpr
}
func (*FuncStmt) End ¶ added in v0.0.2
End returns the position of first character immediately after the node.
func (*FuncStmt) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*FuncStmt) WriteCode ¶ added in v0.0.2
func (f *FuncStmt) WriteCode(ctx *CodeWriteContext)
type FuncType ¶
type FuncType struct {
Token TokenLit
FuncPos source.Pos
FuncHeader
}
FuncType represents a function type definition.
func ProxyFuncType ¶
func ProxyFuncType() *FuncType
type FuncWithMethodsExpr ¶ added in v0.0.2
type FuncWithMethodsExpr struct {
FuncToken TokenLit
LBrace source.Pos
RBrace source.Pos
NameExpr Expr
Methods []*FuncMethod
Doc *ast.CommentGroup // doc comment preceding the func; or nil
}
FuncWithMethodsExpr represents the function with methods expression.
func (*FuncWithMethodsExpr) End ¶ added in v0.0.2
func (e *FuncWithMethodsExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*FuncWithMethodsExpr) ExprNode ¶ added in v0.0.2
func (e *FuncWithMethodsExpr) ExprNode()
func (*FuncWithMethodsExpr) Funcs ¶ added in v0.0.2
func (e *FuncWithMethodsExpr) Funcs() (f Exprs)
func (*FuncWithMethodsExpr) NameIdent ¶ added in v0.0.2
func (e *FuncWithMethodsExpr) NameIdent() *IdentExpr
func (*FuncWithMethodsExpr) Pos ¶ added in v0.0.2
func (e *FuncWithMethodsExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*FuncWithMethodsExpr) String ¶ added in v0.0.2
func (e *FuncWithMethodsExpr) String() string
func (*FuncWithMethodsExpr) WriteCode ¶ added in v0.0.2
func (e *FuncWithMethodsExpr) WriteCode(ctx *CodeWriteContext)
type FuncWithMethodsStmt ¶ added in v0.0.2
type FuncWithMethodsStmt struct {
FuncWithMethodsExpr
}
func (FuncWithMethodsStmt) StmtNode ¶ added in v0.0.2
func (f FuncWithMethodsStmt) StmtNode()
type GenDecl ¶
type GenDecl struct {
TokPos source.Pos // position of Tok
Tok token.Token // Var
Lparen source.Pos // position of '(', if any
Specs []Spec
Rparen source.Pos // position of ')', if any
Doc *ast.CommentGroup // associated doc comment (`/?`, `/??`, `/???`); or nil
}
A GenDecl node (generic declaration node) represents a variable declaration. A valid Lparen position (Lparen.Line > 0) indicates a parenthesized declaration.
Relationship between Tok value and Specs element type:
token.Var *ValueSpec
func (*GenDecl) Params ¶ added in v0.0.2
func (d *GenDecl) Params() (positional []*ParamSpec, named []*NamedParamSpec)
func (*GenDecl) WriteCode ¶
func (d *GenDecl) WriteCode(ctx *CodeWriteContext)
type GlobalsLit ¶ added in v0.0.2
GlobalsLit is the `@g` keyword: a short form of the `globals()` builtin call that yields the host-provided globals object.
func (*GlobalsLit) End ¶ added in v0.0.2
func (e *GlobalsLit) End() source.Pos
End returns the position of first character immediately after the node.
func (*GlobalsLit) ExprNode ¶ added in v0.0.2
func (e *GlobalsLit) ExprNode()
func (*GlobalsLit) Pos ¶ added in v0.0.2
func (e *GlobalsLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*GlobalsLit) String ¶ added in v0.0.2
func (e *GlobalsLit) String() string
func (*GlobalsLit) WriteCode ¶ added in v0.0.2
func (e *GlobalsLit) WriteCode(ctx *CodeWriteContext)
type HeredocLit ¶ added in v0.0.2
HeredocLit represents a non-raw heredoc string literal delimited by a fence of three or more double quotes (`"""`). It shares RawHeredocLit's fencing, opening-line and common-indentation handling, but, like a double-quoted StrLit, it interprets escape sequences (e.g. \n, \t, \", \xFF, \uXXXX) in its content.
func (*HeredocLit) ContentPos ¶ added in v0.0.2
func (e *HeredocLit) ContentPos() source.Pos
ContentPos returns the source position of the first byte of RawContent.
func (*HeredocLit) End ¶ added in v0.0.2
func (e *HeredocLit) End() source.Pos
End returns the position of first character immediately after the node.
func (*HeredocLit) ExprNode ¶ added in v0.0.2
func (e *HeredocLit) ExprNode()
func (*HeredocLit) Pos ¶ added in v0.0.2
func (e *HeredocLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*HeredocLit) RawContent ¶ added in v0.0.2
func (e *HeredocLit) RawContent() string
RawContent returns the heredoc body with the surrounding quote fences, the opening fence line and the closing line removed, but with interior indentation preserved and escape sequences left unprocessed. It keeps a 1:1 byte correspondence with the original source starting at ContentPos.
func (*HeredocLit) String ¶ added in v0.0.2
func (e *HeredocLit) String() string
func (*HeredocLit) StripCount ¶ added in v0.0.2
func (e *HeredocLit) StripCount() int
StripCount returns the common leading indentation (spaces/tabs) removed from each content line by Value. It is zero for the single-line form (no newline after the opening fence), which is not indentation-stripped.
func (*HeredocLit) Value ¶ added in v0.0.2
func (e *HeredocLit) Value() string
func (*HeredocLit) WriteCode ¶ added in v0.0.2
func (e *HeredocLit) WriteCode(ctx *CodeWriteContext)
type IdentExpr ¶
IdentExpr represents an identifier.
func EEmptyIdent ¶
func IdentOfSelector ¶ added in v0.0.2
func (*IdentExpr) WriteCode ¶
func (e *IdentExpr) WriteCode(ctx *CodeWriteContext)
type IdentList ¶
IdentList represents a list of identifiers.
type IfStmt ¶
type IfStmt struct {
IfPos source.Pos
Init Stmt
Cond Expr
Body *BlockStmt
Else Stmt // else branch; or nil
}
IfStmt represents an if statement.
func (*IfStmt) WriteCode ¶
func (s *IfStmt) WriteCode(ctx *CodeWriteContext)
type ImportExpr ¶
type ImportExpr struct {
CallExpr
}
ImportExpr represents an import expression
func (*ImportExpr) Build ¶ added in v0.0.2
func (e *ImportExpr) Build() (moduleName string, args CallArgs)
func (*ImportExpr) ExprNode ¶
func (e *ImportExpr) ExprNode()
func (*ImportExpr) ModuleName ¶
func (e *ImportExpr) ModuleName() string
func (*ImportExpr) WriteCode ¶
func (e *ImportExpr) WriteCode(ctx *CodeWriteContext)
type IncDecStmt ¶
IncDecStmt represents increment or decrement statement.
func (*IncDecStmt) End ¶
func (s *IncDecStmt) End() source.Pos
End returns the position of first character immediately after the node.
func (*IncDecStmt) Pos ¶
func (s *IncDecStmt) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*IncDecStmt) StmtNode ¶
func (s *IncDecStmt) StmtNode()
func (*IncDecStmt) String ¶
func (s *IncDecStmt) String() string
func (*IncDecStmt) WriteCode ¶
func (s *IncDecStmt) WriteCode(ctx *CodeWriteContext)
type IndexExpr ¶
IndexExpr represents an index expression.
func (*IndexExpr) WriteCode ¶
func (e *IndexExpr) WriteCode(ctx *CodeWriteContext)
type IntLit ¶
IntLit represents an integer literal.
func (*IntLit) WriteCode ¶
func (e *IntLit) WriteCode(ctx *CodeWriteContext)
type InterfaceExpr ¶ added in v0.0.2
type InterfaceExpr struct {
InterfaceToken TokenLit
NameExpr Expr // *IdentExpr or nil (anonymous)
Parents []Expr // *Parent spreads — no alias
ExtendsDoc *ast.CommentGroup
Members []*InterfaceMemberExpr // fields, getters, setters, props (source order)
Methods []*InterfaceMethodExpr // required methods (one or more signatures each)
LBrace source.Pos
RBrace source.Pos
Doc *ast.CommentGroup // doc comment preceding the interface; or nil
}
InterfaceExpr is an interface literal describing a structural contract:
interface [Name] {
*Parent, … // parent interfaces (spread)
field, field Type // typed fields
get g, set s, prop p // accessors
method(params) <return> // required methods (func-header shape)
parse { (params) <return> } // meti-style headers grouped as `parse`
}
func (*InterfaceExpr) End ¶ added in v0.0.2
func (e *InterfaceExpr) End() source.Pos
func (*InterfaceExpr) ExprNode ¶ added in v0.0.2
func (e *InterfaceExpr) ExprNode()
func (*InterfaceExpr) NameIdent ¶ added in v0.0.2
func (e *InterfaceExpr) NameIdent() *IdentExpr
NameIdent returns the interface name identifier, or nil when anonymous.
func (*InterfaceExpr) Pos ¶ added in v0.0.2
func (e *InterfaceExpr) Pos() source.Pos
func (*InterfaceExpr) String ¶ added in v0.0.2
func (e *InterfaceExpr) String() string
func (*InterfaceExpr) WriteCode ¶ added in v0.0.2
func (e *InterfaceExpr) WriteCode(ctx *CodeWriteContext)
type InterfaceMemberExpr ¶ added in v0.0.2
type InterfaceMemberExpr struct {
Kind InterfaceMemberKind
KwPos source.Pos // position of get/set/prop keyword; NoPos for a field
Name *TypedIdentExpr
Doc *ast.CommentGroup
}
InterfaceMemberExpr is a field/getter/setter/property in an interface body: an optional `get`/`set`/`prop` keyword followed by a typed ident (`name` or `name Type1|Type2`).
func (*InterfaceMemberExpr) End ¶ added in v0.0.2
func (e *InterfaceMemberExpr) End() source.Pos
func (*InterfaceMemberExpr) ExprNode ¶ added in v0.0.2
func (e *InterfaceMemberExpr) ExprNode()
func (*InterfaceMemberExpr) Pos ¶ added in v0.0.2
func (e *InterfaceMemberExpr) Pos() source.Pos
func (*InterfaceMemberExpr) String ¶ added in v0.0.2
func (e *InterfaceMemberExpr) String() string
func (*InterfaceMemberExpr) WriteCode ¶ added in v0.0.2
func (e *InterfaceMemberExpr) WriteCode(ctx *CodeWriteContext)
type InterfaceMemberKind ¶ added in v0.0.2
type InterfaceMemberKind uint8
InterfaceMemberKind selects the kind of a simple (name + optional types) interface body member: a field, or a getter/setter/property accessor.
const ( // IfaceField is a typed field: `name` or `name Type`. IfaceField InterfaceMemberKind = iota // IfaceGet is a getter: `get name` or `get name Type`. IfaceGet // IfaceSet is a setter: `set name` or `set name Type`. IfaceSet // IfaceProp is a property (getter + setter shortcut): `prop name [Type]`. IfaceProp )
func (InterfaceMemberKind) String ¶ added in v0.0.2
func (k InterfaceMemberKind) String() string
type InterfaceMethodExpr ¶ added in v0.0.2
type InterfaceMethodExpr struct {
NameExpr *IdentExpr
Headers []*FuncHeaderExpr // the signature(s), anonymous (the name is on NameExpr)
Block bool // written in the brace-block form
LBrace source.Pos
RBrace source.Pos
Doc *ast.CommentGroup
}
InterfaceMethodExpr is a required method of an interface: a name and one or more signatures (func-header shape, without the `<…>` brackets). Written either single `name(params) <return>` or block `name { (params) <return>, … }` (the block form is how the `parse` example groups several signatures).
func (*InterfaceMethodExpr) End ¶ added in v0.0.2
func (e *InterfaceMethodExpr) End() source.Pos
func (*InterfaceMethodExpr) ExprNode ¶ added in v0.0.2
func (e *InterfaceMethodExpr) ExprNode()
func (*InterfaceMethodExpr) Pos ¶ added in v0.0.2
func (e *InterfaceMethodExpr) Pos() source.Pos
func (*InterfaceMethodExpr) String ¶ added in v0.0.2
func (e *InterfaceMethodExpr) String() string
func (*InterfaceMethodExpr) WriteCode ¶ added in v0.0.2
func (e *InterfaceMethodExpr) WriteCode(ctx *CodeWriteContext)
type InterfaceStmt ¶ added in v0.0.2
type InterfaceStmt struct {
InterfaceExpr
}
InterfaceStmt is the statement form `interface Name { … }`, which binds a const to the interface value.
func (*InterfaceStmt) StmtNode ¶ added in v0.0.2
func (s *InterfaceStmt) StmtNode()
type IsMainLit ¶ added in v0.0.2
IsMainLit represents an @main literal.
func (*IsMainLit) End ¶ added in v0.0.2
End IsMainLit the position of first character immediately after the node.
func (*IsMainLit) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*IsMainLit) WriteCode ¶ added in v0.0.2
func (e *IsMainLit) WriteCode(ctx *CodeWriteContext)
type KeyValueArrayLit ¶
type KeyValueArrayLit struct {
LParen source.Pos
Elements Exprs
RParen source.Pos
// Curly marks the TypeScript-style `{ key, key2: target, **rest }`
// destructuring form (as opposed to the `(; … )` form). It only affects
// rendering; the elements are stored key-on-the-left (source key in Key,
// target in Value), which the dict-destructuring compiler reads directly.
Curly bool
}
KeyValueArrayLit represents a key value array literal.
func (*KeyValueArrayLit) End ¶
func (e *KeyValueArrayLit) End() source.Pos
End returns the position of first character immediately after the node.
func (*KeyValueArrayLit) ExprNode ¶
func (e *KeyValueArrayLit) ExprNode()
func (*KeyValueArrayLit) Pos ¶
func (e *KeyValueArrayLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*KeyValueArrayLit) String ¶
func (e *KeyValueArrayLit) String() string
func (*KeyValueArrayLit) ToMultiParenExpr ¶
func (e *KeyValueArrayLit) ToMultiParenExpr() *MultiParenExpr
func (*KeyValueArrayLit) WriteCode ¶
func (e *KeyValueArrayLit) WriteCode(ctx *CodeWriteContext)
type KeyValueLit ¶
KeyValueLit represents a key value element.
func KV ¶
func KV(key Expr, value ...Expr) *KeyValueLit
func (*KeyValueLit) ElementString ¶
func (e *KeyValueLit) ElementString() string
func (*KeyValueLit) End ¶
func (e *KeyValueLit) End() source.Pos
End returns the position of first character immediately after the node.
func (*KeyValueLit) ExprNode ¶
func (e *KeyValueLit) ExprNode()
func (*KeyValueLit) Pos ¶
func (e *KeyValueLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*KeyValueLit) String ¶
func (e *KeyValueLit) String() string
func (*KeyValueLit) WriteCode ¶
func (e *KeyValueLit) WriteCode(ctx *CodeWriteContext)
type KeyValuePairLit ¶
type KeyValuePairLit struct {
Key Expr
Value Expr
// Colon reports that the key and value were separated by ':' instead of
// '='. It is used by the dict-destructuring target `(;name:key, ...)` where
// the value names the source dict key to read into the variable `name`.
Colon bool
}
KeyValuePairLit represents a key value pair element.
func KVp ¶
func KVp(key Expr, value ...Expr) *KeyValuePairLit
func (*KeyValuePairLit) End ¶
func (e *KeyValuePairLit) End() source.Pos
End returns the position of first character immediately after the node.
func (*KeyValuePairLit) ExprNode ¶
func (e *KeyValuePairLit) ExprNode()
func (*KeyValuePairLit) Func ¶ added in v0.0.2
func (e *KeyValuePairLit) Func() (f *FuncDefLit)
func (*KeyValuePairLit) IsFunc ¶ added in v0.0.2
func (e *KeyValuePairLit) IsFunc() (ok bool)
func (*KeyValuePairLit) Pos ¶
func (e *KeyValuePairLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*KeyValuePairLit) String ¶
func (e *KeyValuePairLit) String() string
func (*KeyValuePairLit) WriteCode ¶
func (e *KeyValuePairLit) WriteCode(ctx *CodeWriteContext)
type MatchArm ¶ added in v0.0.2
type MatchArm struct {
Conds []Expr // conditions (OR); empty for the else arm
Result Expr // `conds: result`
Body *BlockStmt // `conds { body }`
}
MatchArm is a single arm of a MatchExpr. A normal arm has one or more Conds, matched against the subject with OR semantics (`A, B: …`); the `else` arm has no Conds. Exactly one of Result (expression form `conds: result`) or Body (statement form `conds { body }`) is set.
func (*MatchArm) IsElse ¶ added in v0.0.2
IsElse reports whether this arm is the default `else` arm.
func (*MatchArm) WriteCode ¶ added in v0.0.2
func (a *MatchArm) WriteCode(ctx *CodeWriteContext)
type MatchExpr ¶ added in v0.0.2
type MatchExpr struct {
MatchPos source.Pos
Expr Expr // subject
Arms []*MatchArm
LBrace source.Pos
RBrace source.Pos
}
MatchExpr represents a PHP8-like match: `match subject { cond: result, ... }` (expression form, yields a value) or `match subject { cond { body }, ... }` (statement form, runs the matching block). Each arm holds one or more conditions compared against the subject with strict equality; the first arm with a matching condition wins. An optional `else` arm is the default. When nothing matches and there is no `else`, the match yields nil.
func (*MatchExpr) End ¶ added in v0.0.2
End returns the position of first character immediately after the node.
func (*MatchExpr) IsStmt ¶ added in v0.0.2
IsStmt reports whether the match uses statement-form (block) arms.
func (*MatchExpr) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*MatchExpr) WriteCode ¶ added in v0.0.2
func (e *MatchExpr) WriteCode(ctx *CodeWriteContext)
type MethodExpr ¶ added in v0.0.2
type MethodExpr struct {
Expr
}
func EMethod ¶ added in v0.0.2
func EMethod(expr *FuncExpr) *MethodExpr
type MethodInterfaceExpr ¶ added in v0.0.2
type MethodInterfaceExpr struct {
MetiToken TokenLit
NameExpr Expr
LBrace source.Pos
RBrace source.Pos
Headers []*FuncHeaderExpr
// Shortcut reports the single-method `meti <header>` form (one header, no
// braces); it is preserved by WriteCode.
Shortcut bool
Doc *ast.CommentGroup // doc comment preceding the meti; or nil
}
MethodInterfaceExpr is a set of required function headers introduced by the `meti` keyword: `meti { () }`, `meti { (), (v) <int> }`, `meti Name { … }`. Each header is a FuncHeaderExpr written without the surrounding angle brackets.
func (*MethodInterfaceExpr) End ¶ added in v0.0.2
func (e *MethodInterfaceExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*MethodInterfaceExpr) ExprNode ¶ added in v0.0.2
func (e *MethodInterfaceExpr) ExprNode()
func (*MethodInterfaceExpr) NameIdent ¶ added in v0.0.2
func (e *MethodInterfaceExpr) NameIdent() *IdentExpr
func (*MethodInterfaceExpr) Pos ¶ added in v0.0.2
func (e *MethodInterfaceExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*MethodInterfaceExpr) String ¶ added in v0.0.2
func (e *MethodInterfaceExpr) String() string
func (*MethodInterfaceExpr) WriteCode ¶ added in v0.0.2
func (e *MethodInterfaceExpr) WriteCode(ctx *CodeWriteContext)
type MethodInterfaceStmt ¶ added in v0.0.2
type MethodInterfaceStmt struct {
MethodInterfaceExpr
}
MethodInterfaceStmt is the statement form of a method interface, e.g. `meti Name { () }`, which binds the interface to a const.
func (MethodInterfaceStmt) StmtNode ¶ added in v0.0.2
func (s MethodInterfaceStmt) StmtNode()
type MixedTextExpr ¶
type MixedTextExpr struct {
StartLit ast.Literal
EndLit ast.Literal
Stmt MixedTextStmt
}
func (*MixedTextExpr) End ¶
func (e *MixedTextExpr) End() source.Pos
func (*MixedTextExpr) ExprNode ¶
func (e *MixedTextExpr) ExprNode()
func (*MixedTextExpr) Pos ¶
func (e *MixedTextExpr) Pos() source.Pos
func (*MixedTextExpr) String ¶
func (e *MixedTextExpr) String() string
func (*MixedTextExpr) WriteCode ¶
func (e *MixedTextExpr) WriteCode(ctx *CodeWriteContext)
type MixedTextStmt ¶
type MixedTextStmt struct {
Lit ast.Literal
Flags MixedTextStmtFlag
LParen source.Pos
RParen source.Pos
}
MixedTextStmt represents an MixedTextStmt.
func SMixedText ¶
func SMixedText(pos source.Pos, vlit string, flags ...MixedTextStmtFlag) *MixedTextStmt
func (*MixedTextStmt) End ¶
func (s *MixedTextStmt) End() source.Pos
func (*MixedTextStmt) ExprNode ¶
func (s *MixedTextStmt) ExprNode()
func (*MixedTextStmt) Pos ¶
func (s *MixedTextStmt) Pos() source.Pos
func (*MixedTextStmt) StmtNode ¶
func (s *MixedTextStmt) StmtNode()
func (*MixedTextStmt) String ¶
func (s *MixedTextStmt) String() string
func (*MixedTextStmt) TrimLinePrefix ¶
func (s *MixedTextStmt) TrimLinePrefix(prefix string)
func (*MixedTextStmt) ValidLit ¶
func (s *MixedTextStmt) ValidLit() ast.Literal
func (*MixedTextStmt) Value ¶
func (s *MixedTextStmt) Value() string
func (*MixedTextStmt) WriteCode ¶
func (s *MixedTextStmt) WriteCode(ctx *CodeWriteContext)
type MixedTextStmtFlag ¶
type MixedTextStmtFlag uint
const ( // RemoveLeftSpaces / RemoveRightSpaces are the single-dash markers (`-%}` // trims the following text's leading blanks; `{%-` trims the preceding // text's trailing blanks) and preserve a single boundary newline. RemoveLeftSpaces MixedTextStmtFlag = 1 << iota RemoveRightSpaces // RemoveLeftAll / RemoveRightAll are the double-dash markers (`--%}` / `{%--`) // and strip ALL boundary whitespace, newlines included. RemoveLeftAll RemoveRightAll )
func (MixedTextStmtFlag) Has ¶
func (s MixedTextStmtFlag) Has(f MixedTextStmtFlag) bool
func (MixedTextStmtFlag) String ¶
func (s MixedTextStmtFlag) String() string
type MixedValueStmt ¶
type MixedValueStmt struct {
Expr Expr
StartLit ast.Literal
EndLit ast.Literal
RemoveLeftSpace bool
RemoveRightSpace bool
// RemoveLeftAll/RemoveRightAll are the double-dash markers (`{%--= … --%}`)
// that strip ALL adjacent whitespace (newlines included).
RemoveLeftAll bool
RemoveRightAll bool
Eq bool
}
MixedValueStmt is an inline value-emitting tag in mixed/template mode, e.g. `{%= expr %}`, whose Expr is evaluated and written into the surrounding text. StartLit/EndLit hold the opening/closing delimiters (`{%`/`%}`); Eq reports the `=` value marker. RemoveLeftSpace/RemoveRightSpace mirror the `-` trim markers (`{%- … -%}`) that strip surrounding whitespace from the adjacent text at run time.
func SMixedValue ¶
func SMixedValue(start, end ast.Literal, expr Expr) *MixedValueStmt
func (*MixedValueStmt) End ¶
func (s *MixedValueStmt) End() source.Pos
End returns the position of first character immediately after the node.
func (*MixedValueStmt) ExprNode ¶
func (s *MixedValueStmt) ExprNode()
func (*MixedValueStmt) Pos ¶
func (s *MixedValueStmt) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*MixedValueStmt) StmtNode ¶
func (s *MixedValueStmt) StmtNode()
func (*MixedValueStmt) String ¶
func (s *MixedValueStmt) String() string
func (*MixedValueStmt) WriteCode ¶
func (s *MixedValueStmt) WriteCode(ctx *CodeWriteContext)
type ModuleLit ¶ added in v0.0.2
ModuleLit represents an @module literal.
func (*ModuleLit) End ¶ added in v0.0.2
End IsMainLit the position of first character immediately after the node.
func (*ModuleLit) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*ModuleLit) WriteCode ¶ added in v0.0.2
func (e *ModuleLit) WriteCode(ctx *CodeWriteContext)
type MultiParenExpr ¶
type MultiParenExpr struct {
LParen Token
RParen Token
PositionalElements Exprs
NamedElements Exprs
}
MultiParenExpr represents a parenthesis wrapped expressions.
func (*MultiParenExpr) End ¶
func (e *MultiParenExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*MultiParenExpr) ExprNode ¶
func (e *MultiParenExpr) ExprNode()
func (*MultiParenExpr) Pos ¶
func (e *MultiParenExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*MultiParenExpr) String ¶
func (e *MultiParenExpr) String() string
func (*MultiParenExpr) ToCallArgs ¶
func (e *MultiParenExpr) ToCallArgs(strict bool) (args *CallArgs, err *NodeError)
func (*MultiParenExpr) ToFuncHeaderParams ¶ added in v0.0.2
func (e *MultiParenExpr) ToFuncHeaderParams() (FuncParams, *NodeError)
ToFuncHeaderParams parses the positional list as a *function header* signature (a `meti` header or a `<…>` func-header value): a bare positional entry is a *type*, not a param name, so `(int)` yields the unnamed typed param `(_ int)` (and `(mod.T)` likewise). Entries already written as `name type` (*TypedIdentExpr) are kept as-is. Otherwise it behaves like ToFuncParams.
func (*MultiParenExpr) ToFuncParams ¶
func (e *MultiParenExpr) ToFuncParams() (params FuncParams, err *NodeError)
func (*MultiParenExpr) ToMultiParenExpr ¶
func (e *MultiParenExpr) ToMultiParenExpr() *MultiParenExpr
func (*MultiParenExpr) WriteCode ¶
func (e *MultiParenExpr) WriteCode(ctx *CodeWriteContext)
WriteCode renders the canonical `(, positional; named )` form inline, mirroring String. It is intentionally inline: the previous multiline path was broken — it duplicated the positional items and wrote them again in place of the named items (using PositionalElements for both loops), dropping the named side.
type NamedArgBuilder ¶ added in v0.0.2
type NamedArgBuilder struct {
// contains filtered or unexported fields
}
func ENamedArg ¶ added in v0.0.2
func ENamedArg() *NamedArgBuilder
func (*NamedArgBuilder) Build ¶ added in v0.0.2
func (b *NamedArgBuilder) Build() *NamedArgExpr
func (*NamedArgBuilder) Expr ¶ added in v0.0.2
func (b *NamedArgBuilder) Expr(v Expr) *NamedArgBuilder
func (*NamedArgBuilder) Ident ¶ added in v0.0.2
func (b *NamedArgBuilder) Ident(v *IdentExpr) *NamedArgBuilder
func (*NamedArgBuilder) Literal ¶ added in v0.0.2
func (b *NamedArgBuilder) Literal(v *StrLit) *NamedArgBuilder
func (*NamedArgBuilder) Var ¶ added in v0.0.2
func (b *NamedArgBuilder) Var() *NamedArgBuilder
type NamedArgExpr ¶
func (*NamedArgExpr) Expr ¶
func (e *NamedArgExpr) Expr() Expr
func (*NamedArgExpr) Name ¶
func (e *NamedArgExpr) Name() string
func (*NamedArgExpr) String ¶
func (e *NamedArgExpr) String() string
func (*NamedArgExpr) WriteCode ¶
func (e *NamedArgExpr) WriteCode(ctx *CodeWriteContext)
type NamedArgVarLit ¶
NamedArgVarLit represents an variadic of named argument.
func (*NamedArgVarLit) End ¶
func (e *NamedArgVarLit) End() source.Pos
func (*NamedArgVarLit) ExprNode ¶
func (e *NamedArgVarLit) ExprNode()
func (*NamedArgVarLit) Pos ¶
func (e *NamedArgVarLit) Pos() source.Pos
func (*NamedArgVarLit) String ¶
func (e *NamedArgVarLit) String() string
func (*NamedArgVarLit) WriteCode ¶
func (e *NamedArgVarLit) WriteCode(ctx *CodeWriteContext)
type NamedArgsKeywordExpr ¶
func NamedArgsKW ¶
func NamedArgsKW(pos source.Pos) *NamedArgsKeywordExpr
func (*NamedArgsKeywordExpr) End ¶
func (c *NamedArgsKeywordExpr) End() source.Pos
func (*NamedArgsKeywordExpr) ExprNode ¶
func (c *NamedArgsKeywordExpr) ExprNode()
func (*NamedArgsKeywordExpr) Pos ¶
func (c *NamedArgsKeywordExpr) Pos() source.Pos
func (*NamedArgsKeywordExpr) String ¶
func (c *NamedArgsKeywordExpr) String() string
func (*NamedArgsKeywordExpr) WriteCode ¶
func (c *NamedArgsKeywordExpr) WriteCode(ctx *CodeWriteContext)
type NamedArgsList ¶
type NamedArgsList struct {
Var *IdentExpr
Names []*TypedIdentExpr
Values []Expr
}
NamedArgsList represents a list of identifier with value pairs.
func NamedArgs ¶
func NamedArgs(vari *IdentExpr, names []*TypedIdentExpr, values []Expr) NamedArgsList
func (*NamedArgsList) Add ¶
func (n *NamedArgsList) Add(name *TypedIdentExpr, value Expr) *NamedArgsList
func (*NamedArgsList) End ¶
func (n *NamedArgsList) End() source.Pos
End returns the position of first character immediately after the node.
func (*NamedArgsList) IsZero ¶ added in v0.0.2
func (n *NamedArgsList) IsZero() bool
func (*NamedArgsList) NumFields ¶
func (n *NamedArgsList) NumFields() int
NumFields returns the number of fields.
func (*NamedArgsList) Pos ¶
func (n *NamedArgsList) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*NamedArgsList) String ¶
func (n *NamedArgsList) String() string
type NamedParamSpec ¶
type NamedParamSpec struct {
Ident *TypedIdentExpr
Value Expr
Var bool
// AbsentDefault marks a `global` default written with `!?=` (apply only when
// the name is absent) instead of `=` (apply when nil or absent).
AbsentDefault bool
}
A NamedParamSpec node represents a named parameter declaration
func (*NamedParamSpec) End ¶
func (s *NamedParamSpec) End() source.Pos
End returns the position of first character immediately after the spec.
func (*NamedParamSpec) Pos ¶
func (s *NamedParamSpec) Pos() source.Pos
Pos returns the position of first character belonging to the spec.
func (*NamedParamSpec) String ¶
func (s *NamedParamSpec) String() string
func (*NamedParamSpec) WriteCode ¶
func (s *NamedParamSpec) WriteCode(ctx *CodeWriteContext)
type NilLit ¶
NilLit represents an nil literal.
func (*NilLit) WriteCode ¶
func (e *NilLit) WriteCode(ctx *CodeWriteContext)
type NullishCallExpr ¶ added in v0.0.2
NullishCallExpr represents an optional (nullish) call `x?.(args)`: x is evaluated once and called only when it is not nil; otherwise the whole expression evaluates to nil. It is the call counterpart of the `?.` nullish selector and is shorthand for `x != nil ? x(args) : nil`.
func (*NullishCallExpr) CallPos ¶ added in v0.0.2
func (e *NullishCallExpr) CallPos() source.Pos
CallPos returns the position of the first valid call pos.
func (*NullishCallExpr) End ¶ added in v0.0.2
func (e *NullishCallExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*NullishCallExpr) ExprNode ¶ added in v0.0.2
func (e *NullishCallExpr) ExprNode()
func (*NullishCallExpr) GetCallArgs ¶ added in v0.0.2
func (e *NullishCallExpr) GetCallArgs() *CallArgs
func (*NullishCallExpr) Pos ¶ added in v0.0.2
func (e *NullishCallExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*NullishCallExpr) String ¶ added in v0.0.2
func (e *NullishCallExpr) String() string
func (*NullishCallExpr) WriteCode ¶ added in v0.0.2
func (e *NullishCallExpr) WriteCode(ctx *CodeWriteContext)
type NullishSelectorExpr ¶
NullishSelectorExpr represents a selector expression.
func ENullish ¶
func ENullish( sel, expr Expr, ) *NullishSelectorExpr
func (*NullishSelectorExpr) End ¶
func (e *NullishSelectorExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*NullishSelectorExpr) ExprNode ¶
func (e *NullishSelectorExpr) ExprNode()
func (*NullishSelectorExpr) GetX ¶ added in v0.0.2
func (e *NullishSelectorExpr) GetX() Expr
func (*NullishSelectorExpr) GetY ¶ added in v0.0.2
func (e *NullishSelectorExpr) GetY() Expr
func (*NullishSelectorExpr) Pos ¶
func (e *NullishSelectorExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*NullishSelectorExpr) String ¶
func (e *NullishSelectorExpr) String() string
func (*NullishSelectorExpr) WriteCode ¶
func (e *NullishSelectorExpr) WriteCode(ctx *CodeWriteContext)
type OrExpr ¶ added in v0.0.2
OrExpr represents an error-fallback expression: `expr or fallback`. If evaluating Expr throws an error, Fallback is evaluated instead, with the caught error bound to the local `$err`. The whole expression yields the value of Expr on success, or the value of Fallback when Expr throws.
func (*OrExpr) End ¶ added in v0.0.2
End returns the position of first character immediately after the node.
func (*OrExpr) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*OrExpr) WriteCode ¶ added in v0.0.2
func (e *OrExpr) WriteCode(ctx *CodeWriteContext)
type ParamSpec ¶
type ParamSpec struct {
Ident *TypedIdentExpr
Var bool
}
A ParamSpec node represents a parameter declaration
func (*ParamSpec) WriteCode ¶
func (s *ParamSpec) WriteCode(ctx *CodeWriteContext)
type ParenExpr ¶
ParenExpr represents a parenthesis wrapped expression.
func (*ParenExpr) ToMultiParenExpr ¶
func (e *ParenExpr) ToMultiParenExpr() *MultiParenExpr
func (*ParenExpr) WriteCode ¶
func (e *ParenExpr) WriteCode(ctx *CodeWriteContext)
type PropExpr ¶ added in v0.0.2
type PropExpr struct {
PropToken TokenLit
LBrace source.Pos
RBrace source.Pos
NameExpr Expr
Methods []*FuncMethod
Doc *ast.CommentGroup // doc comment preceding the prop; or nil
}
PropExpr represents a property expression: a named value defined by one or more accessor methods, sharing the func-with-methods body syntax but introduced by the `prop` keyword. A method with no parameters is the getter and a method with one parameter is a setter.
func (*PropExpr) End ¶ added in v0.0.2
End returns the position of first character immediately after the node.
func (*PropExpr) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*PropExpr) WriteCode ¶ added in v0.0.2
func (e *PropExpr) WriteCode(ctx *CodeWriteContext)
type PropStmt ¶ added in v0.0.2
type PropStmt struct {
PropExpr
}
PropStmt represents a property declaration statement, e.g. `prop name { () { ... } (v int) { ... } }`.
type Ptr ¶ added in v0.0.2
func (*Ptr) WriteCode ¶ added in v0.0.2
func (e *Ptr) WriteCode(ctx *CodeWriteContext)
type RawHeredocLit ¶
func RawHeredoc ¶
func RawHeredoc(value string, pos source.Pos) *RawHeredocLit
func (*RawHeredocLit) ContentPos ¶ added in v0.0.2
func (e *RawHeredocLit) ContentPos() source.Pos
ContentPos returns the source position of the first byte of RawContent.
func (*RawHeredocLit) End ¶
func (e *RawHeredocLit) End() source.Pos
End returns the position of first character immediately after the node.
func (*RawHeredocLit) ExprNode ¶
func (e *RawHeredocLit) ExprNode()
func (*RawHeredocLit) Pos ¶
func (e *RawHeredocLit) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*RawHeredocLit) RawContent ¶ added in v0.0.2
func (e *RawHeredocLit) RawContent() string
RawContent returns the heredoc body with the surrounding backtick fences, the opening fence line and the closing line removed, but with interior indentation preserved. Unlike Value it keeps a 1:1 byte correspondence with the original source starting at ContentPos, so it is what gets parsed for template interpolation so positions map back to the source.
func (*RawHeredocLit) String ¶
func (e *RawHeredocLit) String() string
func (*RawHeredocLit) StripCount ¶ added in v0.0.2
func (e *RawHeredocLit) StripCount() int
StripCount returns the common leading indentation (spaces/tabs) removed from each content line by Value. It is zero for the single-line form (no newline after the opening fence), which is not indentation-stripped.
func (*RawHeredocLit) Value ¶
func (e *RawHeredocLit) Value() string
func (*RawHeredocLit) WriteCode ¶
func (e *RawHeredocLit) WriteCode(ctx *CodeWriteContext)
type RawStrLit ¶ added in v0.0.2
func (*RawStrLit) End ¶ added in v0.0.2
End returns the position of first character immediately after the node.
func (*RawStrLit) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*RawStrLit) QuotedValue ¶ added in v0.0.2
func (*RawStrLit) WriteCode ¶ added in v0.0.2
func (e *RawStrLit) WriteCode(ctx *CodeWriteContext)
type RegexLit ¶ added in v0.0.2
RegexLit represents a `/regex/` (or `/regex/p` POSIX) literal. Literal holds the raw source including the delimiters and optional flag.
func (*RegexLit) End ¶ added in v0.0.2
End returns the position of first character immediately after the node.
func (*RegexLit) Pattern ¶ added in v0.0.2
Pattern returns the regex source between the delimiters, with `\/` unescaped.
func (*RegexLit) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*RegexLit) Posix ¶ added in v0.0.2
Posix reports whether the literal carries the trailing `p` POSIX flag.
func (*RegexLit) WriteCode ¶ added in v0.0.2
func (e *RegexLit) WriteCode(ctx *CodeWriteContext)
type Return ¶
Return represents an return expression.
func (*Return) WriteCode ¶
func (s *Return) WriteCode(ctx *CodeWriteContext)
type ReturnExpr ¶
type ReturnExpr struct {
Return
}
ReturnExpr represents an return expression.
func EReturnExpr ¶
func EReturnExpr(pos source.Pos, result Expr) *ReturnExpr
func (*ReturnExpr) ExprNode ¶
func (s *ReturnExpr) ExprNode()
type ReturnStmt ¶
type ReturnStmt struct {
Return
}
ReturnStmt represents a return statement.
func SReturnAssign ¶ added in v0.0.2
func SReturnAssign(pos source.Pos, result Expr) *ReturnStmt
func (*ReturnStmt) StmtNode ¶
func (s *ReturnStmt) StmtNode()
func (*ReturnStmt) WriteCode ¶
func (s *ReturnStmt) WriteCode(ctx *CodeWriteContext)
type SelectorExpr ¶
SelectorExpr represents a selector expression.
func ESelector ¶
func ESelector(x, sel Expr) *SelectorExpr
func (*SelectorExpr) End ¶
func (e *SelectorExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*SelectorExpr) ExprNode ¶
func (e *SelectorExpr) ExprNode()
func (*SelectorExpr) GetX ¶ added in v0.0.2
func (e *SelectorExpr) GetX() Expr
func (*SelectorExpr) GetY ¶ added in v0.0.2
func (e *SelectorExpr) GetY() Expr
func (*SelectorExpr) Pos ¶
func (e *SelectorExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*SelectorExpr) String ¶
func (e *SelectorExpr) String() string
func (*SelectorExpr) WriteCode ¶
func (e *SelectorExpr) WriteCode(ctx *CodeWriteContext)
type SliceExpr ¶
SliceExpr represents a slice expression.
func (*SliceExpr) WriteCode ¶
func (e *SliceExpr) WriteCode(ctx *CodeWriteContext)
type Spec ¶
Spec node represents a single (non-parenthesized) variable declaration. The Spec type stands for any of *ParamSpec or *ValueSpec.
func NewNamedParamSpec ¶
func NewNamedParamSpec(ident *TypedIdentExpr, value Expr) Spec
func NewNamedParamSpecVar ¶ added in v0.0.2
func NewNamedParamSpecVar(ident *TypedIdentExpr) Spec
func NewParamSpec ¶
func NewParamSpec(variadic bool, ident *TypedIdentExpr) Spec
func NewValueSpec ¶
type StdErrLit ¶
StdErrLit represents an STDERR literal.
func (*StdErrLit) WriteCode ¶
func (e *StdErrLit) WriteCode(ctx *CodeWriteContext)
type StdInLit ¶
StdInLit represents an STDIN literal.
func (*StdInLit) WriteCode ¶
func (e *StdInLit) WriteCode(ctx *CodeWriteContext)
type StdOutLit ¶
StdOutLit represents an STDOUT literal.
func (*StdOutLit) WriteCode ¶
func (e *StdOutLit) WriteCode(ctx *CodeWriteContext)
type Stmts ¶
type Stmts []Stmt
func (Stmts) WriteCode ¶
func (s Stmts) WriteCode(ctx *CodeWriteContext)
type StmtsExpr ¶
type StmtsExpr struct {
Stmts Stmts
}
func (*StmtsExpr) WriteCode ¶
func (s *StmtsExpr) WriteCode(ctx *CodeWriteContext)
type StrLit ¶ added in v0.0.2
StrLit represents a string literal.
func (*StrLit) End ¶ added in v0.0.2
End returns the position of first character immediately after the node.
func (*StrLit) Pos ¶ added in v0.0.2
Pos returns the position of first character belonging to the node.
func (*StrLit) WriteCode ¶ added in v0.0.2
func (e *StrLit) WriteCode(ctx *CodeWriteContext)
type SymbolLit ¶ added in v0.0.2
type SymbolLit struct {
Lit TokenLit
}
func (*SymbolLit) WriteCode ¶ added in v0.0.2
func (s *SymbolLit) WriteCode(ctx *CodeWriteContext)
type TemplateLit ¶
TemplateLit represents a template string literal prefixed with `#`, such as `#"text"` or `#'symbol'`. It is parsed in ParseOperand when a token.Template is followed by a string, raw string, heredoc, or symbol token. The Value field holds the string/symbol expression that follows the `#` token.
func (*TemplateLit) Build ¶ added in v0.0.2
func (e *TemplateLit) Build(sourceStmts Stmts) (expr Expr, err error)
func (*TemplateLit) End ¶
func (e *TemplateLit) End() source.Pos
func (*TemplateLit) ExprNode ¶
func (e *TemplateLit) ExprNode()
func (*TemplateLit) Pos ¶
func (e *TemplateLit) Pos() source.Pos
func (*TemplateLit) String ¶
func (e *TemplateLit) String() string
func (*TemplateLit) StringValue ¶ added in v0.0.2
func (e *TemplateLit) StringValue() string
func (*TemplateLit) StringValuePos ¶ added in v0.0.2
func (e *TemplateLit) StringValuePos() source.Pos
StringValuePos returns the source position to pass to parser.ParseTemplateString: the position of the byte immediately before the first content byte of StringValue (the template content begins one byte after it). For single-delimiter values that is the opening delimiter; for a heredoc it is the newline that ends the opening backtick line, since the surrounding backticks and the opening line are stripped from the content.
func (*TemplateLit) WriteCode ¶
func (e *TemplateLit) WriteCode(ctx *CodeWriteContext)
type TestKind ¶ added in v0.0.2
type TestKind uint8
TestKind selects whether a TestStmt declares a test or a benchmark.
type TestStmt ¶ added in v0.0.2
type TestStmt struct {
Kind TestKind
KwPos source.Pos // position of the `test`/`bench` keyword
Name string // the test name (identifier spelling or string value)
NamePos source.Pos
Quoted bool // NAME was written as a string literal
Body *BlockStmt
Doc *ast.CommentGroup // doc comment preceding the statement; or nil
}
TestStmt is a `test NAME { … }` or `bench NAME { … }` statement. NAME is an identifier or a string literal; the body runs with an injected `t` test context (see the `test` module). `test`/`bench` are contextual: they are only this statement when followed by a NAME and `{`, so they remain ordinary identifiers everywhere else.
func (*TestStmt) WriteCode ¶ added in v0.0.2
func (s *TestStmt) WriteCode(ctx *CodeWriteContext)
type ThrowExpr ¶
ThrowExpr represents an throw expression.
func (*ThrowExpr) WriteCode ¶
func (s *ThrowExpr) WriteCode(ctx *CodeWriteContext)
type ThrowStmt ¶
ThrowStmt represents an throw statement.
func (*ThrowStmt) WriteCode ¶
func (s *ThrowStmt) WriteCode(ctx *CodeWriteContext)
type ToMultiParenConverter ¶
type ToMultiParenConverter interface {
Expr
ToMultiParenExpr() *MultiParenExpr
}
type ToRaw ¶ added in v0.0.2
func (*ToRaw) WriteCode ¶ added in v0.0.2
func (r *ToRaw) WriteCode(ctx *CodeWriteContext)
type TokenLit ¶ added in v0.0.2
func (TokenLit) Precedence ¶ added in v0.0.2
type TranspileOptions ¶
type TryStmt ¶
type TryStmt struct {
TryPos source.Pos
Body *BlockStmt
Catch *CatchStmt // catch branch; or nil
Finally *FinallyStmt // finally branch; or nil
}
TryStmt represents an try statement.
func (*TryStmt) WriteCode ¶
func (s *TryStmt) WriteCode(ctx *CodeWriteContext)
type TypedIdentExpr ¶
func ETypedIdent ¶
func ETypedIdent(ident *IdentExpr, typ ...*TypeExpr) *TypedIdentExpr
func FuncReturn ¶ added in v0.0.2
func FuncReturn(types ...*TypedIdentExpr) []*TypedIdentExpr
FuncReturn builds a function return-type list from typed idents.
func (*TypedIdentExpr) End ¶
func (e *TypedIdentExpr) End() source.Pos
End returns the position of first character immediately after the node.
func (*TypedIdentExpr) ExprNode ¶
func (e *TypedIdentExpr) ExprNode()
func (*TypedIdentExpr) Pos ¶
func (e *TypedIdentExpr) Pos() source.Pos
Pos returns the position of first character belonging to the node.
func (*TypedIdentExpr) String ¶
func (e *TypedIdentExpr) String() string
func (*TypedIdentExpr) WriteCode ¶
func (e *TypedIdentExpr) WriteCode(ctx *CodeWriteContext)
type UintLit ¶
UintLit represents an unsigned integer literal.
func (*UintLit) WriteCode ¶
func (e *UintLit) WriteCode(ctx *CodeWriteContext)
type UnaryExpr ¶
UnaryExpr represents an unary operator expression.
func (*UnaryExpr) WriteCode ¶
func (e *UnaryExpr) WriteCode(ctx *CodeWriteContext)
type ValueSpec ¶
type ValueSpec struct {
Idents []*IdentExpr // TODO: slice is reserved for tuple assignment
Values []Expr // initial values; or nil
// Pattern is a destructuring left side (`const { … } = v` / `const [ … ] = v`).
// When set, Idents is empty and Values holds the single source expression.
Pattern Expr
Data any // iota
Doc *ast.CommentGroup // doc comment preceding the spec (linked to ident); or nil
}
A ValueSpec node represents a variable declaration
func (*ValueSpec) WriteCode ¶
func (s *ValueSpec) WriteCode(ctx *CodeWriteContext)
type WithBind ¶ added in v0.0.2
type WithBind int
WithBind selects how a `with` statement binds its resource.
type WithExpr ¶ added in v0.0.2
type WithExpr struct {
WithPos source.Pos
Resource Expr
Ident *IdentExpr // `as IDENT`, or nil
ColonPos source.Pos
Value Expr
}
WithExpr is the expression form `with Resource [as IDENT]: Value`: it enters the resource (gad.enter), evaluates Value, exits (gad.exit) and yields Value.
func (*WithExpr) WriteCode ¶ added in v0.0.2
func (e *WithExpr) WriteCode(ctx *CodeWriteContext)
type WithStmt ¶ added in v0.0.2
type WithStmt struct {
WithPos source.Pos
Bind WithBind
Ident *IdentExpr
Resource Expr
Body *BlockStmt
}
WithStmt represents a `with` context-manager statement. The resource's enter/exit hooks (gad.enter / gad.exit) run around Body. Resource is the context value; Ident is the `as` block-local binding or the assign/define target (nil for WithBindNone).
func (*WithStmt) WriteCode ¶ added in v0.0.2
func (s *WithStmt) WriteCode(ctx *CodeWriteContext)