ast

package
v0.0.0-...-7ea389d Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const And = 57382
View Source
const Break = 57362
View Source
const Catch = 57369
View Source
const Continue = 57367
View Source
const Date = 57387
View Source
const Directive = 57346
View Source
const EOF = -1 // end of file
View Source
const (
	EOL = '\n' // end of line.

)
View Source
const Each = 57357
View Source
const Else = 57354
View Source
const ElseIf = 57353
View Source
const EndFunction = 57375
View Source
const EndIf = 57355
View Source
const EndLoop = 57361
View Source
const EndProcedure = 57350
View Source
const EndTry = 57370
View Source
const Export = 57386
View Source
const False = 57384
View Source
const For = 57356
View Source
const Function = 57374
View Source
const Ge = 57380
View Source
const GoTo = 57388
View Source
const GoToLabel = 57366
View Source
const Identifier = 57347
View Source
const If = 57351
View Source
const In = 57358
View Source
const Le = 57379
View Source
const Loop = 57360
View Source
const NeEq = 57378
View Source
const New = 57373
View Source
const Not = 57363
View Source
const Number = 57371
View Source
const Or = 57381
View Source
const Procedure = 57348
View Source
const Return = 57376
View Source
const String = 57372
View Source
const Then = 57352
View Source
const Throw = 57377
View Source
const To = 57359
View Source
const True = 57383
View Source
const Try = 57368
View Source
const UNARY = 57389
View Source
const Undefind = 57385
View Source
const ValueParam = 57364
View Source
const Var = 57349
View Source
const While = 57365

Variables

This section is empty.

Functions

func IF

func IF[T any](condition bool, a, b T) T

func IsDigit

func IsDigit(str string) bool

Types

type AstNode

type AstNode struct {
	ModuleStatement
	// contains filtered or unexported fields
}

func NewAST

func NewAST(code string) *AstNode

func (*AstNode) Error

func (ast *AstNode) Error(s string)

func (*AstNode) JSON

func (ast *AstNode) JSON() ([]byte, error)

func (*AstNode) Lex

func (ast *AstNode) Lex(lval *yySymType) int

func (*AstNode) Parse

func (ast *AstNode) Parse() error

func (*AstNode) Print

func (ast *AstNode) Print(conf PrintConf) string

func (*AstNode) PrintStatement

func (ast *AstNode) PrintStatement(stat Statement, conf PrintConf) string

type BreakStatement

type BreakStatement struct {
}

type CallChainStatement

type CallChainStatement struct {
	Unit Statement
	Call Statement
	// contains filtered or unexported fields
}

func (CallChainStatement) Not

func (e CallChainStatement) Not() interface{}

func (CallChainStatement) Unary

func (e CallChainStatement) Unary() interface{}

type ContinueStatement

type ContinueStatement struct {
}

type ExpStatement

type ExpStatement struct {
	Operation OperationType
	Left      interface{}
	Right     interface{}
	// contains filtered or unexported fields
}

func (*ExpStatement) Not

func (e *ExpStatement) Not() interface{}

func (*ExpStatement) Unary

func (e *ExpStatement) Unary() interface{}

type FunctionOrProcedure

type FunctionOrProcedure struct {
	Type              StatementType
	Name              string
	Body              []Statement
	Export            bool
	Params            []ParamStatement
	Directive         string
	ExplicitVariables map[string]VarStatement
}

type GlobalVariables

type GlobalVariables struct {
	Directive string
	Export    bool
	Var       VarStatement
}

type GoToLabelStatement

type GoToLabelStatement struct {
	Name string
}

type GoToStatement

type GoToStatement struct {
	Label *GoToLabelStatement
}

type INot

type INot interface {
	Not() interface{}
}

type IParams

type IParams interface {
	Params() []Statement
}

type IUnary

type IUnary interface {
	Unary() interface{}
}

type IfStatement

type IfStatement struct {
	Expression  Statement
	TrueBlock   []Statement
	IfElseBlock []Statement
	ElseBlock   []Statement
}

type ItemStatement

type ItemStatement struct {
	Item   Statement
	Object Statement
}

type LoopStatement

type LoopStatement struct {
	Body      []Statement
	For       Statement `json:"For,omitempty"`
	To        Statement `json:"To,omitempty"`
	In        Statement `json:"In,omitempty"`
	WhileExpr Statement `json:"WhileExpr,omitempty"`
}

type MethodStatement

type MethodStatement struct {
	Name  string
	Param []Statement
	// contains filtered or unexported fields
}

func (MethodStatement) Not

func (e MethodStatement) Not() interface{}

func (MethodStatement) Params

func (n MethodStatement) Params() []Statement

type ModuleStatement

type ModuleStatement struct {
	Name            string
	GlobalVariables map[string]GlobalVariables `json:"GlobalVariables,omitempty"`
	Body            []Statement
}

func (*ModuleStatement) Append

func (m *ModuleStatement) Append(item Statement, yylex yyLexer)

func (ModuleStatement) Walk

func (m ModuleStatement) Walk(callBack func(current *FunctionOrProcedure, statement *Statement))

type NewObjectStatement

type NewObjectStatement struct {
	Constructor string
	Param       []Statement
}

func (NewObjectStatement) Params

func (n NewObjectStatement) Params() []Statement

type OperationType

type OperationType int
const (
	OpPlus OperationType = iota
	OpMinus
	OpMul
	OpDiv
	OpEq  // =
	OpGt  // >
	OpLt  // <
	OpNe  // <>
	OpLe  // <=
	OpGe  // >=
	OpMod // % - деление по модулю
	OpOr
	OpAnd
)

func (OperationType) String

func (o OperationType) String() string

type ParamStatement

type ParamStatement struct {
	Name    string
	IsValue bool      `json:"IsValue,omitempty"`
	Default Statement `json:"Default,omitempty"`
}

func (*ParamStatement) DefaultValue

func (p *ParamStatement) DefaultValue(value Statement) *ParamStatement

func (*ParamStatement) Fill

func (p *ParamStatement) Fill(valueParam *Token, identifier Token) *ParamStatement

type Position

type Position struct {
	Line   int
	Column int
}

type PrintConf

type PrintConf struct {
	// Margin отступы (количество пробелов)
	Margin  int
	OneLine bool
}

type ReturnStatement

type ReturnStatement struct {
	Param Statement
}

type Statement

type Statement interface{}

type StatementType

type StatementType int
const (
	PFTypeUndefined StatementType = iota
	PFTypeProcedure
	PFTypeFunction
)

type TernaryStatement

type TernaryStatement struct {
	Expression Statement
	TrueBlock  Statement
	ElseBlock  Statement
}

type ThrowStatement

type ThrowStatement struct {
	Param Statement
}

type Token

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

func (*Token) GetPosition

func (t *Token) GetPosition() Position

func (*Token) Next

func (t *Token) Next(srs string) (token int, err error)

type TryStatement

type TryStatement struct {
	Body  []Statement
	Catch []Statement
}

type UndefinedStatement

type UndefinedStatement struct{}

type VarStatement

type VarStatement struct {
	Name string
	// contains filtered or unexported fields
}

func (VarStatement) Not

func (e VarStatement) Not() interface{}

func (VarStatement) Unary

func (e VarStatement) Unary() interface{}

Jump to

Keyboard shortcuts

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