Documentation ¶
Index ¶
- type AdditionalChain
- type ArgList
- type ArrLiteral
- type AssignExpr
- type CallExpr
- type Chain
- type DiamondLiteral
- type EmbeddedStr
- type Expr
- type ExprStmt
- type FloatLiteral
- type FormerStrPiece
- type FuncComponent
- type FuncLiteral
- type Ident
- type IdentAttr
- type IfExpr
- type InfixExpr
- type IntLiteral
- type IterLiteral
- type JumpIfStmt
- type JumpStmt
- type JumpType
- type KwargPair
- type LiteralCallExpr
- type MainChain
- type MapLiteral
- type MatchLiteral
- type Node
- type ObjLiteral
- type Pair
- type PinnedIdent
- type Position
- type PrefixExpr
- type Program
- type PropCallExpr
- type RangeLiteral
- type RecvAndChain
- type Source
- type Stmt
- type StrLiteral
- type SymLiteral
- type VarCallExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdditionalChain ¶
type AdditionalChain int
AdditionalChain is an Enum for additional chain context.
const ( // Vanilla is a Type showing no additional chains. Vanilla AdditionalChain = iota // Lonely is a Type for `&` chain. Lonely // Thoughtful is a Type for `~` chain. Thoughtful // Strict is a Type for `=` chain. Strict )
type ArgList ¶
ArgList is an ast element for argument list.
func ExprToArgList ¶
ExprToArgList makes ArgList with the passed expression.
func KwargPairToArgList ¶
KwargPairToArgList makes ArgList with the passed keyword argument.
func SelfIdentArgList ¶
SelfIdentArgList returns ArgList only with identifier `self`.
func (*ArgList) AppendKwarg ¶
AppendKwarg appends a keyword argument and its value, then returns self.
func (*ArgList) PrependSelf ¶
PrependSelf prepends `self` ident to its arguments, then returns self.
type ArrLiteral ¶
ArrLiteral is an ast node for arr literal like `[1, 2]`.
func (*ArrLiteral) Source ¶
func (al *ArrLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*ArrLiteral) String ¶
func (al *ArrLiteral) String() string
func (*ArrLiteral) TokenLiteral ¶
func (al *ArrLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type AssignExpr ¶
AssignExpr is an ast node of assign expression like `a := 2`.
func (*AssignExpr) Source ¶
func (ae *AssignExpr) Source() *Source
Source returns stacktrace information used for error massages.
func (*AssignExpr) String ¶
func (ae *AssignExpr) String() string
func (*AssignExpr) TokenLiteral ¶
func (ae *AssignExpr) TokenLiteral() string
TokenLiteral returns token given by lexer.
type Chain ¶
type Chain struct { Token string Additional AdditionalChain Main MainChain Arg Expr }
Chain is an ast element for chain like `.`.
type DiamondLiteral ¶
DiamondLiteral is an ast node for diamond literal `<>`.
func (*DiamondLiteral) Source ¶
func (dl *DiamondLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*DiamondLiteral) String ¶
func (dl *DiamondLiteral) String() string
func (*DiamondLiteral) TokenLiteral ¶
func (dl *DiamondLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type EmbeddedStr ¶
type EmbeddedStr struct { Token string Former *FormerStrPiece Latter string Src *Source }
EmbeddedStr is an ast node of embedded string like `"value=#{1 + 1}"`.
func (*EmbeddedStr) Source ¶
func (es *EmbeddedStr) Source() *Source
Source returns stacktrace information used for error massages.
func (*EmbeddedStr) String ¶
func (es *EmbeddedStr) String() string
func (*EmbeddedStr) TokenLiteral ¶
func (es *EmbeddedStr) TokenLiteral() string
TokenLiteral returns token given by lexer.
type Expr ¶
type Expr interface { Node // contains filtered or unexported methods }
Expr is an interface of ast expression node.
type ExprStmt ¶
ExprStmt is an ast node of statement which consists of just one expression.
func (*ExprStmt) TokenLiteral ¶
TokenLiteral returns token given by lexer.
type FloatLiteral ¶
FloatLiteral is an ast node for float literal like `1.0`.
func (*FloatLiteral) Source ¶
func (fl *FloatLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*FloatLiteral) String ¶
func (fl *FloatLiteral) String() string
func (*FloatLiteral) TokenLiteral ¶
func (fl *FloatLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type FormerStrPiece ¶
type FormerStrPiece struct { Token string Former *FormerStrPiece Str string Expr Expr }
FormerStrPiece is a former part of EmbeddedStr expression. NOTE: EmbeddedStr consists of recursive FormerStrPieces and each FormerStrPiece corresponds to string literal and expression.
func (*FormerStrPiece) String ¶
func (fs *FormerStrPiece) String() string
type FuncComponent ¶
FuncComponent is an ast container for elements of func/iter/match literal.
func (*FuncComponent) PrependSelf ¶
func (fc *FuncComponent) PrependSelf(src *Source) *FuncComponent
PrependSelf prepends `self` parameter to its paramters. This is helper function to parse methods like `m{}` (, which is a syntax sugar of `{|self| }`)
func (*FuncComponent) String ¶
func (fc *FuncComponent) String() string
type FuncLiteral ¶
type FuncLiteral struct { FuncComponent Token string Src *Source }
FuncLiteral is an ast node of func literal like `{|i| i * 2}`.
func (*FuncLiteral) Source ¶
func (fl *FuncLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*FuncLiteral) String ¶
func (fl *FuncLiteral) String() string
func (*FuncLiteral) TokenLiteral ¶
func (fl *FuncLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type Ident ¶
Ident is an ast node of identifier expression.
func (*Ident) TokenLiteral ¶
TokenLiteral returns token given by lexer.
type IfExpr ¶
IfExpr is an ast node of if expression.
func (*IfExpr) TokenLiteral ¶
TokenLiteral returns token given by lexer.
type InfixExpr ¶
type InfixExpr struct { Token string // i.e.: "+" Left Expr Operator string Right Expr Src *Source }
InfixExpr is an ast node of infix expression.
func (*InfixExpr) TokenLiteral ¶
TokenLiteral returns token given by lexer.
type IntLiteral ¶
IntLiteral is an ast node for int literal like `1`.
func (*IntLiteral) Source ¶
func (il *IntLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*IntLiteral) String ¶
func (il *IntLiteral) String() string
func (*IntLiteral) TokenLiteral ¶
func (il *IntLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type IterLiteral ¶
type IterLiteral struct { FuncComponent Token string Src *Source }
IterLiteral is an ast node of func literal like `<{|i| yield i if i; recur(i-1)}>`.
func (*IterLiteral) Source ¶
func (il *IterLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*IterLiteral) String ¶
func (il *IterLiteral) String() string
func (*IterLiteral) TokenLiteral ¶
func (il *IterLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type JumpIfStmt ¶
JumpIfStmt is an ast node of JumpStmt with `if` clause.
func (*JumpIfStmt) Source ¶
func (js *JumpIfStmt) Source() *Source
Source returns stacktrace information used for error massages.
func (*JumpIfStmt) String ¶
func (js *JumpIfStmt) String() string
func (*JumpIfStmt) TokenLiteral ¶
func (js *JumpIfStmt) TokenLiteral() string
TokenLiteral returns token given by lexer.
type JumpStmt ¶
JumpStmt is an ast node of statement such as `return` or `yield`.
func (*JumpStmt) TokenLiteral ¶
TokenLiteral returns token given by lexer.
type JumpType ¶
type JumpType int
JumpType is an Enum for jump keywords, used for JumpStmt.
const ( // ReturnJump is JumpType for `return`. ReturnJump JumpType = iota // RaiseJump is JumpType for `raise`. RaiseJump // YieldJump is JumpType for `yield`. YieldJump // DeferJump is JumpType for `defer`. // NOTE: treat `defer` as JumpType because syntax is equivalent to the other JumpTypes DeferJump )
type LiteralCallExpr ¶
type LiteralCallExpr struct { Token string Chain *Chain Receiver Expr Func *FuncLiteral Args []Expr Kwargs map[*Ident]Expr Src *Source }
LiteralCallExpr is an ast node of literalcall expression like `1.{|i| i * 2}`.
func (*LiteralCallExpr) ChainArg ¶
func (lc *LiteralCallExpr) ChainArg() Expr
ChainArg returns chain arg expression of this call.
func (*LiteralCallExpr) ChainToken ¶
func (lc *LiteralCallExpr) ChainToken() string
ChainToken returns chain string of this call.
func (*LiteralCallExpr) Source ¶
func (lc *LiteralCallExpr) Source() *Source
Source returns stacktrace information used for error massages.
func (*LiteralCallExpr) String ¶
func (lc *LiteralCallExpr) String() string
func (*LiteralCallExpr) TokenLiteral ¶
func (lc *LiteralCallExpr) TokenLiteral() string
TokenLiteral returns token given by lexer.
type MapLiteral ¶
MapLiteral is an ast node for map literal like `%{"a": 1}`.
func (*MapLiteral) Source ¶
func (ml *MapLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*MapLiteral) String ¶
func (ml *MapLiteral) String() string
func (*MapLiteral) TokenLiteral ¶
func (ml *MapLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type MatchLiteral ¶
type MatchLiteral struct { Token string Patterns []*FuncComponent Src *Source }
MatchLiteral is an ast node of match literal like `%{|1| 2, |3| 4}`.
func (*MatchLiteral) Source ¶
func (ml *MatchLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*MatchLiteral) String ¶
func (ml *MatchLiteral) String() string
func (*MatchLiteral) TokenLiteral ¶
func (ml *MatchLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type ObjLiteral ¶
ObjLiteral is an ast node for obj literal like `{a: 1}`.
func (*ObjLiteral) Source ¶
func (ol *ObjLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*ObjLiteral) String ¶
func (ol *ObjLiteral) String() string
func (*ObjLiteral) TokenLiteral ¶
func (ol *ObjLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type PinnedIdent ¶
type PinnedIdent struct {
Ident
}
PinnedIdent is an ast node of identifier with pinned operation `^`.
func (*PinnedIdent) String ¶
func (pi *PinnedIdent) String() string
type PrefixExpr ¶
PrefixExpr is an ast node of prefix expression.
func (*PrefixExpr) Source ¶
func (pe *PrefixExpr) Source() *Source
Source returns stacktrace information used for error massages.
func (*PrefixExpr) String ¶
func (pe *PrefixExpr) String() string
func (*PrefixExpr) TokenLiteral ¶
func (pe *PrefixExpr) TokenLiteral() string
TokenLiteral returns token given by lexer.
type Program ¶
Program is an ast node of program, corresponding to the whole source code.
func (*Program) TokenLiteral ¶
TokenLiteral returns token given by lexer.
type PropCallExpr ¶
type PropCallExpr struct { Token string Chain *Chain Receiver Expr Prop *Ident Args []Expr Kwargs map[*Ident]Expr Src *Source }
PropCallExpr is an ast node of propcall expression like `"hello".p`.
func (*PropCallExpr) ChainArg ¶
func (pc *PropCallExpr) ChainArg() Expr
ChainArg returns chain arg expression of this call.
func (*PropCallExpr) ChainToken ¶
func (pc *PropCallExpr) ChainToken() string
ChainToken returns chain string of this call.
func (*PropCallExpr) Source ¶
func (pc *PropCallExpr) Source() *Source
Source returns stacktrace information used for error massages.
func (*PropCallExpr) String ¶
func (pc *PropCallExpr) String() string
func (*PropCallExpr) TokenLiteral ¶
func (pc *PropCallExpr) TokenLiteral() string
TokenLiteral returns token given by lexer.
type RangeLiteral ¶
RangeLiteral is an ast node of range literal like `(1:10)`.
func (*RangeLiteral) Source ¶
func (rl *RangeLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*RangeLiteral) String ¶
func (rl *RangeLiteral) String() string
func (*RangeLiteral) TokenLiteral ¶
func (rl *RangeLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type RecvAndChain ¶
RecvAndChain is a container for receiver and chain of CallExpr. This type is only used to make parser rules simple.
type Stmt ¶
type Stmt interface { Node // contains filtered or unexported methods }
Stmt is an interface of ast statement node.
type StrLiteral ¶
StrLiteral is an ast node of str literal like `"a"`.
func (*StrLiteral) Source ¶
func (sl *StrLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*StrLiteral) String ¶
func (sl *StrLiteral) String() string
func (*StrLiteral) TokenLiteral ¶
func (sl *StrLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type SymLiteral ¶
SymLiteral is an ast node of sym literal like `'a`.
func (*SymLiteral) Source ¶
func (sl *SymLiteral) Source() *Source
Source returns stacktrace information used for error massages.
func (*SymLiteral) String ¶
func (sl *SymLiteral) String() string
func (*SymLiteral) TokenLiteral ¶
func (sl *SymLiteral) TokenLiteral() string
TokenLiteral returns token given by lexer.
type VarCallExpr ¶
type VarCallExpr struct { Token string Chain *Chain Receiver Expr Var *Ident Args []Expr Kwargs map[*Ident]Expr Src *Source }
VarCallExpr is an ast node of varcall expression like `foo.^bar`.
func (*VarCallExpr) ChainArg ¶
func (vc *VarCallExpr) ChainArg() Expr
ChainArg returns chain arg expression of this call.
func (*VarCallExpr) ChainToken ¶
func (vc *VarCallExpr) ChainToken() string
ChainToken returns chain string of this call.
func (*VarCallExpr) Source ¶
func (vc *VarCallExpr) Source() *Source
Source returns stacktrace information used for error massages.
func (*VarCallExpr) String ¶
func (vc *VarCallExpr) String() string
func (*VarCallExpr) TokenLiteral ¶
func (vc *VarCallExpr) TokenLiteral() string
TokenLiteral returns token given by lexer.