ast

package
v0.0.0-...-ab8d200 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Begin reader.Position
	Elems []Expr
	End   reader.Position
}

Array 数组

func (*Array) Output

func (self *Array) Output(w io.Writer, depth uint) (err error)

func (*Array) Position

func (self *Array) Position() reader.Position

type ArrayType

type ArrayType struct {
	Begin reader.Position
	Size  token.Token
	Elem  Type
}

ArrayType 数组类型

func (*ArrayType) Output

func (self *ArrayType) Output(w io.Writer, depth uint) (err error)

func (*ArrayType) Position

func (self *ArrayType) Position() reader.Position

type Ast

type Ast interface {
	Position() reader.Position
	Output(io.Writer, uint) error
}

Ast 抽象语法树

type Attr

type Attr interface {
	Ast
	AttrName() string
}

Attr 属性

type Binary

type Binary struct {
	Left  Expr
	Opera token.Token
	Right Expr
}

Binary 二元运算

func (*Binary) Output

func (self *Binary) Output(w io.Writer, depth uint) (err error)

func (*Binary) Position

func (self *Binary) Position() reader.Position

type Block

type Block struct {
	Begin reader.Position
	Stmts linkedlist.LinkedList[Stmt]
	End   reader.Position
}

Block 代码块

func (*Block) Output

func (self *Block) Output(w io.Writer, depth uint) (err error)

func (*Block) Position

func (self *Block) Position() reader.Position

type Break

type Break struct {
	Token token.Token
}

Break 跳出循环

func (*Break) Output

func (self *Break) Output(w io.Writer, depth uint) (err error)

func (*Break) Position

func (self *Break) Position() reader.Position

type Call

type Call struct {
	Func Expr
	Args []Expr
	End  reader.Position
}

Call 调用

func (*Call) Output

func (self *Call) Output(w io.Writer, depth uint) (err error)

func (*Call) Position

func (self *Call) Position() reader.Position

type Char

type Char struct {
	Value token.Token
}

Char 字符

func (*Char) Output

func (self *Char) Output(w io.Writer, depth uint) (err error)

func (*Char) Position

func (self *Char) Position() reader.Position

type CheckNull

type CheckNull struct {
	Value Expr
	End   reader.Position
}

CheckNull 空指针检查

func (*CheckNull) Output

func (self *CheckNull) Output(w io.Writer, depth uint) (err error)

func (*CheckNull) Position

func (self *CheckNull) Position() reader.Position

type Continue

type Continue struct {
	Token token.Token
}

Continue 下一次循环

func (*Continue) Output

func (self *Continue) Output(w io.Writer, depth uint) (err error)

func (*Continue) Position

func (self *Continue) Position() reader.Position

type Covert

type Covert struct {
	Value Expr
	Type  Type
}

Covert 类型转换

func (*Covert) Output

func (self *Covert) Output(w io.Writer, depth uint) (err error)

func (*Covert) Position

func (self *Covert) Position() reader.Position

type Dot

type Dot struct {
	From        Expr
	Index       token.Token
	GenericArgs optional.Optional[*GenericArgList]
}

Dot 点

func (*Dot) Output

func (self *Dot) Output(w io.Writer, depth uint) (err error)

func (*Dot) Position

func (self *Dot) Position() reader.Position

type EnumField

type EnumField struct {
	Name token.Token
	Elem optional.Optional[Type]
}

func (*EnumField) Output

func (self *EnumField) Output(w io.Writer, depth uint) (err error)

type EnumType

type EnumType struct {
	Begin  reader.Position
	Fields []EnumField
	End    reader.Position
}

EnumType 枚举类型

func (*EnumType) Output

func (self *EnumType) Output(w io.Writer, depth uint) (err error)

func (*EnumType) Position

func (self *EnumType) Position() reader.Position

type Expr

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

Expr 表达式

type Extern

type Extern struct {
	Begin reader.Position
	Name  token.Token
	End   reader.Position
}

func (*Extern) AttrName

func (self *Extern) AttrName() string

func (*Extern) Output

func (self *Extern) Output(w io.Writer, depth uint) (err error)

func (*Extern) Position

func (self *Extern) Position() reader.Position

type Extract

type Extract struct {
	From  Expr
	Index token.Token
}

Extract 提取

func (*Extract) Output

func (self *Extract) Output(w io.Writer, depth uint) (err error)

func (*Extract) Position

func (self *Extract) Position() reader.Position

type Field

