model

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Keywords = map[string]TokenKind{
	"False":    TK_False,
	"None":     TK_None,
	"True":     TK_True,
	"and":      TK_And,
	"as":       TK_As,
	"assert":   TK_Assert,
	"async":    TK_Async,
	"await":    TK_Await,
	"break":    TK_Break,
	"case":     TK_Case,
	"class":    TK_Class,
	"continue": TK_Continue,
	"def":      TK_Def,
	"del":      TK_Del,
	"elif":     TK_Elif,
	"else":     TK_Else,
	"except":   TK_Except,
	"finally":  TK_Finally,
	"for":      TK_For,
	"from":     TK_From,
	"global":   TK_Global,
	"if":       TK_If,
	"import":   TK_Import,
	"in":       TK_In,
	"is":       TK_Is,
	"lambda":   TK_Lambda,
	"match":    TK_Match,
	"nonlocal": TK_Nonlocal,
	"not":      TK_Not,
	"or":       TK_Or,
	"pass":     TK_Pass,
	"raise":    TK_Raise,
	"return":   TK_Return,
	"try":      TK_Try,
	"while":    TK_While,
	"with":     TK_With,
	"yield":    TK_Yield,
}

Keywords maps Python keywords to their token kinds.

Functions

This section is empty.

Types

type Alias

type Alias struct {
	Name     *Identifier
	AsName   *Identifier // can be nil
	StartPos Position
	EndPos   Position
}

Alias represents an import alias.

func (*Alias) End

func (a *Alias) End() Position

func (*Alias) Pos

func (a *Alias) Pos() Position

type AnnAssign

type AnnAssign struct {
	Target     Expr
	Annotation Expr
	Value      Expr // can be nil
	Simple     bool
	StartPos   Position
}

AnnAssign represents an annotated assignment.

func (*AnnAssign) End

func (a *AnnAssign) End() Position

func (*AnnAssign) Pos

func (a *AnnAssign) Pos() Position

type Arg

type Arg struct {
	Arg        *Identifier
	Annotation Expr // can be nil
	StartPos   Position
	EndPos     Position
}

Arg represents a single argument.

func (*Arg) End

func (a *Arg) End() Position

func (*Arg) Pos

func (a *Arg) Pos() Position

type Arguments

type Arguments struct {
	PosOnlyArgs []*Arg
	Args        []*Arg
	VarArg      *Arg // *args
	KwOnlyArgs  []*Arg
	KwDefaults  []Expr // defaults for kwonly args
	KwArg       *Arg   // **kwargs
	Defaults    []Expr // defaults for positional args
}

Arguments represents function arguments.

type Assert

type Assert struct {
	Test     Expr
	Msg      Expr // can be nil
	StartPos Position
	EndPos   Position
}

Assert represents an assert statement.

func (*Assert) End

func (a *Assert) End() Position

func (*Assert) Pos

func (a *Assert) Pos() Position

type Assign

type Assign struct {
	Targets []Expr
	Value   Expr
}

Assign represents an assignment statement.

func (*Assign) End

func (a *Assign) End() Position

func (*Assign) Pos

func (a *Assign) Pos() Position

type Attribute

type Attribute struct {
	Value Expr
	Attr  *Identifier
}

Attribute represents attribute access (obj.attr).

func (*Attribute) End

func (a *Attribute) End() Position

func (*Attribute) Pos

func (a *Attribute) Pos() Position

type AugAssign

type AugAssign struct {
	Target Expr
	Op     TokenKind
	Value  Expr
}

AugAssign represents an augmented assignment (+=, -=, etc.).

func (*AugAssign) End

func (a *AugAssign) End() Position

func (*AugAssign) Pos

func (a *AugAssign) Pos() Position

type Await

type Await struct {
	Value    Expr
	StartPos Position
}

Await represents an await expression.

func (*Await) End

func (a *Await) End() Position

func (*Await) Pos

func (a *Await) Pos() Position

type BinaryOp

type BinaryOp struct {
	Left  Expr
	Op    TokenKind
	Right Expr
}

