ast

package
v0.0.0-...-4926b86 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const IndentSpace = 2

Variables

View Source
var Indent int32 = 0

Functions

func IsSingleOperator

func IsSingleOperator(kind string) bool

func IsStatement

func IsStatement(current, prev lexer.Token) (ok bool, withTerminator bool)

func ParseBlock

func ParseBlock(b BlockAST, indent int) string

Types

type Arg

type Arg struct {
	Token lexer.Token
	Expr  Expr
}

func (Arg) String

func (a Arg) String() string

type Assign

type Assign struct {
	Setter      lexer.Token
	SelectExprs []AssignSelector
	ValueExprs  []Expr
	IsExpr      bool
	MultipleRet bool
}

func (Assign) String

func (vs Assign) String() string

type AssignSelector

type AssignSelector struct {
	Var    Var
	Expr   Expr
	Ignore bool
}

func (AssignSelector) String

func (vs AssignSelector) String() string

type Attribute

type Attribute struct {
	Token lexer.Token
	Tag   lexer.Token
}

func (Attribute) String

func (a Attribute) String() string

type BlockAST

type BlockAST struct {
	Tree []Statement
}

func (BlockAST) String

func (b BlockAST) String() string

type Break

type Break struct {
	Token lexer.Token
}

func (Break) String

func (b Break) String() string

type Builder