type Field struct {
	Public  bool
	Mutable bool
	Name    token.Token
	Type    Type
}

func (Field) Output

func (self Field) Output(w io.Writer, depth uint) (err error)

type Float

type Float struct {
	Value token.Token
}

Float 浮点数

func (*Float) Output

func (self *Float) Output(w io.Writer, depth uint) (err error)

func (*Float) Position

func (self *Float) Position() reader.Position

type For

type For struct {
	Begin     reader.Position
	CursorMut bool
	Cursor    token.Token
	Iterator  Expr
	Body      *Block
}

For 遍历

func (*For) Output

func (self *For) Output(w io.Writer, depth uint) (err error)

func (*For) Position

func (self *For) Position() reader.Position

type FuncDecl

type FuncDecl struct {
	Begin  reader.Position
	Name   token.Token
	Params []Param
	Ret    optional.Optional[Type]
	End    reader.Position
}

FuncDecl 函数声明

func (*FuncDecl) Output

func (self *FuncDecl) Output(w io.Writer, depth uint) (err error)

func (*FuncDecl) Position

func (self *FuncDecl) Position() reader.Position

type FuncDef

type FuncDef struct {
	Attrs    []Attr
	Begin    reader.Position
	Public   bool
	SelfType optional.Optional[token.Token]
	FuncDecl
	GenericParams optional.Optional[*GenericParamList]
	Body          optional.Optional[*Block]
}

FuncDef 函数定义

func (*FuncDef) Output

func (self *FuncDef) Output(w io.Writer, depth uint) (err error)

func (*FuncDef) Position

func (self *FuncDef) Position() reader.Position

type FuncType

type FuncType struct {
	Begin  reader.Position
	Params []Type
	Ret    optional.Optional[Type]
	End    reader.Position
}

FuncType 函数类型

func (*FuncType) Output

func (self *FuncType) Output(w io.Writer, depth uint) (err error)

func (*FuncType) Position

func (self *FuncType) Position() reader.Position

type GenericArgList

type GenericArgList struct {
	Begin reader.Position
	Args  []Type
	End   reader.Position
}

func (*GenericArgList) Output

func (self *GenericArgList) Output(w io.Writer, depth uint) (err error)

func (*GenericArgList) Position

func (self *GenericArgList) Position() reader.Position

type GenericParam

type GenericParam struct {
	Name      token.Token
	Restraint optional.Optional[*IdentType]
}

func (*GenericParam) Output

func (self *GenericParam) Output(w io.Writer, depth uint) (err error)

func (*GenericParam) Position

func (self *GenericParam) Position() reader.Position

type GenericParamList

type GenericParamList struct {
	Begin  reader.Position
	Params []*GenericParam
	End    reader.Position
}

func (*GenericParamList) Output

func (self *GenericParamList) Output(w io.Writer, depth uint) (err error)

func (*GenericParamList) Position

func (self *GenericParamList) Position() reader.Position

type Global

type Global interface {
	Ast
	// contains filtered or unexported methods
}

Global 全局ast

type Ident

type Ident struct {
	Pkg         optional.Optional[token.Token]
	Name        token.Token
	GenericArgs optional.Optional[*GenericArgList]
}

Ident 标识符

func (*Ident) Output

func (self *Ident) Output(w io.Writer, depth uint) (err error)

func (*Ident) Position

func (self *Ident) Position() reader.Position

type IdentExpr

type IdentExpr Ident

IdentExpr 标识符表达式

func (*IdentExpr) Output

func (self *IdentExpr) Output(w io.Writer, depth uint) (err error)

func (*IdentExpr) Position

func (self *IdentExpr) Position() reader.Position

type IdentType

type IdentType Ident

IdentType 标识符类型

func (*IdentType) Output

func (self *IdentType) Output(w io.Writer, depth uint) (err error)

func (*IdentType) Position

func (self *IdentType) Position() reader.Position

type IfElse

type IfElse struct {
	Begin reader.Position
	Cond  optional.Optional[Expr]
	Body  *Block
	Next  optional.Optional[*IfElse]
}

IfElse if else

func (*IfElse) IsElse

func (self *IfElse) IsElse() bool

func (*IfElse) IsIf

func (self *IfElse) IsIf() bool

func (*IfElse) Output

func (self *IfElse) Output(w io.Writer, depth uint) (err error)

func (*IfElse) Position

func (self *IfElse) Position() reader.Position

type Import

type Import struct {
	Begin reader.Position
	Paths []token.Token
	Alias optional.Optional[token.Token]
}

