ast

package
v0.0.0-...-3085ebc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayLiteral

type ArrayLiteral struct {
	Token   token.Token
	Members []Expression
}

func (*ArrayLiteral) End

func (a *ArrayLiteral) End() token.Position

func (*ArrayLiteral) Pos

func (a *ArrayLiteral) Pos() token.Position

func (*ArrayLiteral) String

func (a *ArrayLiteral) String() string

func (*ArrayLiteral) TokenLiteral

func (a *ArrayLiteral) TokenLiteral() string

type AssignExpression

type AssignExpression struct {
	Token token.Token
	Name  Expression
	Value Expression
}

func (*AssignExpression) End

func (ae *AssignExpression) End() token.Position

func (*AssignExpression) Pos

func (ae *AssignExpression) Pos() token.Position

func (*AssignExpression) String

func (ae *AssignExpression) String() string

func (*AssignExpression) TokenLiteral

func (ae *AssignExpression) TokenLiteral() string

type BlockStatement

type BlockStatement struct {
	Token       token.Token
	Statements  []Statement
	RBraceToken token.Token //used in End() method
}

func (*BlockStatement) End

func (bs *BlockStatement) End() token.Position

func (*BlockStatement) Pos

func (bs *BlockStatement) Pos() token.Position

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

type BooleanLiteral

type BooleanLiteral struct {
	Token token.Token
	Value bool
}

func (*BooleanLiteral) End

func (b *BooleanLiteral) End() token.Position

func (*BooleanLiteral) Pos

func (b *BooleanLiteral) Pos() token.Position

func (*BooleanLiteral) String

func (b *BooleanLiteral) String() string

func (*BooleanLiteral) TokenLiteral

func (b *BooleanLiteral) TokenLiteral() string

type BreakExpression

type BreakExpression struct {
	Token token.Token
}

func (*BreakExpression) End

func (be *BreakExpression) End() token.Position

func (*BreakExpression) Pos

func (be *BreakExpression) Pos() token.Position

func (*BreakExpression) String

func (be *BreakExpression) String() string

func (*BreakExpression) TokenLiteral

func (be *BreakExpression) TokenLiteral() string

type CForLoop

type CForLoop struct {
	Token  token.Token
	Init   Expression
	Cond   Expression
	Update Expression
	Block  *BlockStatement
}

c language like for loop

func (*CForLoop) End

func (fl *CForLoop) End() token.Position

func (*CForLoop) Pos

func (fl *CForLoop) Pos() token.Position

func (*CForLoop) String

func (fl *CForLoop) String() string

func (*CForLoop) TokenLiteral

func (fl *CForLoop) TokenLiteral() string

type CallExpression

type CallExpression struct {
	Token     token.Token // The '(' token
	Function  Expression  // Identifier or FunctionLiteral
	Arguments []Expression
	Variadic  bool
}

func (*CallExpression) End

func (ce *CallExpression) End() token.Position

func (*CallExpression) Pos

func (ce *CallExpression) Pos() token.Position

func (*CallExpression) String

func (ce *CallExpression) String() string

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

type CaseExpression

type CaseExpression struct {
	Token       token.Token
	Default     bool //default case or not
	Exprs       []Expression
	Block       *BlockStatement
	RBraceToken token.Token //used in End() method
}

case expr1, expr2, ... { block } default { block }

func (*CaseExpression) End

func (ce *CaseExpression) End() token.Position

func (*CaseExpression) Pos

func (ce *CaseExpression) Pos() token.Position

func (*CaseExpression) String

func (ce *CaseExpression) String() string

func (*CaseExpression) TokenLiteral

func (ce *CaseExpression) TokenLiteral() string

type CmdExpression

type CmdExpression struct {
	Token token.Token
	Value string
}

func (*CmdExpression) End

func (c *CmdExpression) End() token.Position

func (*CmdExpression) Pos

func (c *CmdExpression) Pos() token.Position

func (*CmdExpression) String

func (c *CmdExpression) String() string