type Builder struct {
	Tree   []Obj
	Errs   []jnlog.CompilerLog
	Tokens []lexer.Token
	Pos    int
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(tokens []lexer.Token) *Builder

func (*Builder) Args

func (b *Builder) Args(tokens []lexer.Token) []Arg

func (*Builder) AssignExpr

func (b *Builder) AssignExpr(tokens []lexer.Token, isExpr bool) (assign Assign, ok bool)

func (*Builder) AssignStatement

func (b *Builder) AssignStatement(tokens []lexer.Token, isExpr bool) (s Statement, _ bool)

func (*Builder) Attribute

func (b *Builder) Attribute(tokens []lexer.Token)

func (*Builder) Block

func (b *Builder) Block(tokens []lexer.Token) (block BlockAST)

func (*Builder) BreakStatement

func (b *Builder) BreakStatement(tokens []lexer.Token) Statement

func (*Builder) Build

func (b *Builder) Build()

func (*Builder) Comment

func (b *Builder) Comment(token lexer.Token)

func (*Builder) CommentStatement

func (b *Builder) CommentStatement(token lexer.Token) (s Statement)

func (*Builder) ContinueStatement

func (b *Builder) ContinueStatement(tokens []lexer.Token) Statement

func (*Builder) DataType

func (b *Builder) DataType(tokens []lexer.Token, i *int, err bool) (t DataType, ok bool)

func (*Builder) ElseBlock

func (b *Builder) ElseBlock(bs *blockStatement) (s Statement)

func (*Builder) ElseIfExpr

func (b *Builder) ElseIfExpr(bs *blockStatement) (s Statement)

func (*Builder) Ended

func (ast *Builder) Ended() bool

func (*Builder) Expr

func (b *Builder) Expr(tokens []lexer.Token) (e Expr)

func (*Builder) ExprStatement

func (b *Builder) ExprStatement(tokens []lexer.Token) Statement

func (*Builder) FreeStatement

func (b *Builder) FreeStatement(tokens []lexer.Token) Statement

func (*Builder) Func

func (b *Builder) Func(tokens []lexer.Token, anonymous bool) (f Func)

func (*Builder) FuncCallStatement

func (b *Builder) FuncCallStatement(tokens []lexer.Token) Statement

func (*Builder) FuncDataTypeHead

func (b *Builder) FuncDataTypeHead(tokens []lexer.Token, i *int) (string, Func)

func (*Builder) FuncRetDataType

func (b *Builder) FuncRetDataType(tokens []lexer.Token, i *int) (t DataType, ok bool)

func (*Builder) GlobalVar

func (b *Builder) GlobalVar(tokens []lexer.Token)

func (*Builder) Id

func (b *Builder) Id(tokens []lexer.Token)

func (*Builder) IdStatement

func (b *Builder) IdStatement(tokens []lexer.Token) (s Statement)

func (*Builder) IfExpr

func (b *Builder) IfExpr(bs *blockStatement) (s Statement)

func (*Builder) IterExpr

func (b *Builder) IterExpr(tokens []lexer.Token) (s Statement)

func (*Builder) MapDataType

func (b *Builder) MapDataType(tokens []lexer.Token, i *int, err bool) (t DataType, _ string)

func (*Builder) Params

func (b *Builder) Params(fn *Func, tokens []lexer.Token)

func (*Builder) Pragma

func (b *Builder) Pragma(pp *Preprocessor, tokens []lexer.Token) bool

func (*Builder) Preprocessor

func (b *Builder) Preprocessor(tokens []lexer.Token)

func (*Builder) RetStatement

func (b *Builder) RetStatement(tokens []lexer.Token) Statement

func (*Builder) Statement

func (b *Builder) Statement(bs *blockStatement) (s Statement)

func (*Builder) Type

func (b *Builder) Type(tokens []lexer.Token)

func (*Builder) Use

func (b *Builder) Use(tokens []lexer.Token)

func (*Builder) VarStatement

func (b *Builder) VarStatement(tokens []lexer.Token) (s Statement)

type Comment

type Comment struct {
	Content string
}

func (Comment) String

func (c Comment) String() string

type Continue

type Continue struct {
	Token lexer.Token
}

func (Continue) String

func (c Continue) String() string

type CxxEmbed

type CxxEmbed struct {
	Content string
}

func (CxxEmbed) String

func (ce CxxEmbed) String() string

type DataType

type DataType struct {
	Token      lexer.Token
	Id         uint8
	Val        string
	MultiTyped bool
	Tag        interface{}
}

func (DataType) FunctionString

func (dt DataType) FunctionString() string

func (DataType) MultiTypeString

func (dt DataType) MultiTypeString() string

func (DataType) String

func (dt DataType) String() string

type Directive

type Directive struct {
	Command interface{}
}

func (Directive) String

func (d Directive) String() string

type Else

type Else struct {
	Token lexer.Token
	Block BlockAST
}

func (Else) String

func (elseast Else) String() string

type ElseIf

type ElseIf struct {
	Token lexer.Token
	Expr  Expr
	Block BlockAST
}

func (ElseIf) String

func (elif ElseIf) String() string

type EnofiDirective

type EnofiDirective struct{}

func (EnofiDirective) String

func (EnofiDirective) String() string

type Expr

type Expr struct {
	Tokens    []lexer.Token
	Processes [][]lexer.Token
	Model     IExprModel
}

func (Expr) String

func (e Expr) String() string

type ExprStatement

type ExprStatement struct {
	Expr Expr
}

func (ExprStatement) String

func (be ExprStatement) String() string

type ForeachProfile

type ForeachProfile struct {
	KeyA     Var
	KeyB     Var
	InToken  lexer.Token
	Expr     Expr
	ExprType DataType
}

func (ForeachProfile) ClassicString

func (fp ForeachProfile) ClassicString(iter Iter) string

func (*ForeachProfile) ForeachString

func (fp *ForeachProfile) ForeachString(iter Iter) string

func (ForeachProfile) IterationSring

func (fp ForeachProfile) IterationSring(iter Iter) string

func (ForeachProfile) MapString

func (fp ForeachProfile) MapString(iter Iter) string

func (ForeachProfile) String

func (fp ForeachProfile) String(iter Iter) string

type Free

type Free struct {
	Token lexer.Token
	Expr  Expr
}

func (Free) String

func (f Free) String() string

type Func

type Func struct {
	Pub     bool
	Token   lexer.Token
	Id      string
	Params  []Parameter
	RetType DataType
	Block   BlockAST
}

func (Func) DataTypeString

func (fc Func) DataTypeString() string

type IExprModel

type IExprModel interface {
	String() string
}

type If

type If struct {
	Token lexer.Token
	Expr  Expr
	Block BlockAST
}

func (If) String

func (ifast If) String() string

type Iter

type Iter struct {
	Token   lexer.Token
	Block   BlockAST
	Profile IterProfile
}

func (Iter) String

func (iter Iter) String() string

type IterProfile

type IterProfile interface {
	String(iter Iter) string
}

type Obj

type Obj struct {
	Token lexer.Token
	Value interface{}
}

type Parameter

type Parameter struct {
	Token    lexer.Token
	Id       string
	Const    bool
	Volatile bool
	Variadic bool
	Type     DataType
}

func (Parameter) Prototype

func (p Parameter) Prototype() string

func (Parameter) String

func (p Parameter) String() string

type Preprocessor

type Preprocessor struct {
	Token   lexer.Token
	Command interface{}
}

func (Preprocessor) String

func (pp Preprocessor) String() string

type Ret

type Ret struct {
	Token lexer.Token
	Expr  Expr
}

func (Ret) String

func (r Ret) String() string

type Statement

type Statement struct {
	Token          lexer.Token
	Val            interface{}
	WithTerminator bool
}

func (Statement) String

func (s Statement) String() string

type Type

type Type struct {
	Pub   bool
	Token lexer.Token
	Id    string
	Type  DataType
	Desc  string
}

func (Type) String

func (t Type) String() string

type Use

type Use struct {
	Token lexer.Token
	Path  string
}

type Value

type Value struct {
	Token lexer.Token
	Data  string
	Type  DataType
}

func (Value) String

func (v Value) String() string

type Var

type Var struct {
	Pub         bool
	DefToken    lexer.Token
	IdToken     lexer.Token
	SetterToken lexer.Token
	Id          string
	Type        DataType
	Val         Expr
	Const       bool
	Volatile    bool
	New         bool
	Tag         interface{}
	Desc        string
}

func (Var) String

func (v Var) String() string

type WhileProfile

type WhileProfile struct {
	Expr Expr
}

func (WhileProfile) String

func (wp WhileProfile) String(iter Iter) string

Jump to

Keyboard shortcuts

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