ast

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: MIT Imports: 1 Imported by: 35

Documentation

Overview

Package ast implements abstruct-syntax-tree for anko.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddOperator added in v0.0.9

type AddOperator struct {
	OperatorImpl
	LHS      Expr
	Operator string
	RHS      Expr
}

AddOperator provides add operation.

type AddrExpr

type AddrExpr struct {
	ExprImpl
	Expr Expr
}

AddrExpr provide referencing address expression.

type AnonCallExpr

type AnonCallExpr struct {
	ExprImpl
	Expr     Expr
	SubExprs []Expr
	VarArg   bool
	Go       bool
}

AnonCallExpr provide anonymous calling expression. ex: func(){}().

type ArrayExpr

type ArrayExpr struct {
	ExprImpl
	Exprs    []Expr
	TypeData *TypeStruct
}

ArrayExpr provide Array expression.

type BinaryOperator added in v0.0.9

type BinaryOperator struct {
	OperatorImpl
	LHS      Expr
	Operator string
	RHS      Expr
}

BinaryOperator provides binary operation.

type BreakStmt

type BreakStmt struct {
	StmtImpl
}

BreakStmt provide "break" expression statement.

type CForStmt

type CForStmt struct {
	StmtImpl
	Stmt1 Stmt
	Expr2 Expr
	Expr3 Expr
	Stmt  Stmt
}

CForStmt provide C-style "for (;;)" expression statement.

type CallExpr

type CallExpr struct {
	ExprImpl
	Func     reflect.Value
	Name     string
	SubExprs []Expr
	VarArg   bool
	Go       bool
}

CallExpr provide calling expression.

type ChanExpr

type ChanExpr struct {
	ExprImpl
	LHS Expr
	RHS Expr
}

ChanExpr provide chan expression.

type ChanStmt added in v0.1.5

type ChanStmt struct {
	ExprImpl
	LHS    Expr
	OkExpr Expr
	RHS    Expr
}

ChanStmt provide chan lets statement.

type CloseStmt added in v0.0.9

type CloseStmt struct {
	StmtImpl
	Expr Expr
}

CloseStmt provides statement of close.

type ComparisonOperator added in v0.0.9

type ComparisonOperator struct {
	OperatorImpl
	LHS      Expr
	Operator string
	RHS      Expr
}

ComparisonOperator provides comparison operation.

type ContinueStmt

type ContinueStmt struct {
	StmtImpl
}

ContinueStmt provide "continue" expression statement.

type DeleteStmt added in v0.0.9

type DeleteStmt struct {
	ExprImpl
	Item Expr
	Key  Expr
}

DeleteStmt provides statement of delete.

type DerefExpr

type DerefExpr struct {
	ExprImpl
	Expr Expr
}

DerefExpr provide dereferencing address expression.

type Expr

type Expr interface {
	Pos
}

Expr provides all of interfaces for expression.

type ExprImpl

type ExprImpl struct {
	PosImpl // PosImpl provide Pos() function.
}

ExprImpl provide commonly implementations for Expr.

type ExprStmt

type ExprStmt struct {
	StmtImpl
	Expr Expr
}

ExprStmt provide expression statement.

type ForStmt

type ForStmt struct {
	StmtImpl
	Vars  []string
	Value Expr
	Stmt  Stmt
}

ForStmt provide "for in" expression statement.

type FuncExpr

type FuncExpr struct {
	ExprImpl
	Name   string
	Stmt   Stmt
	Params []string
	VarArg bool
}

FuncExpr provide function expression.

type GoroutineStmt added in v0.0.4

type GoroutineStmt struct {
	StmtImpl
	Expr Expr
}

GoroutineStmt provide statement of groutine.

type IdentExpr

type IdentExpr struct {
	ExprImpl
	Lit string
}

IdentExpr provide identity expression.

type IfStmt

type IfStmt struct {
	StmtImpl
	If     Expr
	Then   Stmt
	ElseIf []Stmt // This is array of IfStmt
	Else   Stmt
}

IfStmt provide "if/else" statement.

type ImportExpr added in v0.1.3

type ImportExpr struct {
	ExprImpl
	Name Expr
}

ImportExpr provide expression to import packages.

type IncludeExpr added in v0.0.3

type IncludeExpr struct {
	ExprImpl
	ItemExpr Expr
	ListExpr Expr
}

IncludeExpr provide in expression

type ItemExpr

type ItemExpr struct {
	ExprImpl
	Item  Expr
	Index Expr
}

ItemExpr provide expression to refer Map/Array item.

type LenExpr

type LenExpr struct {
	ExprImpl
	Expr Expr
}

LenExpr provide expression to get length of array, map, etc.

type LetMapItemStmt added in v0.0.3

type LetMapItemStmt struct {
	StmtImpl
	LHSS []Expr
	RHS  Expr
}

LetMapItemStmt provide statement of let for map item.

type LetsExpr

type LetsExpr struct {
	ExprImpl
	LHSS []Expr
	RHSS []Expr
}

LetsExpr provide multiple expression of let.

type LetsStmt

type LetsStmt struct {
	StmtImpl
	LHSS []Expr
	RHSS []Expr
}

LetsStmt provide multiple statement of let.

type LiteralExpr added in v0.0.9

type LiteralExpr struct {
	ExprImpl
	Literal reflect.Value
}

LiteralExpr provide literal expression.

type LoopStmt

type LoopStmt struct {
	StmtImpl
	Expr Expr
	Stmt Stmt
}