func (*CmdExpression) TokenLiteral

func (c *CmdExpression) TokenLiteral() string

type ContinueExpression

type ContinueExpression struct {
	Token token.Token
}

/////////////////////////////////////////////////////////

CONTINUE                      //

/////////////////////////////////////////////////////////

func (*ContinueExpression) End

func (ce *ContinueExpression) End() token.Position

func (*ContinueExpression) Pos

func (ce *ContinueExpression) Pos() token.Position

func (*ContinueExpression) String

func (ce *ContinueExpression) String() string

func (*ContinueExpression) TokenLiteral

func (ce *ContinueExpression) TokenLiteral() string

type DecoratorExpr

type DecoratorExpr struct {
	Token     token.Token // '@'
	Decorator Expression  //Decorator function
	Decorated Expression  //Decorated function or another Decorator
}

@Func Decorated e.g. @logger fn demo(xx, xx) { }

func (*DecoratorExpr) End

func (dc *DecoratorExpr) End() token.Position

func (*DecoratorExpr) Pos

func (dc *DecoratorExpr) Pos() token.Position

func (*DecoratorExpr) String

func (dc *DecoratorExpr) String() string

func (*DecoratorExpr) TokenLiteral

func (dc *DecoratorExpr) TokenLiteral() string

type DoLoop

type DoLoop struct {
	Token token.Token
	Block *BlockStatement
}

do { block }

func (*DoLoop) End

func (dl *DoLoop) End() token.Position

func (*DoLoop) Pos

func (dl *DoLoop) Pos() token.Position

func (*DoLoop) String

func (dl *DoLoop) String() string

func (*DoLoop) TokenLiteral

func (dl *DoLoop) TokenLiteral() string

type Expression

type Expression interface {
	Node
	// contains filtered or unexported methods
}

type ExpressionStatement

type ExpressionStatement struct {
	Token      token.Token
	Expression Expression
}

func (*ExpressionStatement) End

func (*ExpressionStatement) Pos

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

type FallthroughExpression

type FallthroughExpression struct {
	Token token.Token
}

func (*FallthroughExpression) End

func (*FallthroughExpression) Pos

t: through

func (*FallthroughExpression) String

func (t *FallthroughExpression) String() string

func (*FallthroughExpression) TokenLiteral

func (t *FallthroughExpression) TokenLiteral() string

type ForEachArrayLoop

type ForEachArrayLoop struct {
	Token token.Token
	Var   string
	Value Expression //value to range over
	Block *BlockStatement
}

for var in value { block }

func (*ForEachArrayLoop) End

func (fal *ForEachArrayLoop) End() token.Position

func (*ForEachArrayLoop) Pos

func (fal *ForEachArrayLoop) Pos() token.Position

func (*ForEachArrayLoop) String

func (fal *ForEachArrayLoop) String() string

func (*ForEachArrayLoop) TokenLiteral

func (fal *ForEachArrayLoop) TokenLiteral() string

type ForEachMapLoop

type ForEachMapLoop struct {
	Token token.Token
	Key   string
	Value string
	X     Expression //value to range over
	Block *BlockStatement
}

for key, value in X { block }

func (*ForEachMapLoop) End

func (fml *ForEachMapLoop) End() token.Position

func (*ForEachMapLoop) Pos

func (fml *ForEachMapLoop) Pos() token.Position

func (*ForEachMapLoop) String

func (fml *ForEachMapLoop) String() string

func (*ForEachMapLoop) TokenLiteral

func (fml *ForEachMapLoop) TokenLiteral() string

type ForEverLoop

type ForEverLoop struct {
	Token token.Token
	Block *BlockStatement
}

for { block }

func (*ForEverLoop) End

func (fel *ForEverLoop) End() token.Position

func (*ForEverLoop) Pos

func (fel *ForEverLoop) Pos() token.Position

func (*ForEverLoop) String

func (fel *ForEverLoop) String() string

func (*ForEverLoop) TokenLiteral

