Documentation
¶
Index ¶
- Variables
- func AnalyzeFunctionLocals(fn *FunctionLiteral)
- func AnalyzeLambdaLocals(lambda *Lambda)
- func AnalyzeTopLevelLocals(program *Program)
- func EstimateRetainedBytes(program *Program, source string) int
- func FoldConstants(program *Program)
- type AssertStatement
- type AssignStatement
- type AugmentedAssignStatement
- type BlockStatement
- type Boolean
- type BreakStatement
- type CallExpression
- func (ce *CallExpression) GetArgsUnpack() []Expression
- func (ce *CallExpression) GetKeywords() map[string]Expression
- func (ce *CallExpression) GetKwargsUnpack() Expression
- func (ce *CallExpression) HasOverflow() bool
- func (ce *CallExpression) Line() int
- func (ce *CallExpression) SetOverflow(keywords map[string]Expression, argsUnpack []Expression, ...)
- func (ce *CallExpression) TokenLiteral() string
- type CallOverflow
- type CaseClause
- type ClassStatement
- type ComprehensionClause
- type ConditionalExpression
- type ContinueStatement
- type DecoratorsOverflow
- type DelStatement
- type DictComprehension
- type DictLiteral
- type DictPairLiteral
- type ElifClause
- type ExceptClause
- type Expression
- type ExpressionStatement
- type FStringLiteral
- type FStringOverflow
- type FloatLiteral
- type ForStatement
- type FromImportStatement
- type FuncOverflow
- type FunctionLiteral
- func (fl *FunctionLiteral) GetDefaultValues() map[string]Expression
- func (fl *FunctionLiteral) GetKeywordOnlyStart() int
- func (fl *FunctionLiteral) GetKwargs() *Identifier
- func (fl *FunctionLiteral) GetVariadic() *Identifier
- func (fl *FunctionLiteral) Line() int
- func (fl *FunctionLiteral) SetFuncOverflow(dv map[string]Expression, variadic, kwargs *Identifier, keywordOnlyStart int)
- func (fl *FunctionLiteral) TokenLiteral() string
- type FunctionStatement
- type GlobalStatement
- type Identifier
- type IfStatement
- type ImportOverflow
- type ImportStatement
- func (is *ImportStatement) AppendAdditionalAlias(alias *Identifier)
- func (is *ImportStatement) AppendAdditionalName(name *Identifier)
- func (is *ImportStatement) FullName() string
- func (is *ImportStatement) GetAdditionalAliases() []*Identifier
- func (is *ImportStatement) GetAdditionalNames() []*Identifier
- func (is *ImportStatement) GetAlias() *Identifier
- func (is *ImportStatement) Line() int
- func (is *ImportStatement) SetImportOverflow(alias *Identifier, names, aliases []*Identifier)
- func (is *ImportStatement) TokenLiteral() string
- type IndexExpression
- type InfixExpression
- type IntegerLiteral
- type Lambda
- func (l *Lambda) GetDefaultValues() map[string]Expression
- func (l *Lambda) GetKeywordOnlyStart() int
- func (l *Lambda) GetKwargs() *Identifier
- func (l *Lambda) GetVariadic() *Identifier
- func (l *Lambda) Line() int
- func (l *Lambda) SetFuncOverflow(dv map[string]Expression, variadic, kwargs *Identifier, keywordOnlyStart int)
- func (l *Lambda) TokenLiteral() string
- type LineInfo
- type ListComprehension
- type ListLiteral
- type MatchStatement
- type MethodCallExpression
- func (mce *MethodCallExpression) GetArgsUnpack() []Expression
- func (mce *MethodCallExpression) GetKeywords() map[string]Expression
- func (mce *MethodCallExpression) GetKwargsUnpack() Expression
- func (mce *MethodCallExpression) HasOverflow() bool
- func (mce *MethodCallExpression) Line() int
- func (mce *MethodCallExpression) SetOverflow(keywords map[string]Expression, argsUnpack []Expression, ...)
- func (mce *MethodCallExpression) TokenLiteral() string
- type MultipleAssignStatement
- type Node
- type None
- type NonlocalStatement
- type Op
- type OrPattern
- type PassStatement
- type PrefixExpression
- type Program
- type RaiseStatement
- type ReturnStatement
- type SetComprehension
- type SetLiteral
- type SliceExpression
- type SliceOverflow
- type Statement
- type StringLiteral
- type SymbolTable
- type TryStatement
- type TupleLiteral
- type WhileStatement
- type WithStatement
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AnalyzeFunctionLocals ¶ added in v0.8.0
func AnalyzeFunctionLocals(fn *FunctionLiteral)
func AnalyzeLambdaLocals ¶ added in v0.8.0
func AnalyzeLambdaLocals(lambda *Lambda)
func AnalyzeTopLevelLocals ¶ added in v0.8.0
func AnalyzeTopLevelLocals(program *Program)
func EstimateRetainedBytes ¶ added in v0.8.0
EstimateRetainedBytes approximates the retained heap size of a parsed AST. The source script is counted separately by callers, so strings that alias the source backing bytes are not charged again here.
func FoldConstants ¶ added in v0.9.2
func FoldConstants(program *Program)
FoldConstants replaces constant sub-expressions with their evaluated literal values. It walks the entire AST including nested function bodies, class bodies, and all blocks.
Types ¶
type AssertStatement ¶
type AssertStatement struct {
Token LineInfo
Condition Expression
Message Expression // Optional
}
func (*AssertStatement) Line ¶
func (as *AssertStatement) Line() int
func (*AssertStatement) TokenLiteral ¶
func (as *AssertStatement) TokenLiteral() string
type AssignStatement ¶
type AssignStatement struct {
Token LineInfo
Left Expression
Value Expression
Chained *AssignStatement // for chained assignment: a = b = 5
}
func (*AssignStatement) Line ¶
func (as *AssignStatement) Line() int
func (*AssignStatement) TokenLiteral ¶
func (as *AssignStatement) TokenLiteral() string
type AugmentedAssignStatement ¶
type AugmentedAssignStatement struct {
Token LineInfo
Name *Identifier
Left Expression
Operator Op
Value Expression
}
func (*AugmentedAssignStatement) Line ¶
func (aas *AugmentedAssignStatement) Line() int
func (*AugmentedAssignStatement) TokenLiteral ¶
func (aas *AugmentedAssignStatement) TokenLiteral() string
type BlockStatement ¶
func (*BlockStatement) Line ¶
func (bs *BlockStatement) Line() int
func (*BlockStatement) TokenLiteral ¶
func (bs *BlockStatement) TokenLiteral() string
type BreakStatement ¶
type BreakStatement struct {
Token LineInfo
}
func (*BreakStatement) Line ¶
func (bs *BreakStatement) Line() int
func (*BreakStatement) TokenLiteral ¶
func (bs *BreakStatement) TokenLiteral() string
type CallExpression ¶
type CallExpression struct {
Function Expression
Arguments []Expression
// contains filtered or unexported fields
}
func (*CallExpression) GetArgsUnpack ¶ added in v0.8.0
func (ce *CallExpression) GetArgsUnpack() []Expression
func (*CallExpression) GetKeywords ¶ added in v0.8.0
func (ce *CallExpression) GetKeywords() map[string]Expression
func (*CallExpression) GetKwargsUnpack ¶ added in v0.8.0
func (ce *CallExpression) GetKwargsUnpack() Expression
func (*CallExpression) HasOverflow ¶ added in v0.8.0
func (ce *CallExpression) HasOverflow() bool
func (*CallExpression) Line ¶
func (ce *CallExpression) Line() int
func (*CallExpression) SetOverflow ¶ added in v0.8.0
func (ce *CallExpression) SetOverflow(keywords map[string]Expression, argsUnpack []Expression, kwargsUnpack Expression)
func (*CallExpression) TokenLiteral ¶
func (ce *CallExpression) TokenLiteral() string
type CallOverflow ¶ added in v0.8.0
type CallOverflow struct {
Keywords map[string]Expression
ArgsUnpack []Expression
KwargsUnpack Expression
}
type CaseClause ¶
type CaseClause struct {
Token LineInfo // The 'case' token
Pattern Expression // The pattern to match (can be literal, identifier for type, dict, or wildcard)
Guard Expression // Optional guard condition (if clause)
Body *BlockStatement
CaptureAs *Identifier // Optional capture variable for the matched value
}
CaseClause represents a single case in a match statement
type ClassStatement ¶
type ClassStatement struct {
Token LineInfo
Name *Identifier
BaseClass Expression
Body *BlockStatement
// contains filtered or unexported fields
}
func (*ClassStatement) GetDecorators ¶ added in v0.8.0
func (cs *ClassStatement) GetDecorators() []Expression
func (*ClassStatement) Line ¶
func (cs *ClassStatement) Line() int
func (*ClassStatement) SetDecorators ¶ added in v0.8.0
func (cs *ClassStatement) SetDecorators(decorators []Expression)
func (*ClassStatement) TokenLiteral ¶
func (cs *ClassStatement) TokenLiteral() string
type ComprehensionClause ¶ added in v0.3.2
type ComprehensionClause struct {
Variables []Expression
Iterable Expression
Condition Expression // optional
}
ComprehensionClause represents an additional `for var in iterable [if cond]` clause
type ConditionalExpression ¶
type ConditionalExpression struct {
TrueExpr Expression
Condition Expression
FalseExpr Expression
}
func (*ConditionalExpression) Line ¶
func (ce *ConditionalExpression) Line() int
func (*ConditionalExpression) TokenLiteral ¶
func (ce *ConditionalExpression) TokenLiteral() string
type ContinueStatement ¶
type ContinueStatement struct {
Token LineInfo
}
func (*ContinueStatement) Line ¶
func (cs *ContinueStatement) Line() int
func (*ContinueStatement) TokenLiteral ¶
func (cs *ContinueStatement) TokenLiteral() string
type DecoratorsOverflow ¶ added in v0.8.0
type DecoratorsOverflow struct {
Decorators []Expression
}
type DelStatement ¶ added in v0.5.5
type DelStatement struct {
Token LineInfo
Target Expression
}
func (*DelStatement) Line ¶ added in v0.5.5
func (ds *DelStatement) Line() int
func (*DelStatement) TokenLiteral ¶ added in v0.5.5
func (ds *DelStatement) TokenLiteral() string
type DictComprehension ¶ added in v0.2.0
type DictComprehension struct {
Key Expression
Value Expression
Variables []Expression
Iterable Expression
Condition Expression // optional
AdditionalClauses []ComprehensionClause // additional for clauses
}
func (*DictComprehension) Line ¶ added in v0.2.0
func (dc *DictComprehension) Line() int
func (*DictComprehension) TokenLiteral ¶ added in v0.2.0
func (dc *DictComprehension) TokenLiteral() string
type DictLiteral ¶
type DictLiteral struct {
Pairs []DictPairLiteral
}
func (*DictLiteral) Line ¶
func (dl *DictLiteral) Line() int
func (*DictLiteral) TokenLiteral ¶
func (dl *DictLiteral) TokenLiteral() string
type DictPairLiteral ¶ added in v0.5.2
type DictPairLiteral struct {
Key Expression
Value Expression
}
type ElifClause ¶
type ElifClause struct {
Token LineInfo
Condition Expression
Consequence *BlockStatement
}
type ExceptClause ¶
type ExceptClause struct {
Token LineInfo
ExceptType Expression // exception type to catch
ExceptVar *Identifier // variable to bind exception to
Body *BlockStatement
}
type Expression ¶
type Expression interface {
Node
// contains filtered or unexported methods
}
type ExpressionStatement ¶
type ExpressionStatement struct {
Token LineInfo
Expression Expression
}
func (*ExpressionStatement) Line ¶
func (es *ExpressionStatement) Line() int
func (*ExpressionStatement) TokenLiteral ¶
func (es *ExpressionStatement) TokenLiteral() string
type FStringLiteral ¶
type FStringLiteral struct {
Value string
Expressions []Expression
Parts []string
// contains filtered or unexported fields
}
func (*FStringLiteral) GetFormatSpecs ¶ added in v0.8.0
func (fsl *FStringLiteral) GetFormatSpecs() []string
func (*FStringLiteral) Line ¶
func (fsl *FStringLiteral) Line() int
func (*FStringLiteral) SetFormatSpecs ¶ added in v0.8.0
func (fsl *FStringLiteral) SetFormatSpecs(specs []string)
func (*FStringLiteral) TokenLiteral ¶
func (fsl *FStringLiteral) TokenLiteral() string
type FStringOverflow ¶ added in v0.8.0
type FStringOverflow struct {
FormatSpecs []string
}
type FloatLiteral ¶
type FloatLiteral struct {
Value float64
}
func (*FloatLiteral) Line ¶
func (fl *FloatLiteral) Line() int
func (*FloatLiteral) TokenLiteral ¶
func (fl *FloatLiteral) TokenLiteral() string
type ForStatement ¶
type ForStatement struct {
Token LineInfo
Variables []Expression
Iterable Expression
Body *BlockStatement
Else *BlockStatement // optional else clause
}
func (*ForStatement) Line ¶
func (fs *ForStatement) Line() int
func (*ForStatement) TokenLiteral ¶
func (fs *ForStatement) TokenLiteral() string
type FromImportStatement ¶
type FromImportStatement struct {
Token LineInfo // The 'from' token
Module *Identifier // The module name (e.g., "bs4" or "urllib.parse"), nil for "from . import X"
Names []*Identifier // The names to import (e.g., ["BeautifulSoup"])
Aliases []*Identifier // Optional aliases (for "import X as Y"), nil if no alias
RelativeLevel int // Number of leading dots for relative imports (0 = absolute, 1 = ".", 2 = "..", etc.)
}
FromImportStatement represents "from X import Y, Z" statements Also supports relative imports: "from . import X", "from .. import X", "from .module import X"
func (*FromImportStatement) Line ¶
func (fis *FromImportStatement) Line() int
func (*FromImportStatement) TokenLiteral ¶
func (fis *FromImportStatement) TokenLiteral() string
type FuncOverflow ¶ added in v0.8.0
type FuncOverflow struct {
DefaultValues map[string]Expression
Variadic *Identifier
Kwargs *Identifier
KeywordOnlyStart int
}
type FunctionLiteral ¶
type FunctionLiteral struct {
Parameters []*Identifier
Body *BlockStatement
HasNestedFunc bool
LocalSlots map[string]int
LocalSlotNames []string
ParamSlotIndexes []int
// contains filtered or unexported fields
}
func (*FunctionLiteral) GetDefaultValues ¶ added in v0.8.0
func (fl *FunctionLiteral) GetDefaultValues() map[string]Expression
func (*FunctionLiteral) GetKeywordOnlyStart ¶ added in v0.9.1
func (fl *FunctionLiteral) GetKeywordOnlyStart() int
func (*FunctionLiteral) GetKwargs ¶ added in v0.8.0
func (fl *FunctionLiteral) GetKwargs() *Identifier
func (*FunctionLiteral) GetVariadic ¶ added in v0.8.0
func (fl *FunctionLiteral) GetVariadic() *Identifier
func (*FunctionLiteral) Line ¶
func (fl *FunctionLiteral) Line() int
func (*FunctionLiteral) SetFuncOverflow ¶ added in v0.8.0
func (fl *FunctionLiteral) SetFuncOverflow(dv map[string]Expression, variadic, kwargs *Identifier, keywordOnlyStart int)
func (*FunctionLiteral) TokenLiteral ¶
func (fl *FunctionLiteral) TokenLiteral() string
type FunctionStatement ¶
type FunctionStatement struct {
Token LineInfo
Name *Identifier
Function *FunctionLiteral
// contains filtered or unexported fields
}
func (*FunctionStatement) GetDecorators ¶ added in v0.8.0
func (fs *FunctionStatement) GetDecorators() []Expression
func (*FunctionStatement) Line ¶
func (fs *FunctionStatement) Line() int
func (*FunctionStatement) SetDecorators ¶ added in v0.8.0
func (fs *FunctionStatement) SetDecorators(decorators []Expression)
func (*FunctionStatement) TokenLiteral ¶
func (fs *FunctionStatement) TokenLiteral() string
type GlobalStatement ¶
type GlobalStatement struct {
Token LineInfo
Names []*Identifier
}
func (*GlobalStatement) Line ¶
func (gs *GlobalStatement) Line() int
func (*GlobalStatement) TokenLiteral ¶
func (gs *GlobalStatement) TokenLiteral() string
type Identifier ¶
type Identifier struct {
Token LineInfo
Symbols *SymbolTable
Name uint32
// Slot cache for fast local variable access.
// 0 = uncached (zero value), -1 = not a local slot, >0 = slot index + 1.
SlotCache atomic.Int32
}
func NewIdentifier ¶ added in v0.8.0
func NewIdentifier(tok token.Token, symbols *SymbolTable, value string) *Identifier
func NewIdentifierWithLine ¶ added in v0.8.0
func NewIdentifierWithLine(line LineInfo, symbols *SymbolTable, value string) *Identifier
func (*Identifier) Line ¶
func (i *Identifier) Line() int
func (*Identifier) TokenLiteral ¶
func (i *Identifier) TokenLiteral() string
func (*Identifier) Value ¶
func (i *Identifier) Value() string
type IfStatement ¶
type IfStatement struct {
Token LineInfo
Condition Expression
Consequence *BlockStatement
ElifClauses []*ElifClause
Alternative *BlockStatement
}
func (*IfStatement) Line ¶
func (is *IfStatement) Line() int
func (*IfStatement) TokenLiteral ¶
func (is *IfStatement) TokenLiteral() string
type ImportOverflow ¶ added in v0.8.0
type ImportOverflow struct {
Alias *Identifier
AdditionalNames []*Identifier
AdditionalAliases []*Identifier
}
type ImportStatement ¶
type ImportStatement struct {
Token LineInfo
Name *Identifier
// contains filtered or unexported fields
}
func (*ImportStatement) AppendAdditionalAlias ¶ added in v0.8.0
func (is *ImportStatement) AppendAdditionalAlias(alias *Identifier)
func (*ImportStatement) AppendAdditionalName ¶ added in v0.8.0
func (is *ImportStatement) AppendAdditionalName(name *Identifier)
func (*ImportStatement) FullName ¶
func (is *ImportStatement) FullName() string
FullName returns the complete import name (handles dotted imports like urllib.parse)
func (*ImportStatement) GetAdditionalAliases ¶ added in v0.8.0
func (is *ImportStatement) GetAdditionalAliases() []*Identifier
func (*ImportStatement) GetAdditionalNames ¶ added in v0.8.0
func (is *ImportStatement) GetAdditionalNames() []*Identifier
func (*ImportStatement) GetAlias ¶ added in v0.8.0
func (is *ImportStatement) GetAlias() *Identifier
func (*ImportStatement) Line ¶
func (is *ImportStatement) Line() int
func (*ImportStatement) SetImportOverflow ¶ added in v0.8.0
func (is *ImportStatement) SetImportOverflow(alias *Identifier, names, aliases []*Identifier)
func (*ImportStatement) TokenLiteral ¶
func (is *ImportStatement) TokenLiteral() string
type IndexExpression ¶
type IndexExpression struct {
Token LineInfo
Left Expression
Index Expression
IsDotAccess bool // true when desugared from dot notation (obj.attr)
}
func (*IndexExpression) Line ¶
func (ie *IndexExpression) Line() int
func (*IndexExpression) TokenLiteral ¶
func (ie *IndexExpression) TokenLiteral() string
type InfixExpression ¶
type InfixExpression struct {
Left Expression
Operator Op
Right Expression
}
func (*InfixExpression) Line ¶
func (ie *InfixExpression) Line() int
func (*InfixExpression) TokenLiteral ¶
func (ie *InfixExpression) TokenLiteral() string
type IntegerLiteral ¶
type IntegerLiteral struct {
Value int64
}
func (*IntegerLiteral) Line ¶
func (il *IntegerLiteral) Line() int
func (*IntegerLiteral) TokenLiteral ¶
func (il *IntegerLiteral) TokenLiteral() string
type Lambda ¶
type Lambda struct {
Parameters []*Identifier
Body Expression
LocalSlots map[string]int
LocalSlotNames []string
ParamSlotIndexes []int
// contains filtered or unexported fields
}
func (*Lambda) GetDefaultValues ¶ added in v0.8.0
func (l *Lambda) GetDefaultValues() map[string]Expression
func (*Lambda) GetKeywordOnlyStart ¶ added in v0.9.1
func (*Lambda) GetKwargs ¶ added in v0.8.0
func (l *Lambda) GetKwargs() *Identifier
func (*Lambda) GetVariadic ¶ added in v0.8.0
func (l *Lambda) GetVariadic() *Identifier
func (*Lambda) SetFuncOverflow ¶ added in v0.8.0
func (l *Lambda) SetFuncOverflow(dv map[string]Expression, variadic, kwargs *Identifier, keywordOnlyStart int)
func (*Lambda) TokenLiteral ¶
type LineInfo ¶ added in v0.8.0
type LineInfo struct {
Line int32
}
func NewLineInfo ¶ added in v0.8.0
type ListComprehension ¶
type ListComprehension struct {
Expression Expression
Variables []Expression // supports tuple unpacking like: for h, t in ...
Iterable Expression
Condition Expression // optional
AdditionalClauses []ComprehensionClause // additional for clauses
}
func (*ListComprehension) Line ¶
func (lc *ListComprehension) Line() int
func (*ListComprehension) TokenLiteral ¶
func (lc *ListComprehension) TokenLiteral() string
type ListLiteral ¶
type ListLiteral struct {
Elements []Expression
}
func (*ListLiteral) Line ¶
func (ll *ListLiteral) Line() int
func (*ListLiteral) TokenLiteral ¶
func (ll *ListLiteral) TokenLiteral() string
type MatchStatement ¶
type MatchStatement struct {
Token LineInfo // The 'match' token
Subject Expression // The expression to match against
Cases []*CaseClause
}
MatchStatement represents a match statement with multiple case clauses
func (*MatchStatement) Line ¶
func (ms *MatchStatement) Line() int
func (*MatchStatement) TokenLiteral ¶
func (ms *MatchStatement) TokenLiteral() string
type MethodCallExpression ¶
type MethodCallExpression struct {
Receiver Expression
Method *Identifier
Arguments []Expression
// contains filtered or unexported fields
}
func (*MethodCallExpression) GetArgsUnpack ¶ added in v0.8.0
func (mce *MethodCallExpression) GetArgsUnpack() []Expression
func (*MethodCallExpression) GetKeywords ¶ added in v0.8.0
func (mce *MethodCallExpression) GetKeywords() map[string]Expression
func (*MethodCallExpression) GetKwargsUnpack ¶ added in v0.8.0
func (mce *MethodCallExpression) GetKwargsUnpack() Expression
func (*MethodCallExpression) HasOverflow ¶ added in v0.8.0
func (mce *MethodCallExpression) HasOverflow() bool
func (*MethodCallExpression) Line ¶
func (mce *MethodCallExpression) Line() int
func (*MethodCallExpression) SetOverflow ¶ added in v0.8.0
func (mce *MethodCallExpression) SetOverflow(keywords map[string]Expression, argsUnpack []Expression, kwargsUnpack Expression)
func (*MethodCallExpression) TokenLiteral ¶
func (mce *MethodCallExpression) TokenLiteral() string
type MultipleAssignStatement ¶
type MultipleAssignStatement struct {
Token LineInfo
Names []*Identifier
Value Expression
StarredIndex int // Index of starred variable (-1 if none)
}
func (*MultipleAssignStatement) Line ¶
func (mas *MultipleAssignStatement) Line() int
func (*MultipleAssignStatement) TokenLiteral ¶
func (mas *MultipleAssignStatement) TokenLiteral() string
type NonlocalStatement ¶
type NonlocalStatement struct {
Token LineInfo
Names []*Identifier
}
func (*NonlocalStatement) Line ¶
func (ns *NonlocalStatement) Line() int
func (*NonlocalStatement) TokenLiteral ¶
func (ns *NonlocalStatement) TokenLiteral() string
type Op ¶ added in v0.8.0
type Op byte
const ( OpNil Op = iota // Arithmetic group (1-12): OpAdd..OpDiv OpAdd OpSub OpMul OpFloorDiv OpMod OpPow OpBitAnd OpBitOr OpBitXor OpLShift OpRShift OpDiv // Comparison group (13-18): OpLt..OpNeq OpLt OpGt OpLte OpGte OpEq OpNeq // Short-circuit logical OpAnd OpOr // Membership/Identity OpIn OpNotIn OpIs OpIsNot // Prefix OpNot OpBitNot OpPos // Augmented assignment: base op + opAugOffset OpAddEq OpSubEq OpMulEq OpFloorDivEq OpModEq OpPowEq OpBitAndEq OpBitOrEq OpBitXorEq OpLShiftEq OpRShiftEq OpDivEq )
func (Op) IsArithmetic ¶ added in v0.8.0
func (Op) IsComparison ¶ added in v0.8.0
type OrPattern ¶ added in v0.2.0
type OrPattern struct {
Patterns []Expression
}
OrPattern represents a pattern like `case 1 | 2 | 3:`
func (*OrPattern) TokenLiteral ¶ added in v0.2.0
type PassStatement ¶
type PassStatement struct {
Token LineInfo
}
func (*PassStatement) Line ¶
func (ps *PassStatement) Line() int
func (*PassStatement) TokenLiteral ¶
func (ps *PassStatement) TokenLiteral() string
type PrefixExpression ¶
type PrefixExpression struct {
Operator Op
Right Expression
}
func (*PrefixExpression) Line ¶
func (pe *PrefixExpression) Line() int
func (*PrefixExpression) TokenLiteral ¶
func (pe *PrefixExpression) TokenLiteral() string
type Program ¶
type Program struct {
Statements []Statement
Symbols *SymbolTable
LocalSlots map[string]int
LocalSlotNames []string
}
func (*Program) TokenLiteral ¶
type RaiseStatement ¶
type RaiseStatement struct {
Token LineInfo
Message Expression
}
func (*RaiseStatement) Line ¶
func (rs *RaiseStatement) Line() int
func (*RaiseStatement) TokenLiteral ¶
func (rs *RaiseStatement) TokenLiteral() string
type ReturnStatement ¶
type ReturnStatement struct {
Token LineInfo
ReturnValue Expression
}
func (*ReturnStatement) Line ¶
func (rs *ReturnStatement) Line() int
func (*ReturnStatement) TokenLiteral ¶
func (rs *ReturnStatement) TokenLiteral() string
type SetComprehension ¶ added in v0.2.23
type SetComprehension struct {
Expression Expression
Variables []Expression
Iterable Expression
Condition Expression // optional
AdditionalClauses []ComprehensionClause // additional for clauses
}
func (*SetComprehension) Line ¶ added in v0.2.23
func (sc *SetComprehension) Line() int
func (*SetComprehension) TokenLiteral ¶ added in v0.2.23
func (sc *SetComprehension) TokenLiteral() string
type SetLiteral ¶ added in v0.2.0
type SetLiteral struct {
Elements []Expression
}
func (*SetLiteral) Line ¶ added in v0.2.0
func (sl *SetLiteral) Line() int
func (*SetLiteral) TokenLiteral ¶ added in v0.2.0
func (sl *SetLiteral) TokenLiteral() string
type SliceExpression ¶
type SliceExpression struct {
Left Expression
Start Expression
End Expression
// contains filtered or unexported fields
}
func (*SliceExpression) GetStep ¶ added in v0.8.0
func (se *SliceExpression) GetStep() Expression
func (*SliceExpression) Line ¶
func (se *SliceExpression) Line() int
func (*SliceExpression) SetStep ¶ added in v0.8.0
func (se *SliceExpression) SetStep(step Expression)
func (*SliceExpression) TokenLiteral ¶
func (se *SliceExpression) TokenLiteral() string
type SliceOverflow ¶ added in v0.8.0
type SliceOverflow struct {
Step Expression
}
type StringLiteral ¶
type StringLiteral struct {
Value string
}
func (*StringLiteral) Line ¶
func (sl *StringLiteral) Line() int
func (*StringLiteral) TokenLiteral ¶
func (sl *StringLiteral) TokenLiteral() string
type SymbolTable ¶ added in v0.8.0
type SymbolTable struct {
// contains filtered or unexported fields
}
func NewSymbolTable ¶ added in v0.8.0
func NewSymbolTable() *SymbolTable
func (*SymbolTable) Freeze ¶ added in v0.8.0
func (st *SymbolTable) Freeze()
func (*SymbolTable) Intern ¶ added in v0.8.0
func (st *SymbolTable) Intern(name string) uint32
func (*SymbolTable) Resolve ¶ added in v0.8.0
func (st *SymbolTable) Resolve(id uint32) string
type TryStatement ¶
type TryStatement struct {
Token LineInfo
Body *BlockStatement
ExceptClauses []*ExceptClause // multiple except blocks
Else *BlockStatement // runs only when no exception was raised
Finally *BlockStatement
}
func (*TryStatement) Line ¶
func (ts *TryStatement) Line() int
func (*TryStatement) TokenLiteral ¶
func (ts *TryStatement) TokenLiteral() string
type TupleLiteral ¶
type TupleLiteral struct {
Elements []Expression
}
func (*TupleLiteral) Line ¶
func (tl *TupleLiteral) Line() int
func (*TupleLiteral) TokenLiteral ¶
func (tl *TupleLiteral) TokenLiteral() string
type WhileStatement ¶
type WhileStatement struct {
Token LineInfo
Condition Expression
Body *BlockStatement
Else *BlockStatement // optional else clause
}
func (*WhileStatement) Line ¶
func (ws *WhileStatement) Line() int
func (*WhileStatement) TokenLiteral ¶
func (ws *WhileStatement) TokenLiteral() string
type WithStatement ¶ added in v0.2.0
type WithStatement struct {
Token LineInfo
ContextExpr Expression
Target *Identifier // optional: 'as' binding
Body *BlockStatement
}
func (*WithStatement) Line ¶ added in v0.2.0
func (ws *WithStatement) Line() int
func (*WithStatement) TokenLiteral ¶ added in v0.2.0
func (ws *WithStatement) TokenLiteral() string