parser

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JBaseNode

type JBaseNode struct {
	Token    *token.JToken
	StartPos *common.JPosition
	EndPos   *common.JPosition
}

JBaseNode is general node structure of AST

func (*JBaseNode) GetEndPos

func (n *JBaseNode) GetEndPos() *common.JPosition

func (*JBaseNode) GetStartPos

func (n *JBaseNode) GetStartPos() *common.JPosition

func (*JBaseNode) GetToken

func (n *JBaseNode) GetToken() *token.JToken

func (*JBaseNode) String

func (n *JBaseNode) String() string

func (*JBaseNode) Type

func (n *JBaseNode) Type() JNodeType

type JBinOpNode

type JBinOpNode struct {
	*JBaseNode
	LeftNode  JNode
	RightNode JNode
}

JBinOpNode is binary operation node structure of AST

func (*JBinOpNode) String

func (n *JBinOpNode) String() string

func (*JBinOpNode) Type

func (n *JBinOpNode) Type() JNodeType

type JBreakNode

type JBreakNode struct {
	*JBaseNode
}

func (*JBreakNode) String

func (n *JBreakNode) String() string

func (*JBreakNode) Type

func (n *JBreakNode) Type() JNodeType

type JCallExprNode

type JCallExprNode struct {
	*JBaseNode // JBaseNode fields are not use
	CallNode   JNode
	ArgNodes   []JNode
}

JCallExprNode is call expression node structure of AST

func (*JCallExprNode) String

func (n *JCallExprNode) String() string

func (*JCallExprNode) Type

func (n *JCallExprNode) Type() JNodeType

type JContinueNode

type JContinueNode struct {
	*JBaseNode
}

func (*JContinueNode) String

func (n *JContinueNode) String() string

func (*JContinueNode) Type

func (n *JContinueNode) Type() JNodeType

type JForExprNode

type JForExprNode struct {
	*JBaseNode        // JBaseNode.Token is variable name token
	StartValueNode    JNode
	EndValueNode      JNode
	StepValueNode     JNode
	BodyNode          JNode
	IsBlockStatements bool
}

JForExprNode is for expression node structure of AST

func (*JForExprNode) Type

func (n *JForExprNode) Type() JNodeType

type JFuncDefNode

type JFuncDefNode struct {
	*JBaseNode // JBaseNode.Token is function name token
	ArgTokens  []*token.JToken
	BodyNode   JNode
}

JFuncDefNode is function definition node structure of AST

func (*JFuncDefNode) String

func (n *JFuncDefNode) String() string

func (*JFuncDefNode) Type

func (n *JFuncDefNode) Type() JNodeType

type JIfExprNode

type JIfExprNode struct {
	*JBaseNode
	CaseNodes    [][2]JNode
	ElseCaseNode JNode
}

JIfExprNode is if expression node structure of AST

func (*JIfExprNode) String added in v0.1.1

func (n *JIfExprNode) String() string

func (*JIfExprNode) Type

func (n *JIfExprNode) Type() JNodeType

type JIndexExprNode

type JIndexExprNode struct {
	*JBaseNode
	IndexNode JNode
	IndexExpr JNode
}

JIndexExprNode is index expression node structure of AST

func (*JIndexExprNode) String

func (i *JIndexExprNode) String() string

func (*JIndexExprNode) Type

func (i *JIndexExprNode) Type() JNodeType

type JListNode

type JListNode struct {
	*JBaseNode
	ElementNodes      []JNode
	IsBlockStatements bool
}

JListNode is list node structure of AST

func (*JListNode) String

func (l *JListNode) String() string

func (*JListNode) Type

func (l *JListNode) Type() JNodeType

type JMapNode

type JMapNode struct {
	*JBaseNode
	ElementMap map[JNode]JNode
}

JMapNode is map node structure of AST

func (*JMapNode) String

func (m *JMapNode) String() string

func (*JMapNode) Type

func (m *JMapNode) Type() JNodeType

type JNode

type JNode interface {
	fmt.Stringer
	Type() JNodeType
	GetToken() *token.JToken
	GetStartPos() *common.JPosition
	GetEndPos() *common.JPosition
}

JNode is general node interface of AST

type JNodeType

type JNodeType int
const (
	Base JNodeType = iota
	Number
	String
	List
	Map
	VarAssign
	VarIndexAssign
	VarAccess
	BinOp
	UnaryOp
	IfExpr
	ForExpr
	WhileExpr
	FuncDefExpr
	CallExpr
	IndexExpr
	ReturnExpr
	ContinueExpr
	BreakExpr
)

type JNumberNode

type JNumberNode struct {
	*JBaseNode
}

JNumberNode is number node structure of AST

func (*JNumberNode) String

func (n *JNumberNode) String() string

func (*JNumberNode) Type

func (n *JNumberNode) Type() JNodeType

type JParser

type JParser struct {
	TokenIndex   int
	Tokens       []*token.JToken
	CurrentToken *token.JToken
}

func NewJParser

func NewJParser(tokens []*token.JToken, tokenIndex int) *JParser

func (*JParser) Parse

func (p *JParser) Parse() (JNode, error)

type JReturnNode

type JReturnNode struct {
	*JBaseNode
	ReturnNode JNode
}

func (*JReturnNode) String

func (n *JReturnNode) String() string

func (*JReturnNode) Type

func (n *JReturnNode) Type() JNodeType

type JStringNode

type JStringNode struct {
	*JBaseNode
}

JStringNode is string node structure of AST

func (*JStringNode) Type

func (s *JStringNode) Type() JNodeType

type JUnaryOpNode

type JUnaryOpNode struct {
	*JBaseNode
	Node JNode
}

JUnaryOpNode is unary operation node structure of AST

func (*JUnaryOpNode) String

func (n *JUnaryOpNode) String() string

func (*JUnaryOpNode) Type

func (n *JUnaryOpNode) Type() JNodeType

type JVarAccessNode

type JVarAccessNode struct {
	*JBaseNode
}

JVarAccessNode is variable access node structure of AST

func (*JVarAccessNode) String

func (n *JVarAccessNode) String() string

func (*JVarAccessNode) Type

func (n *JVarAccessNode) Type() JNodeType

type JVarAssignNode

type JVarAssignNode struct {
	*JBaseNode
	Node JNode
}

JVarAssignNode is variable assign node structure of AST

func (*JVarAssignNode) String

func (n *JVarAssignNode) String() string

func (*JVarAssignNode) Type

func (n *JVarAssignNode) Type() JNodeType

type JVarIndexAssignNode

type JVarIndexAssignNode struct {
	*JVarAssignNode
	IndexExprNode *JIndexExprNode
}

JVarIndexAssignNode is variable index assign node structure of AST

func (*JVarIndexAssignNode) String

func (n *JVarIndexAssignNode) String() string

func (*JVarIndexAssignNode) Type

func (n *JVarIndexAssignNode) Type() JNodeType

type JWhileExprNode

type JWhileExprNode struct {
	*JBaseNode
	ConditionNode     JNode
	BodyNode          JNode
	IsBlockStatements bool
}

JWhileExprNode is while expression node structure of AST

func (*JWhileExprNode) String added in v0.1.1

func (n *JWhileExprNode) String() string

func (*JWhileExprNode) Type

func (n *JWhileExprNode) Type() JNodeType

Jump to

Keyboard shortcuts

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