func (fel *ForEverLoop) TokenLiteral() string

type FunctionLiteral

type FunctionLiteral struct {
	Token      token.Token // The 'fn' token
	Name       string      // function's name
	Parameters []*Identifier
	Variadic   bool
	Body       *BlockStatement
}

func (*FunctionLiteral) End

func (fl *FunctionLiteral) End() token.Position

func (*FunctionLiteral) Pos

func (fl *FunctionLiteral) Pos() token.Position

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

type HashLiteral

type HashLiteral struct {
	Token       token.Token
	Pairs       map[Expression]Expression
	RBraceToken token.Token
	IsOrdered   bool
	Order       []Expression //For keeping the order of the hash key
}

func (*HashLiteral) End

func (h *HashLiteral) End() token.Position

func (*HashLiteral) Pos

func (h *HashLiteral) Pos() token.Position

func (*HashLiteral) String

func (h *HashLiteral) String() string

func (*HashLiteral) TokenLiteral

func (h *HashLiteral) TokenLiteral() string

type Identifier

type Identifier struct {
	Token token.Token
	Value string
}

func (*Identifier) End

func (i *Identifier) End() token.Position

func (*Identifier) Pos

func (i *Identifier) Pos() token.Position

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

type IfConditionExpr

type IfConditionExpr struct {
	Token token.Token
	Cond  Expression      //condition
	Body  *BlockStatement //body
}

if/else-if condition

func (*IfConditionExpr) End

func (ic *IfConditionExpr) End() token.Position

func (*IfConditionExpr) Pos

func (ic *IfConditionExpr) Pos() token.Position

func (*IfConditionExpr) String

func (ic *IfConditionExpr) String() string

func (*IfConditionExpr) TokenLiteral

func (ic *IfConditionExpr) TokenLiteral() string

type IfExpression

type IfExpression struct {
	Token       token.Token
	Conditions  []*IfConditionExpr //if or else-if part
	Alternative *BlockStatement    //else part
}

func (*IfExpression) End

func (ifex *IfExpression) End() token.Position

func (*IfExpression) Pos

func (ifex *IfExpression) Pos() token.Position

func (*IfExpression) String

func (ifex *IfExpression) String() string

func (*IfExpression) TokenLiteral

func (ifex *IfExpression) TokenLiteral() string

type ImportStatement

type ImportStatement struct {
	Token      token.Token
	ImportPath string
	Program    *Program
}

func (*ImportStatement) End

func (is *ImportStatement) End() token.Position

func (*ImportStatement) Pos

func (is *ImportStatement) Pos() token.Position

func (*ImportStatement) String

func (is *ImportStatement) String() string

func (*ImportStatement) TokenLiteral

func (is *ImportStatement) TokenLiteral() string

type IndexExpression

type IndexExpression struct {
	Token token.Token
	Left  Expression
	Index Expression
}

<Left-Expression>[<Index-Expression>]

func (*IndexExpression) End

func (ie *IndexExpression) End() token.Position

func (*IndexExpression) Pos

func (ie *IndexExpression) Pos() token.Position

func (*IndexExpression) String

func (ie *IndexExpression) String() string

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

type InfixExpression

type InfixExpression struct {
	Token        token.Token
	Operator     string
	Right        Expression
	Left         Expression
	HasNext      bool
	NextOperator string
	Next         Expression
}

1 + 2 * 3

func (*InfixExpression) End

func (ie *InfixExpression) End() token.Position

func (*InfixExpression) Pos

func (ie *InfixExpression) Pos() token.Position

func (*InfixExpression) String