Import 包导入

func (*Import) Output

func (self *Import) Output(w io.Writer, depth uint) (err error)

func (*Import) Position

func (self *Import) Position() reader.Position

type Index

type Index struct {
	From  Expr
	Index Expr
}

Index 索引

func (*Index) Output

func (self *Index) Output(w io.Writer, depth uint) (err error)

func (*Index) Position

func (self *Index) Position() reader.Position

type Inline

type Inline struct {
	Begin reader.Position
	End   reader.Position
}

func (*Inline) AttrName

func (self *Inline) AttrName() string

func (*Inline) Output

func (self *Inline) Output(w io.Writer, depth uint) (err error)

func (*Inline) Position

func (self *Inline) Position() reader.Position

type Integer

type Integer struct {
	Value token.Token
}

Integer 整数

func (*Integer) Output

func (self *Integer) Output(w io.Writer, depth uint) (err error)

func (*Integer) Position

func (self *Integer) Position() reader.Position

type Judgment

type Judgment struct {
	Value Expr
	Type  Type
}

Judgment 判断

func (*Judgment) Output

func (self *Judgment) Output(w io.Writer, depth uint) (err error)

func (*Judgment) Position

func (self *Judgment) Position() reader.Position

type Lambda

type Lambda struct {
	Begin  reader.Position
	Params []Param
	Ret    Type
	Body   *Block
}

Lambda 匿名函数

func (*Lambda) Output

func (self *Lambda) Output(w io.Writer, depth uint) (err error)

func (*Lambda) Position

func (self *Lambda) Position() reader.Position

type LambdaType

type LambdaType struct {
	Begin  reader.Position
	Params []Type
	Ret    Type
}

LambdaType 匿名函数类型

func (*LambdaType) Output

func (self *LambdaType) Output(w io.Writer, depth uint) (err error)

func (*LambdaType) Position

func (self *LambdaType) Position() reader.Position

type Match

type Match struct {
	Begin reader.Position
	Value Expr
	Cases []MatchCase
	Other optional.Optional[*Block]
	End   reader.Position
}

Match 匹配

func (*Match) Output

func (self *Match) Output(w io.Writer, depth uint) (err error)

func (*Match) Position

func (self *Match) Position() reader.Position

type MatchCase

type MatchCase struct {
	Name    token.Token
	Elem    optional.Optional[MatchCaseElem]
	ElemEnd reader.Position
	Body    *Block
}

func (*MatchCase) Output

func (self *MatchCase) Output(w io.Writer, depth uint) (err error)

type MatchCaseElem

type MatchCaseElem struct {
	Mutable bool
	Name    token.Token
}

func (*MatchCaseElem) Output

func (self *MatchCaseElem) Output(w io.Writer, depth uint) (err error)

type MultipleVariableDef

type MultipleVariableDef struct {
	Attrs  []Attr
	Begin  reader.Position
	Public bool
	Vars   []VarDef
	Value  optional.Optional[Expr]
	End    reader.Position
}

MultipleVariableDef 多变量定义

func (*MultipleVariableDef) Output

func (self *MultipleVariableDef) Output(w io.Writer, depth uint) (err error)

func (*MultipleVariableDef) Position

func (self *MultipleVariableDef) Position() reader.Position

func (*MultipleVariableDef) ToSingleList

func (self *MultipleVariableDef) ToSingleList() []*SingleVariableDef

type NoInline

type NoInline struct {
	Begin reader.Position
	End   reader.Position
}

func (*NoInline) AttrName

func (self *NoInline) AttrName() string

func (*NoInline) Output

func (self *NoInline) Output(w io.Writer, depth uint) (err error)

func (*NoInline) Position

func (self *NoInline) Position() reader.Position

type Param

type Param struct {
	Mutable optional.Optional[token.Token]
	Name    optional.Optional[token.Token]
	Type    Type
}

func (Param) Output

func (self Param) Output(w io.Writer, depth uint) (err error)

func (Param) Position

func (self Param) Position() reader.Position

type RefType

type RefType struct {
	Begin reader.Position
	Mut   bool
	Elem  Type
}

RefType 引用类型

func (*RefType) Output

func (self *RefType) Output(w io.Writer, depth uint) (err error)

func (*RefType) Position

func (self *RefType) Position() reader.Position

type Return

type Return struct {
	Begin reader.Position
	Value optional.Optional[Expr]
}

Return 函数返回

func (*Return) Output

