Documentation
¶
Overview ¶
Package ast declares the syntax tree of Kukel programs (syntax.ebnf, sections 1-3).
Index ¶
- func Fprint(w io.Writer, n Node, withPos bool) error
- func FprintFile(w io.Writer, f *File, withPos bool) error
- func Inspect(n Node, f func(Node) bool)
- type AssignExpr
- type BinaryExpr
- type Block
- type BoolLit
- type BreakStmt
- type CallExpr
- type CaseLabel
- type CharLit
- type ClassDecl
- type CommaExpr
- type CondExpr
- type ConstDecl
- type ContinueStmt
- type Decl
- type DefaultLabel
- type DoStmt
- type EmptyStmt
- type Expr
- type ExprStmt
- type FieldDecl
- type File
- type FloatLit
- type ForEachStmt
- type ForStmt
- type FuncDecl
- type FuncLit
- type GlobalDecl
- type Ident
- type IfStmt
- type IncDecExpr
- type IndexExpr
- type IntLit
- type LabeledStmt
- type LocalDecl
- type MapEntry
- type MapLit
- type Member
- type MemberExpr
- type MethodCall
- type MethodDecl
- type NewExpr
- type NilLit
- type Node
- type Param
- type ParamList
- type ReturnStmt
- type Spread
- type StaticRef
- type Stmt
- type StringLit
- type SwitchStmt
- type ThisExpr
- type ThrowStmt
- type TryStmt
- type UnaryExpr
- type UseDecl
- type VarSpec
- type VectorLit
- type WhileStmt
- type WithStmt
- type YieldStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fprint ¶
Fprint writes n as an indented tree, one node per line. With withPos each line ends with the node's position.
func FprintFile ¶
FprintFile writes a whole file as a tree (see Fprint).
Types ¶
type AssignExpr ¶
AssignExpr is "lhs op rhs" with op one of = += -= *= /= %= &= |= ^= <<= >>=.
func (*AssignExpr) Pos ¶
func (x *AssignExpr) Pos() token.Pos
type BinaryExpr ¶
BinaryExpr is "x op y".
func (*BinaryExpr) Pos ¶
func (x *BinaryExpr) Pos() token.Pos
type ClassDecl ¶
type ClassDecl struct {
Class token.Pos
Name *Ident
BaseModule *Ident // the module of the base class, or nil
Base *Ident // nil without a base class
Members []Member
}
ClassDecl is "class Name [: [module::]Base] { members }".
type CommaExpr ¶
type CommaExpr struct {
List []Expr
}
CommaExpr is "a, b, c": evaluated left to right, value of the last. It occurs only as the first and last part of a for loop.
type ContinueStmt ¶
ContinueStmt is "continue [label];".
func (*ContinueStmt) Pos ¶
func (s *ContinueStmt) Pos() token.Pos
type Decl ¶
type Decl interface {
Node
// contains filtered or unexported methods
}
Decl is a top-level definition.
type DefaultLabel ¶
DefaultLabel is "default:".
func (*DefaultLabel) Pos ¶
func (s *DefaultLabel) Pos() token.Pos
type Expr ¶
type Expr interface {
Node
// contains filtered or unexported methods
}
Expr is an expression.
type File ¶
type File struct {
Name string
Module string // the module the file is, "" for the program's own files (set by the loader)
Decls []Decl // the use declarations come first
// Compiled is set for a module loaded from a .kkc file (kukel build
// -module): the file holds the module's header, the compiler links
// this code instead of compiling function bodies.
Compiled *bytecode.Module
}
File is one parsed source file.
type ForEachStmt ¶
type ForEachStmt struct {
For token.Pos
Key *Ident // the only name with one name
Value *Ident // nil with one name
X Expr
Body Stmt
}
ForEachStmt is "for (local key[, value] in x) body".
func (*ForEachStmt) Pos ¶
func (s *ForEachStmt) Pos() token.Pos
type ForStmt ¶
type ForStmt struct {
For token.Pos
InitVars []*VarSpec // "for (local i = 0, j; ...)"
Init Expr
Cond Expr // nil: loop until break
Post Expr
Body Stmt
}
ForStmt is "for (init; cond; post) body". The initializer is either a local list (InitVars) or an expression (Init); both may be absent.
type FuncDecl ¶
type FuncDecl struct {
Class *Ident // nil for a plain function
Name *Ident
Params *ParamList
Body *Block
}
FuncDecl is a function definition "name(params) { ... }" or, with Class set, a member function definition "Class::name(params) { ... }".
type GlobalDecl ¶
GlobalDecl is "global a, b = 1;".
func (*GlobalDecl) Pos ¶
func (d *GlobalDecl) Pos() token.Pos
type IncDecExpr ¶
type IncDecExpr struct {
Op token.Kind // token.INC or token.DEC
OpPos token.Pos
Prefix bool
X Expr
}
IncDecExpr is "++x", "--x", "x++" or "x--".
func (*IncDecExpr) Pos ¶
func (x *IncDecExpr) Pos() token.Pos
type IntLit ¶
IntLit is an integer literal. A "-" directly before a literal is folded into it, so Value may be negative; Text is then "-" plus the literal.
type LabeledStmt ¶
LabeledStmt is "label: stmt".
func (*LabeledStmt) Pos ¶
func (s *LabeledStmt) Pos() token.Pos
type Member ¶
type Member interface {
Node
// contains filtered or unexported methods
}
Member is a member declaration inside a class: *MethodDecl or *FieldDecl.
type MemberExpr ¶
MemberExpr is "x->name" without a call: a data member or bound method.
func (*MemberExpr) Pos ¶
func (x *MemberExpr) Pos() token.Pos
type MethodCall ¶
MethodCall is "x->name(args)".
func (*MethodCall) Pos ¶
func (x *MethodCall) Pos() token.Pos
type MethodDecl ¶
type MethodDecl struct {
Start token.Pos
Static bool
Name *Ident
Params []*Ident
Rest bool // the last parameter is a rest parameter
}
MethodDecl declares a (static) member function: "[static] name(a, b..);". The parameter names are documentation only.
func (*MethodDecl) Pos ¶
func (m *MethodDecl) Pos() token.Pos
type NewExpr ¶
type NewExpr struct {
New token.Pos
Module *Ident // nil without a module
Class *Ident
Args []Expr // may contain *Spread
}
NewExpr is "new [module::]Class(args)".
type ParamList ¶
type ParamList struct {
Params []*Param
}
ParamList is the parameter list of a function definition or function literal.
type ReturnStmt ¶
ReturnStmt is "return [value];".
func (*ReturnStmt) Pos ¶
func (s *ReturnStmt) Pos() token.Pos
type StaticRef ¶
type StaticRef struct {
Module *Ident // set only for module::Class::name
Class *Ident
Name *Ident
}
StaticRef is "Class::name" (a static member or static function), "module::name" (a top-level name of a module; the compiler tells the two apart) or "module::Class::name".
type Stmt ¶
type Stmt interface {
Node
// contains filtered or unexported methods
}
Stmt is a statement.
type SwitchStmt ¶
SwitchStmt is "switch (tag) body". Case and default labels are statements somewhere inside Body.
func (*SwitchStmt) Pos ¶
func (s *SwitchStmt) Pos() token.Pos
type TryStmt ¶
TryStmt is "try body [catch (v) catch] [finally finally]"; at least one of Catch and Finally is set.