BinaryOp represents a binary operation.

func (*BinaryOp) End

func (b *BinaryOp) End() Position

func (*BinaryOp) Pos

func (b *BinaryOp) Pos() Position

type BoolLit

type BoolLit struct {
	Value    bool
	StartPos Position
	EndPos   Position
}

BoolLit represents True or False.

func (*BoolLit) End

func (b *BoolLit) End() Position

func (*BoolLit) Pos

func (b *BoolLit) Pos() Position

type BoolOp

type BoolOp struct {
	Op     TokenKind // TK_And or TK_Or
	Values []Expr
}

BoolOp represents 'and' / 'or' with multiple values.

func (*BoolOp) End

func (b *BoolOp) End() Position

func (*BoolOp) Pos

func (b *BoolOp) Pos() Position

type Break

type Break struct {
	StartPos Position
	EndPos   Position
}

Break represents a break statement.

func (*Break) End

func (b *Break) End() Position

func (*Break) Pos

func (b *Break) Pos() Position

type BytesLit

type BytesLit struct {
	Value    string
	StartPos Position
	EndPos   Position
}

BytesLit represents a bytes literal.

func (*BytesLit) End

func (b *BytesLit) End() Position

func (*BytesLit) Pos

func (b *BytesLit) Pos() Position

type Call

type Call struct {
	Func     Expr
	Args     []Expr
	Keywords []*Keyword
	EndPos   Position
}

Call represents a function call.

func (*Call) End

func (c *Call) End() Position

func (*Call) Pos

func (c *Call) Pos() Position

type ClassDef

type ClassDef struct {
	Name       *Identifier
	Bases      []Expr
	Keywords   []*Keyword
	Body       []Stmt
	Decorators []Expr
	StartPos   Position
	EndPos     Position
}

ClassDef represents a class definition.

func (*ClassDef) End

func (c *ClassDef) End() Position

func (*ClassDef) Pos

func (c *ClassDef) Pos() Position

type Compare

type Compare struct {
	Left        Expr
	Ops         []TokenKind
	Comparators []Expr
}

Compare represents a comparison (can be chained: a < b < c).

func (*Compare) End

func (c *Compare) End() Position

func (*Compare) Pos

func (c *Compare) Pos() Position

type Comprehension

type Comprehension struct {
	Target  Expr
	Iter    Expr
	Ifs     []Expr
	IsAsync bool
}

Comprehension represents a single for clause in a comprehension.

type Continue

type Continue struct {
	StartPos Position
	EndPos   Position
}

Continue represents a continue statement.

func (*Continue) End

func (c *Continue) End() Position

func (*Continue) Pos

func (c *Continue) Pos() Position

type Delete

type Delete struct {
	Targets  []Expr
	StartPos Position
}

Delete represents a del statement.

func (*Delete) End

func (d *Delete) End() Position

func (*Delete) Pos

func (d *Delete) Pos() Position

type Dict

type Dict struct {
	Keys     []Expr // nil key means **unpacking
	Values   []Expr
	StartPos Position
	EndPos   Position
}

Dict represents a dictionary {k: v, ...}.

func (*Dict) End

func (d *Dict) End() Position

func (*Dict) Pos

func (d *Dict) Pos() Position

type DictComp

type DictComp struct {
	Key        Expr
	Value      Expr
	Generators []*Comprehension
	StartPos   Position
	EndPos     Position
}

DictComp represents a dict comprehension {k: v for k, v in items}.

func (*DictComp) End

func (d *DictComp) End() Position

func (*DictComp) Pos

func (d *DictComp) Pos() Position

type Ellipsis

type Ellipsis struct {
	StartPos Position
	EndPos   Position
}

Ellipsis represents the ... literal.

func (*Ellipsis) End

func (e *Ellipsis) End() Position

func (*Ellipsis) Pos

func (e *Ellipsis) Pos() Position

type ExceptHandler

type ExceptHandler struct {
	Type     Expr        // can be nil for bare except
	Name     *Identifier // can be nil
	Body     []Stmt
	IsStar   bool // true for "except* Type:"
	StartPos Position
	EndPos   Position
}