LoopStmt provide "for expr" expression statement.

type MakeExpr

type MakeExpr struct {
	ExprImpl
	TypeData *TypeStruct
	LenExpr  Expr
	CapExpr  Expr
}

MakeExpr provide expression to make instance.

type MakeTypeExpr

type MakeTypeExpr struct {
	ExprImpl
	Name string
	Type Expr
}

MakeTypeExpr provide expression to make type.

type MapExpr

type MapExpr struct {
	ExprImpl
	Keys     []Expr
	Values   []Expr
	TypeData *TypeStruct
}

MapExpr provide Map expression.

type MemberExpr

type MemberExpr struct {
	ExprImpl
	Expr Expr
	Name string
}

MemberExpr provide expression to refer member.

type ModuleStmt

type ModuleStmt struct {
	StmtImpl
	Name string
	Stmt Stmt
}

ModuleStmt provide "module" expression statement.

type MultiplyOperator added in v0.0.9

type MultiplyOperator struct {
	OperatorImpl
	LHS      Expr
	Operator string
	RHS      Expr
}

MultiplyOperator provides multiply operation.

type NilCoalescingOpExpr added in v0.0.5

type NilCoalescingOpExpr struct {
	ExprImpl
	LHS Expr
	RHS Expr
}

NilCoalescingOpExpr provide if invalid operator expression.

type OpExpr added in v0.0.9

type OpExpr struct {
	ExprImpl
	Op Operator
}

OpExpr provide operator expression.

type Operator added in v0.0.9

type Operator interface {
	Pos
}

Operator provides interfaces for operators.

type OperatorImpl added in v0.0.9

type OperatorImpl struct {
	PosImpl // PosImpl provide Pos() function.
}

OperatorImpl provides common implementations for Operator.

type ParenExpr

type ParenExpr struct {
	ExprImpl
	SubExpr Expr
}

ParenExpr provide parent block expression.

type Pos

type Pos interface {
	Position() Position
	SetPosition(Position)
}

Pos interface provides two functions to get/set the position for expression or statement.

type PosImpl

type PosImpl struct {
	// contains filtered or unexported fields
}

PosImpl provides commonly implementations for Pos.

func (*PosImpl) Position

func (x *PosImpl) Position() Position

Position return the position of the expression or statement.

func (*PosImpl) SetPosition

func (x *PosImpl) SetPosition(pos Position)

SetPosition is a function to specify position of the expression or statement.

type Position

type Position struct {
	Line   int
	Column int
}

Position provides interface to store code locations.

type ReturnStmt

type ReturnStmt struct {
	StmtImpl
	Exprs []Expr
}

ReturnStmt provide "return" expression statement.

type SliceExpr

type SliceExpr struct {
	ExprImpl
	Item  Expr
	Begin Expr
	End   Expr
	Cap   Expr
}

SliceExpr provide expression to refer slice of Array.

type Stmt

type Stmt interface {
	Pos
}

Stmt provides all of interfaces for statement.

type StmtImpl

type StmtImpl struct {
	PosImpl // PosImpl provide Pos() function.
}

StmtImpl provide commonly implementations for Stmt..

type StmtsStmt added in v0.0.9

type StmtsStmt struct {
	StmtImpl
	Stmts []Stmt
}

StmtsStmt provides statements.

type SwitchCaseStmt added in v0.0.7

type SwitchCaseStmt struct {
	StmtImpl
	Exprs []Expr
	Stmt  Stmt
}

SwitchCaseStmt provide switch case statement.

type SwitchStmt

type SwitchStmt struct {
	StmtImpl
	Expr    Expr
	Cases   []Stmt
	Default Stmt
}

SwitchStmt provide switch statement.

type TernaryOpExpr

type TernaryOpExpr struct {
	ExprImpl
	Expr Expr
	LHS  Expr
	RHS  Expr
}

TernaryOpExpr provide ternary operator expression.

type ThrowStmt

type ThrowStmt struct {
	StmtImpl
	Expr Expr
}

ThrowStmt provide "throw" expression statement.

type Token

type Token struct {
	PosImpl
	Tok int
	Lit string
}

Token is used in the lexer to split characters into a string called a token

type TryStmt

type TryStmt struct {
	StmtImpl
	Try     Stmt
	Var     string
	Catch   Stmt
	Finally Stmt
}

TryStmt provide "try/catch/finally" statement.

type TypeKind added in v0.0.9

type TypeKind int

TypeKind is the kinds of types

const (
	// TypeDefault default type
	TypeDefault TypeKind = iota
	// TypePtr ptr type
	TypePtr
	// TypeSlice slice type
	TypeSlice
	// TypeMap map type
	TypeMap
	// TypeChan chan type
	TypeChan
	// TypeStructType struct type
	TypeStructType
)

type TypeStruct added in v0.0.9

type TypeStruct struct {
	Kind        TypeKind
	Env         []string
	Name        string
	Dimensions  int
	SubType     *TypeStruct
	Key         *TypeStruct
	StructNames []string
	StructTypes []*TypeStruct
}

TypeStruct is the type and sub-types

type UnaryExpr

type UnaryExpr struct {
	ExprImpl
	Operator string
	Expr     Expr
}

UnaryExpr provide unary minus expression. ex: -1, ^1, ~1.

type VarStmt

type VarStmt struct {
	StmtImpl
	Names []string
	Exprs []Expr
}

VarStmt provide statement to let variables in current scope.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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