func (self *Return) Output(w io.Writer, depth uint) (err error)

func (*Return) Position

func (self *Return) Position() reader.Position

type SingleVariableDef

type SingleVariableDef struct {
	Attrs  []Attr
	Begin  reader.Position
	Public bool
	Var    VarDef
	Value  optional.Optional[Expr]
}

SingleVariableDef 单变量定义

func (*SingleVariableDef) Output

func (self *SingleVariableDef) Output(w io.Writer, depth uint) (err error)

func (*SingleVariableDef) Position

func (self *SingleVariableDef) Position() reader.Position

type Stmt

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

Stmt 语句ast

type String

type String struct {
	Value token.Token
}

String 字符串

func (*String) Output

func (self *String) Output(w io.Writer, depth uint) (err error)

func (*String) Position

func (self *String) Position() reader.Position

type Struct

type Struct struct {
	Type   Type
	Fields []tuple.Tuple2[token.Token, Expr]
	End    reader.Position
}

Struct 结构体

func (*Struct) Output

func (self *Struct) Output(w io.Writer, depth uint) (err error)

func (*Struct) Position

func (self *Struct) Position() reader.Position

type StructType

type StructType struct {
	Begin  reader.Position
	Fields []Field
	End    reader.Position
}

func (*StructType) Output

func (self *StructType) Output(w io.Writer, depth uint) (err error)

func (*StructType) Position

func (self *StructType) Position() reader.Position

type Trait

type Trait struct {
	Begin   reader.Position
	Public  bool
	Name    token.Token
	Methods []*FuncDecl
	End     reader.Position
}

Trait 特征

func (*Trait) Output

func (self *Trait) Output(w io.Writer, depth uint) (err error)

func (*Trait) Position

func (self *Trait) Position() reader.Position

type Tuple

type Tuple struct {
	Begin reader.Position
	Elems []Expr
	End   reader.Position
}

Tuple 元组

func (*Tuple) Output

func (self *Tuple) Output(w io.Writer, depth uint) (err error)

func (*Tuple) Position

func (self *Tuple) Position() reader.Position

type TupleType

type TupleType struct {
	Begin reader.Position
	Elems []Type
	End   reader.Position
}

TupleType 元组类型

func (*TupleType) Output

func (self *TupleType) Output(w io.Writer, depth uint) (err error)

func (*TupleType) Position

func (self *TupleType) Position() reader.Position

type Type

type Type interface {
	Ast
	// contains filtered or unexported methods
}

Type 类型

type TypeAlias

type TypeAlias struct {
	Begin  reader.Position
	Public bool
	Name   token.Token
	Target Type
}

TypeAlias 类型别名

func (*TypeAlias) Output

func (self *TypeAlias) Output(w io.Writer, depth uint) (err error)

func (*TypeAlias) Position

func (self *TypeAlias) Position() reader.Position

type TypeDef

type TypeDef struct {
	Begin         reader.Position
	Public        bool
	Name          token.Token
	GenericParams optional.Optional[*GenericParamList]
	Target        Type
}

TypeDef 类型定义

func (*TypeDef) Output

func (self *TypeDef) Output(w io.Writer, depth uint) (err error)

func (*TypeDef) Position

func (self *TypeDef) Position() reader.Position

type Unary

type Unary struct {
	Opera token.Token
	Value Expr
}

Unary 一元运算

func (*Unary) Output

func (self *Unary) Output(w io.Writer, depth uint) (err error)

func (*Unary) Position

func (self *Unary) Position() reader.Position

type VarArg

type VarArg struct {
	Begin reader.Position
	End   reader.Position
}

func (*VarArg) AttrName

func (self *VarArg) AttrName() string

func (*VarArg) Output

func (self *VarArg) Output(w io.Writer, depth uint) (err error)

func (*VarArg) Position

func (self *VarArg) Position() reader.Position

type VarDef

type VarDef struct {
	Mutable bool
	Name    token.Token
	Type    optional.Optional[Type]
}

func (*VarDef) Output

func (self *VarDef) Output(w io.Writer, depth uint) (err error)

type VariableDef

type VariableDef interface {
	Global
	Stmt
	// contains filtered or unexported methods
}

type While

type While struct {
	Begin reader.Position
	Cond  Expr
	Body  *Block
}

While 循环

func (*While) Output

func (self *While) Output(w io.Writer, depth uint) (err error)

func (*While) Position

func (self *While) Position() reader.Position

Jump to

Keyboard shortcuts

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