ExceptHandler represents an except clause.

func (*ExceptHandler) End

func (e *ExceptHandler) End() Position

func (*ExceptHandler) Pos

func (e *ExceptHandler) Pos() Position

type Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

Expr is the interface for all expression nodes.

type ExprStmt

type ExprStmt struct {
	Value Expr
}

ExprStmt represents an expression statement.

func (*ExprStmt) End

func (e *ExprStmt) End() Position

func (*ExprStmt) Pos

func (e *ExprStmt) Pos() Position

type FStringLit

type FStringLit struct {
	Parts    []FStringPart
	StartPos Position
	EndPos   Position
}

FStringLit represents an f-string literal like f"hello {name}".

func (*FStringLit) End

func (f *FStringLit) End() Position

func (*FStringLit) Pos

func (f *FStringLit) Pos() Position

type FStringPart

type FStringPart struct {
	IsExpr     bool   // true if this part is an expression, false if literal string
	Value      string // the literal string value (if IsExpr is false)
	Expr       Expr   // the expression (if IsExpr is true)
	FormatSpec string // optional format spec after ':'
	Conversion byte   // 0 for none, 'r' for !r, 's' for !s, 'a' for !a
}

FStringPart represents either a string literal or an expression in an f-string.

type FloatLit

type FloatLit struct {
	Value    string
	StartPos Position
	EndPos   Position
}

FloatLit represents a floating-point literal.

func (*FloatLit) End

func (f *FloatLit) End() Position

func (*FloatLit) Pos

func (f *FloatLit) Pos() Position

type For

type For struct {
	Target   Expr
	Iter     Expr
	Body     []Stmt
	OrElse   []Stmt
	IsAsync  bool
	StartPos Position
	EndPos   Position
}

For represents a for statement.

func (*For) End

func (f *For) End() Position

func (*For) Pos

func (f *For) Pos() Position

type FunctionDef

type FunctionDef struct {
	Name       *Identifier
	Args       *Arguments
	Body       []Stmt
	Decorators []Expr
	Returns    Expr // return type annotation, can be nil
	IsAsync    bool
	StartPos   Position
	EndPos     Position
}

FunctionDef represents a function definition.

func (*FunctionDef) End

func (f *FunctionDef) End() Position

func (*FunctionDef) Pos

func (f *FunctionDef) Pos() Position

type GeneratorExpr

type GeneratorExpr struct {
	Elt        Expr
	Generators []*Comprehension
	StartPos   Position
	EndPos     Position
}

GeneratorExpr represents a generator expression (x for x in xs).

func (*GeneratorExpr) End

func (g *GeneratorExpr) End() Position

func (*GeneratorExpr) Pos

func (g *GeneratorExpr) Pos() Position

type Global

type Global struct {
	Names    []*Identifier
	StartPos Position
	EndPos   Position
}

Global represents a global statement.

func (*Global) End

func (g *Global) End() Position

func (*Global) Pos

func (g *Global) Pos() Position

type Identifier

type Identifier struct {
	Name     string
	StartPos Position
	EndPos   Position
}

Identifier represents a name/identifier.

func (*Identifier) End

func (i *Identifier) End() Position

func (*Identifier) Pos

func (i *Identifier) Pos() Position

type If

type If struct {
	Test     Expr
	Body     []Stmt
	OrElse   []Stmt // can include elif (nested If) or else body
	StartPos Position
	EndPos   Position
}

If represents an if statement.

func (*If) End

func (i *If) End() Position

func (*If) Pos

func (i *If) Pos() Position

type IfExpr

type IfExpr struct {
	Test   Expr
	Body   Expr
	OrElse Expr
}

IfExpr represents a conditional expression (a if cond else b).

func (*IfExpr) End

func (i *IfExpr) End() Position

func (*IfExpr) Pos

func (i *IfExpr) Pos() Position

type ImaginaryLit

type ImaginaryLit struct {
	Value    string
	StartPos Position
	EndPos   Position
}