func (ie *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (ie *InfixExpression) TokenLiteral() string

type LetStatement

type LetStatement struct {
	Token  token.Token
	Names  []*Identifier
	Values []Expression
}

let <identifier1>,<identifier2>,... = <expression1>,<expression2>,...

func (*LetStatement) End

func (ls *LetStatement) End() token.Position

func (*LetStatement) Pos

func (ls *LetStatement) Pos() token.Position

func (*LetStatement) String

func (ls *LetStatement) String() string

func (*LetStatement) TokenLiteral

func (ls *LetStatement) TokenLiteral() string

type MethodCallExpression

type MethodCallExpression struct {
	Token  token.Token
	Object Expression
	Call   Expression
}

func (*MethodCallExpression) End

func (*MethodCallExpression) Pos

func (*MethodCallExpression) String

func (mc *MethodCallExpression) String() string

func (*MethodCallExpression) TokenLiteral

func (mc *MethodCallExpression) TokenLiteral() string

type MultiAssignStatement

type MultiAssignStatement struct {
	Token  token.Token
	Names  []Expression
	Values []Expression
}

func (*MultiAssignStatement) End

func (*MultiAssignStatement) Pos

func (*MultiAssignStatement) String

func (as *MultiAssignStatement) String() string

func (*MultiAssignStatement) TokenLiteral

func (as *MultiAssignStatement) TokenLiteral() string

type NilLiteral

type NilLiteral struct {
	Token token.Token
}

func (*NilLiteral) End

func (n *NilLiteral) End() token.Position

func (*NilLiteral) Pos

func (n *NilLiteral) Pos() token.Position

func (*NilLiteral) String

func (n *NilLiteral) String() string

func (*NilLiteral) TokenLiteral

func (n *NilLiteral) TokenLiteral() string

type Node

type Node interface {
	Pos() token.Position // position of first character belonging to the node
	End() token.Position // position of first character immediately after the node

	TokenLiteral() string
	String() string
}

type NumberLiteral

type NumberLiteral struct {
	Token token.Token
	Value float64
}

func (*NumberLiteral) End

func (nl *NumberLiteral) End() token.Position

func (*NumberLiteral) Pos

func (nl *NumberLiteral) Pos() token.Position

func (*NumberLiteral) String

func (nl *NumberLiteral) String() string

func (*NumberLiteral) TokenLiteral

func (nl *NumberLiteral) TokenLiteral() string

type PostfixExpression

type PostfixExpression struct {
	Token    token.Token
	Left     Expression
	Operator string
}

func (*PostfixExpression) End

func (pe *PostfixExpression) End() token.Position

func (*PostfixExpression) Pos

func (pe *PostfixExpression) Pos() token.Position

func (*PostfixExpression) String

func (pe *PostfixExpression) String() string

func (*PostfixExpression) TokenLiteral

func (pe *PostfixExpression) TokenLiteral() string

type PrefixExpression

type PrefixExpression struct {
	Token    token.Token
	Operator string
	Right    Expression
}

-2, -3

func (*PrefixExpression) End

func (pe *PrefixExpression) End() token.Position

func (*PrefixExpression) Pos

func (pe *PrefixExpression) Pos() token.Position

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

type Program

type Program struct {
	Statements []Statement
	Imports    map[string]*ImportStatement
}

func (*Program) End

func (p *Program) End() token.Position

func (*Program) Pos

func (p *Program) Pos() token.Position

func (*Program) String

func (p *Program) String() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

type RegExLiteral

type RegExLiteral struct {
	Token token.Token
	Value string // value of the regular expression
}

func (*RegExLiteral) End

func (rel *RegExLiteral) End() token.Position

func (*RegExLiteral) Pos

func (rel *RegExLiteral) Pos() token.Position

func (*RegExLiteral) String

func (rel *RegExLiteral) String() string

func (*RegExLiteral) TokenLiteral

func (rel *RegExLiteral) TokenLiteral() string

type ReturnStatement

type ReturnStatement struct {
	Token        token.Token // the 'return' token
	ReturnValue  Expression  //for old campatibility
	ReturnValues []Expression
}

func (*ReturnStatement) End

func (rs *ReturnStatement) End() token.Position

func (*ReturnStatement) Pos

func (rs *ReturnStatement) Pos() token.Position

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

type StringLiteral

type StringLiteral struct {
	Token token.Token
	Value string
}

func (*StringLiteral) End

func (s *StringLiteral) End() token.Position

func (*StringLiteral) Pos

func (s *StringLiteral) Pos() token.Position

func (*StringLiteral) String

func (s *StringLiteral) String() string

func (*StringLiteral) TokenLiteral

func (s *StringLiteral) TokenLiteral() string

type StructStatement

type StructStatement struct {
	Token token.Token
	Name  string //struct's name

	Block       *BlockStatement //used in the String() method
	RBraceToken token.Token     //used in End() method
}

func (*StructStatement) End

func (s *StructStatement) End() token.Position

func (*StructStatement) Pos

func (s *StructStatement) Pos() token.Position

func (*StructStatement) String

func (s *StructStatement) String() string

func (*StructStatement) TokenLiteral

func (s *StructStatement) TokenLiteral() string

type SwitchExpression

type SwitchExpression struct {
	Token       token.Token
	Expr        Expression
	Cases       []*CaseExpression
	RBraceToken token.Token //used in End() method
}
    switch Expr {
    case expr1, expr2, ... { block1 }
    case expr3, expr4, ... { block2 }
    ...
    default { block }
}

func (*SwitchExpression) End

func (se *SwitchExpression) End() token.Position

func (*SwitchExpression) Pos

func (se *SwitchExpression) Pos() token.Position

func (*SwitchExpression) String

func (se *SwitchExpression) String() string

func (*SwitchExpression) TokenLiteral

func (se *SwitchExpression) TokenLiteral() string

type TailCallStatement

type TailCallStatement struct {
	Token token.Token // the 'tailcall' token
	Call  Expression
}

tailcall funcCall(param1, param2, ...)

func (*TailCallStatement) End

func (ts *TailCallStatement) End() token.Position

func (*TailCallStatement) Pos

func (ts *TailCallStatement) Pos() token.Position

func (*TailCallStatement) String

func (ts *TailCallStatement) String() string

func (*TailCallStatement) TokenLiteral

func (ts *TailCallStatement) TokenLiteral() string

type ThrowStmt

type ThrowStmt struct {
	Token token.Token
	Expr  Expression
}

throw <expression>

func (*ThrowStmt) End

func (ts *ThrowStmt) End() token.Position

func (*ThrowStmt) Pos

func (ts *ThrowStmt) Pos() token.Position

func (*ThrowStmt) String

func (ts *ThrowStmt) String() string

func (*ThrowStmt) TokenLiteral

func (ts *ThrowStmt) TokenLiteral() string

type TryStmt

type TryStmt struct {
	Token   token.Token
	Try     *BlockStatement
	Var     string
	Catch   *BlockStatement
	Finally *BlockStatement
}

TryStmt provide "try/catch/finally" statement.

func (*TryStmt) End

func (t *TryStmt) End() token.Position

func (*TryStmt) Pos

func (t *TryStmt) Pos() token.Position

func (*TryStmt) String

func (t *TryStmt) String() string

func (*TryStmt) TokenLiteral

func (t *TryStmt) TokenLiteral() string

type TupleLiteral

type TupleLiteral struct {
	Token   token.Token
	Members []Expression
}

func (*TupleLiteral) End

func (t *TupleLiteral) End() token.Position

func (*TupleLiteral) Pos

func (t *TupleLiteral) Pos() token.Position

func (*TupleLiteral) String

func (t *TupleLiteral) String() string

func (*TupleLiteral) TokenLiteral

func (t *TupleLiteral) TokenLiteral() string

type WhileLoop

type WhileLoop struct {
	Token     token.Token
	Condition Expression
	Block     *BlockStatement
}

while condition { block }

func (*WhileLoop) End

func (wl *WhileLoop) End() token.Position

func (*WhileLoop) Pos

func (wl *WhileLoop) Pos() token.Position

func (*WhileLoop) String

func (wl *WhileLoop) String() string

func (*WhileLoop) TokenLiteral

func (wl *WhileLoop) TokenLiteral() string

Jump to

Keyboard shortcuts

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