ImaginaryLit represents an imaginary number literal.

func (*ImaginaryLit) End

func (i *ImaginaryLit) End() Position

func (*ImaginaryLit) Pos

func (i *ImaginaryLit) Pos() Position

type Import

type Import struct {
	Names    []*Alias
	StartPos Position
	EndPos   Position
}

Import represents an import statement.

func (*Import) End

func (i *Import) End() Position

func (*Import) Pos

func (i *Import) Pos() Position

type ImportFrom

type ImportFrom struct {
	Module   *Identifier // can be nil for relative imports
	Names    []*Alias
	Level    int // number of dots for relative import
	StartPos Position
	EndPos   Position
}

ImportFrom represents a from ... import statement.

func (*ImportFrom) End

func (i *ImportFrom) End() Position

func (*ImportFrom) Pos

func (i *ImportFrom) Pos() Position

type IntLit

type IntLit struct {
	Value    string
	StartPos Position
	EndPos   Position
}

IntLit represents an integer literal.

func (*IntLit) End

func (i *IntLit) End() Position

func (*IntLit) Pos

func (i *IntLit) Pos() Position

type Keyword

type Keyword struct {
	Arg      *Identifier // nil for **kwargs
	Value    Expr
	StartPos Position
}

Keyword represents a keyword argument in a call.

func (*Keyword) End

func (k *Keyword) End() Position

func (*Keyword) Pos

func (k *Keyword) Pos() Position

type Lambda

type Lambda struct {
	Args     *Arguments
	Body     Expr
	StartPos Position
}

Lambda represents a lambda expression.

func (*Lambda) End

func (l *Lambda) End() Position

func (*Lambda) Pos

func (l *Lambda) Pos() Position

type List

type List struct {
	Elts     []Expr
	StartPos Position
	EndPos   Position
}

List represents a list literal [a, b, c].

func (*List) End

func (l *List) End() Position

func (*List) Pos

func (l *List) Pos() Position

type ListComp

type ListComp struct {
	Elt        Expr
	Generators []*Comprehension
	StartPos   Position
	EndPos     Position
}

ListComp represents a list comprehension [x for x in xs].

func (*ListComp) End

func (l *ListComp) End() Position

func (*ListComp) Pos

func (l *ListComp) Pos() Position

type Match

type Match struct {
	Subject  Expr
	Cases    []*MatchCase
	StartPos Position
	EndPos   Position
}

Match represents a match statement.

func (*Match) End

func (m *Match) End() Position

func (*Match) Pos

func (m *Match) Pos() Position

type MatchAs

type MatchAs struct {
	Pattern  Pattern     // nil for wildcard _
	Name     *Identifier // nil for wildcard _
	StartPos Position
	EndPos   Position
}

MatchAs represents an as pattern or wildcard.

func (*MatchAs) End

func (m *MatchAs) End() Position

func (*MatchAs) Pos

func (m *MatchAs) Pos() Position

type MatchCase

type MatchCase struct {
	Pattern  Pattern
	Guard    Expr // can be nil
	Body     []Stmt
	StartPos Position
	EndPos   Position
}

MatchCase represents a case in a match statement.

func (*MatchCase) End

func (m *MatchCase) End() Position

func (*MatchCase) Pos

func (m *MatchCase) Pos() Position

type MatchClass

type MatchClass struct {
	Cls         Expr
	Patterns    []Pattern
	KwdAttrs    []*Identifier
	KwdPatterns []Pattern
	StartPos    Position
	EndPos      Position
}

MatchClass represents a class pattern Cls(a, b=c).

func (*MatchClass) End

func (m *MatchClass) End() Position

func (*MatchClass) Pos

func (m *MatchClass) Pos() Position

type MatchMapping

type MatchMapping struct {
	Keys     []Expr
	Patterns []Pattern
	Rest     *Identifier // **rest, can be nil
	StartPos Position
	EndPos   Position
}

MatchMapping represents a mapping pattern {k: v, ...}.

func (*MatchMapping) End

func (m *MatchMapping) End() Position

func (*MatchMapping) Pos

func (m *MatchMapping) Pos() Position

type MatchOr

type MatchOr struct {
	Patterns []Pattern
	StartPos Position
	EndPos   Position
}

MatchOr represents an or pattern a | b | c.

func (*MatchOr) End

func (m *MatchOr) End() Position

func (*MatchOr) Pos

func (m *MatchOr) Pos() Position

type MatchSequence

type MatchSequence struct {
	Patterns []Pattern
	StartPos Position
	EndPos   Position
}

MatchSequence represents a sequence pattern [a, b, c].

func (*MatchSequence) End

func (m *MatchSequence) End() Position

func (*MatchSequence) Pos

func (m *MatchSequence) Pos() Position

type MatchSingleton

type MatchSingleton struct {
	Value    Expr
	StartPos Position
	EndPos   Position
}

MatchSingleton represents True, False, or None in patterns.

func (*MatchSingleton) End

func (m *MatchSingleton) End() Position

func (*MatchSingleton) Pos

func (m *MatchSingleton) Pos() Position

type MatchStar

type MatchStar struct {
	Name     *Identifier // can be nil for _
	StartPos Position
	EndPos   Position
}

MatchStar represents a starred pattern *rest.

func (*MatchStar) End

func (m *MatchStar) End() Position

func (*MatchStar) Pos

func (m *MatchStar) Pos() Position

type MatchValue

type MatchValue struct {
	Value    Expr
	StartPos Position
	EndPos   Position
}

MatchValue represents a literal or constant pattern.

func (*MatchValue) End

func (m *MatchValue) End() Position

func (*MatchValue) Pos

func (m *MatchValue) Pos() Position

type Module

type Module struct {
	Body     []Stmt
	StartPos Position
	EndPos   Position
}

Module represents a complete Python module (file).

func (*Module) End

func (m *Module) End() Position

func (*Module) Pos

func (m *Module) Pos() Position

type NamedExpr

type NamedExpr struct {
	Target *Identifier
	Value  Expr
}

NamedExpr represents a named expression (walrus operator x := value).

func (*NamedExpr) End

func (n *NamedExpr) End() Position

func (*NamedExpr) Pos

func (n *NamedExpr) Pos() Position

type Node

type Node interface {
	Pos() Position
	End() Position
}

Node is the base interface for all AST nodes.

type NoneLit

type NoneLit struct {
	StartPos Position
	EndPos   Position
}

NoneLit represents None.

func (*NoneLit) End

func (n *NoneLit) End() Position

func (*NoneLit) Pos

func (n *NoneLit) Pos() Position

type Nonlocal

type Nonlocal struct {
	Names    []*Identifier
	StartPos Position
	EndPos   Position
}

Nonlocal represents a nonlocal statement.

func (*Nonlocal) End

func (n *Nonlocal) End() Position

func (*Nonlocal) Pos

func (n *Nonlocal) Pos() Position

type Pass

type Pass struct {
	StartPos Position
	EndPos   Position
}

Pass represents a pass statement.

func (*Pass) End

func (p *Pass) End() Position

func (*Pass) Pos

func (p *Pass) Pos() Position

type Pattern

type Pattern interface {
	Node
	// contains filtered or unexported methods
}

Pattern is the interface for match patterns.

type Position

type Position struct {
	Filename string
	Line     int
	Column   int
	Offset   int
}

Position represents a position in the source code.

func (Position) String

func (p Position) String() string

type Raise

type Raise struct {
	Exc      Expr // can be nil
	Cause    Expr // can be nil
	StartPos Position
	EndPos   Position
}

Raise represents a raise statement.

func (*Raise) End

func (r *Raise) End() Position

func (*Raise) Pos

func (r *Raise) Pos() Position

type Return

type Return struct {
	Value    Expr // can be nil
	StartPos Position
	EndPos   Position
}

Return represents a return statement.

func (*Return) End

func (r *Return) End() Position

func (*Return) Pos

func (r *Return) Pos() Position

type Set

type Set struct {
	Elts     []Expr
	StartPos Position
	EndPos   Position
}

Set represents a set literal {a, b, c}.

func (*Set) End

func (s *Set) End() Position

func (*Set) Pos

func (s *Set) Pos() Position

type SetComp

type SetComp struct {
	Elt        Expr
	Generators []*Comprehension
	StartPos   Position
	EndPos     Position
}

SetComp represents a set comprehension {x for x in xs}.

func (*SetComp) End

func (s *SetComp) End() Position

func (*SetComp) Pos

func (s *SetComp) Pos() Position

type Slice

type Slice struct {
	Lower    Expr // can be nil
	Upper    Expr // can be nil
	Step     Expr // can be nil
	StartPos Position
	EndPos   Position
}

Slice represents a slice (lower:upper:step).

func (*Slice) End

func (s *Slice) End() Position

func (*Slice) Pos

func (s *Slice) Pos() Position

type Starred

type Starred struct {
	Value    Expr
	StartPos Position
}

Starred represents a starred expression (*x).

func (*Starred) End

func (s *Starred) End() Position

func (*Starred) Pos

func (s *Starred) Pos() Position

type Stmt

type Stmt interface {
	Node
	// contains filtered or unexported methods
}

Stmt is the interface for all statement nodes.

type StringLit

type StringLit struct {
	Value    string
	StartPos Position
	EndPos   Position
}

StringLit represents a string literal.

func (*StringLit) End

func (s *StringLit) End() Position

func (*StringLit) Pos

func (s *StringLit) Pos() Position

type Subscript

type Subscript struct {
	Value  Expr
	Slice  Expr
	EndPos Position
}

Subscript represents subscription (obj[index]).

func (*Subscript) End

func (s *Subscript) End() Position

func (*Subscript) Pos

func (s *Subscript) Pos() Position

type Token

type Token struct {
	Kind    TokenKind
	Literal string
	Pos     Position
	EndPos  Position
}

Token represents a lexical token.

func (Token) String

func (t Token) String() string

type TokenKind

type TokenKind int

TokenKind represents the type of a Python token.

const (
	// Special tokens
	TK_Illegal TokenKind = iota
	TK_Newline
	TK_Indent
	TK_Dedent
	TK_Comment

	// Literals
	TK_Identifier
	TK_IntLit
	TK_FloatLit
	TK_ImaginaryLit
	TK_StringLit
	TK_BytesLit
	TK_FStringLit
	TK_FStringStart
	TK_FStringMiddle
	TK_FStringEnd

	// Keywords
	TK_False
	TK_None
	TK_True
	TK_And
	TK_As
	TK_Assert
	TK_Async
	TK_Await
	TK_Break
	TK_Case
	TK_Class
	TK_Continue
	TK_Def
	TK_Del
	TK_Elif
	TK_Else
	TK_Except
	TK_Finally
	TK_For
	TK_From
	TK_Global
	TK_If
	TK_Import
	TK_In
	TK_Is
	TK_Lambda
	TK_Match
	TK_Nonlocal
	TK_Not
	TK_Or
	TK_Pass
	TK_Raise
	TK_Return
	TK_Try
	TK_Type
	TK_While
	TK_With
	TK_Yield

	// Operators
	TK_Plus         // +
	TK_Minus        // -
	TK_Star         // *
	TK_DoubleStar   // **
	TK_Slash        // /
	TK_DoubleSlash  // //
	TK_Percent      // %
	TK_At           // @
	TK_LShift       // <<
	TK_RShift       // >>
	TK_Ampersand    // &
	TK_Pipe         // |
	TK_Caret        // ^
	TK_Tilde        // ~
	TK_Walrus       // :=
	TK_Less         // <
	TK_Greater      // >
	TK_LessEqual    // <=
	TK_GreaterEqual // >=
	TK_Equal        // ==
	TK_NotEqual     // !=
	TK_Arrow        // ->
	TK_NotIn        // not in (compound)
	TK_IsNot        // is not (compound)

	// Delimiters
	TK_LParen            // (
	TK_RParen            // )
	TK_LBracket          // [
	TK_RBracket          // ]
	TK_LBrace            // {
	TK_RBrace            // }
	TK_Comma             // ,
	TK_Colon             // :
	TK_Semicolon         // ;
	TK_Dot               // .
	TK_Ellipsis          // ...
	TK_Assign            // =
	TK_PlusAssign        // +=
	TK_MinusAssign       // -=
	TK_StarAssign        // *=
	TK_SlashAssign       // /=
	TK_DoubleSlashAssign // //=
	TK_PercentAssign     // %=
	TK_AtAssign          // @=
	TK_AmpersandAssign   // &=
	TK_PipeAssign        // |=
	TK_CaretAssign       // ^=
	TK_RShiftAssign      // >>=
	TK_LShiftAssign      // <<=
	TK_DoubleStarAssign  // **=

	TK_EOF
)

func LookupIdent

func LookupIdent(ident string) TokenKind

LookupIdent checks if an identifier is a keyword.

func (TokenKind) String

func (tk TokenKind) String() string

type Try

type Try struct {
	Body      []Stmt
	Handlers  []*ExceptHandler
	OrElse    []Stmt
	FinalBody []Stmt
	StartPos  Position
	EndPos    Position
}

Try represents a try statement.

func (*Try) End

func (t *Try) End() Position

func (*Try) Pos

func (t *Try) Pos() Position

type Tuple

type Tuple struct {
	Elts     []Expr
	StartPos Position
	EndPos   Position
}

Tuple represents a tuple (a, b, c).

func (*Tuple) End

func (t *Tuple) End() Position

func (*Tuple) Pos

func (t *Tuple) Pos() Position

type TypeAlias

type TypeAlias struct {
	Name       *Identifier
	TypeParams []*TypeParam
	Value      Expr
	StartPos   Position
	EndPos     Position
}

TypeAlias represents a type alias statement (type X = ...).

func (*TypeAlias) End

func (t *TypeAlias) End() Position

func (*TypeAlias) Pos

func (t *TypeAlias) Pos() Position

type TypeParam

type TypeParam struct {
	Name     *Identifier
	Bound    Expr // can be nil
	StartPos Position
	EndPos   Position
}

TypeParam represents a type parameter.

func (*TypeParam) End

func (t *TypeParam) End() Position

func (*TypeParam) Pos

func (t *TypeParam) Pos() Position

type UnaryOp

type UnaryOp struct {
	Op       TokenKind
	Operand  Expr
	StartPos Position
}

UnaryOp represents a unary operation.

func (*UnaryOp) End

func (u *UnaryOp) End() Position

func (*UnaryOp) Pos

func (u *UnaryOp) Pos() Position

type While

type While struct {
	Test     Expr
	Body     []Stmt
	OrElse   []Stmt
	StartPos Position
	EndPos   Position
}

While represents a while statement.

func (*While) End

func (w *While) End() Position

func (*While) Pos

func (w *While) Pos() Position

type With

type With struct {
	Items    []*WithItem
	Body     []Stmt
	IsAsync  bool
	StartPos Position
	EndPos   Position
}

With represents a with statement.

func (*With) End

func (w *With) End() Position

func (*With) Pos

func (w *With) Pos() Position

type WithItem

type WithItem struct {
	ContextExpr Expr
	OptionalVar Expr // can be nil
}

WithItem represents a single item in a with statement.

type Yield

type Yield struct {
	Value    Expr // can be nil
	StartPos Position
	EndPos   Position
}

Yield represents a yield expression.

func (*Yield) End

func (y *Yield) End() Position

func (*Yield) Pos

func (y *Yield) Pos() Position

type YieldFrom

type YieldFrom struct {
	Value    Expr
	StartPos Position
}

YieldFrom represents a yield from expression.

func (*YieldFrom) End

func (y *YieldFrom) End() Position

func (*YieldFrom) Pos

func (y *YieldFrom) Pos() Position

Jump to

Keyboard shortcuts

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