object

package
v0.0.0-...-1d1a010 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidOp        = errors.New("invalid operator")
	ErrNotImplemented   = errors.New("not implemented")
	ErrDivByZero        = errors.New("division by zero")
	ErrModByZero        = errors.New("modulo by zero")
	ErrInvalidIndexType = errors.New("invalid index type")
	ErrIndexOutOfRange  = errors.New("index out of range")
	ErrUnknownMethod    = errors.New("unknown method")
)

Functions

This section is empty.

Types

type Arithmetic

type Arithmetic interface {
	// LogicalNot реализация логического унарного НЕ
	LogicalNot() (Object, error)
	// LogicalOr реализация логического ИЛИ
	LogicalOr() (Object, error)
	// LogicalAnd реализация логического И для объекта
	LogicalAnd(Object) (Object, error)
	// Equal реализация сравнения между объектами
	Equal(Object) (Object, error)
	// NotEqual реализация отрицательного сравнения между объектами
	NotEqual(Object) (Object, error)
	// Negative реализация унарного отрицания
	Negative() (Object, error)
	// GtEq реализация сравнения больше либо равно
	GtEq(Object) (Object, error)
	// Gt реализация сравнения строго больше
	Gt(Object) (Object, error)
	// LtEq реализация сравнения меньше либо равно
	LtEq(Object) (Object, error)
	// Lt реализация сравнения строго меньше
	Lt(Object) (Object, error)
	// Add сложение двух объектов
	Add(Object) (Object, error)
	// Sub вычитание двух объектов
	Sub(Object) (Object, error)
	// Pow возведение в степень
	Pow(Object) (Object, error)
	// Mul умножение объектов
	Mul(Object) (Object, error)
	// Div деление объектов
	Div(Object) (Object, error)
	// Mod получение целочисленного остатка
	Mod(Object) (Object, error)
	// Xor ксоринг объектов
	Xor(Object) (Object, error)
}

type ArithmeticImpl

type ArithmeticImpl struct{}

func (*ArithmeticImpl) Add

func (a *ArithmeticImpl) Add(Object) (Object, error)

func (*ArithmeticImpl) Div

func (a *ArithmeticImpl) Div(Object) (Object, error)

func (*ArithmeticImpl) Equal

func (a *ArithmeticImpl) Equal(Object) (Object, error)

func (*ArithmeticImpl) Gt

func (a *ArithmeticImpl) Gt(Object) (Object, error)

func (*ArithmeticImpl) GtEq

func (a *ArithmeticImpl) GtEq(Object) (Object, error)

func (*ArithmeticImpl) LogicalAnd

func (a *ArithmeticImpl) LogicalAnd(Object) (Object, error)

func (*ArithmeticImpl) LogicalNot

func (a *ArithmeticImpl) LogicalNot() (Object, error)

func (*ArithmeticImpl) LogicalOr

func (a *ArithmeticImpl) LogicalOr(Object) (Object, error)

func (*ArithmeticImpl) Lt

func (a *ArithmeticImpl) Lt(Object) (Object, error)

func (*ArithmeticImpl) LtEq

func (a *ArithmeticImpl) LtEq(Object) (Object, error)

func (*ArithmeticImpl) Mod

func (a *ArithmeticImpl) Mod(Object) (Object, error)

func (*ArithmeticImpl) Mul

func (a *ArithmeticImpl) Mul(Object) (Object, error)

func (*ArithmeticImpl) Negative

func (a *ArithmeticImpl) Negative() (Object, error)

func (*ArithmeticImpl) NotEqual

func (a *ArithmeticImpl) NotEqual(Object) (Object, error)

func (*ArithmeticImpl) Pow

func (a *ArithmeticImpl) Pow(Object) (Object, error)

func (*ArithmeticImpl) Sub

func (a *ArithmeticImpl) Sub(Object) (Object, error)

func (*ArithmeticImpl) Xor

func (a *ArithmeticImpl) Xor(Object) (Object, error)

type Bool

type Bool struct {
	Impl
	// contains filtered or unexported fields
}

Bool булевый тип

func NewBool

func NewBool(v bool) *Bool

func (*Bool) Add

func (o *Bool) Add(rs Object) (Object, error)

func (*Bool) BinaryOp

func (o *Bool) BinaryOp(op int, rhs Object) (Object, error)

func (*Bool) Div

func (o *Bool) Div(rs Object) (Object, error)

func (*Bool) Equal

func (o *Bool) Equal(rs Object) (Object, error)

func (*Bool) GetValue

func (o *Bool) GetValue() any

func (*Bool) Gt

func (o *Bool) Gt(rs Object) (Object, error)

func (*Bool) GtEq

func (o *Bool) GtEq(rs Object) (Object, error)

func (*Bool) LogicalAnd

func (o *Bool) LogicalAnd(rs Object) (Object, error)

func (*Bool) LogicalNot

func (o *Bool) LogicalNot() (Object, error)

func (*Bool) LogicalOr

func (o *Bool) LogicalOr(rs Object) (Object, error)

func (*Bool) Lt

func (o *Bool) Lt(rs Object) (Object, error)

func (*Bool) LtEq

func (o *Bool) LtEq(rs Object) (Object, error)

func (*Bool) Mod

func (o *Bool) Mod(rs Object) (Object, error)

func (*Bool) Mul

func (o *Bool) Mul(rs Object) (Object, error)

func (*Bool) Negative

func (o *Bool) Negative() (Object, error)

func (*Bool) NotEqual

func (o *Bool) NotEqual(rs Object) (Object, error)

func (*Bool) Pow

func (o *Bool) Pow(rs Object) (Object, error)

func (*Bool) String

func (o *Bool) String() string

func (*Bool) Sub

func (o *Bool) Sub(rs Object) (Object, error)

func (*Bool) TypeName

func (o *Bool) TypeName() string

func (*Bool) UnaryOp

func (o *Bool) UnaryOp(op int) (Object, error)

func (*Bool) Xor

func (o *Bool) Xor(rs Object) (Object, error)

type BuiltinFunc

type BuiltinFunc struct {
	Impl
	// contains filtered or unexported fields
}

BuiltinFunc функция

func NewBuiltinFunc

func NewBuiltinFunc(
	n string,
	c func(args ...Object) (Object, error),
) *BuiltinFunc

NewBuiltinFunc новая встроенная функция

func (*BuiltinFunc) BinaryOp

func (o *BuiltinFunc) BinaryOp(_ int, _ Object) (Object, error)

func (*BuiltinFunc) Call

func (o *BuiltinFunc) Call(args ...Object) (Object, error)

func (*BuiltinFunc) CanCall

func (o *BuiltinFunc) CanCall() bool

func (*BuiltinFunc) String

func (o *BuiltinFunc) String() string

func (*BuiltinFunc) TypeName

func (o *BuiltinFunc) TypeName() string

func (*BuiltinFunc) UnaryOp

func (o *BuiltinFunc) UnaryOp(_ int) (Object, error)

type Dict

type Dict struct {
	Impl
	// contains filtered or unexported fields
}

Dict мапа

func NewDict

func NewDict(v map[string]Object) *Dict

func (*Dict) BinaryOp

func (o *Dict) BinaryOp(op int, rhs Object) (Object, error)

func (*Dict) CanIterate

func (o *Dict) CanIterate() bool

func (*Dict) Equal

func (o *Dict) Equal(rs Object) (Object, error)

func (*Dict) GetValue

func (o *Dict) GetValue() any

func (*Dict) IndexGet

func (o *Dict) IndexGet(rs Object) (Object, error)

func (*Dict) IndexSet

func (o *Dict) IndexSet(idx Object, rs Object) error

func (*Dict) Iterate

func (o *Dict) Iterate() Iterator

func (*Dict) LogicalAnd

func (o *Dict) LogicalAnd(rs Object) (Object, error)

func (*Dict) LogicalNot

func (o *Dict) LogicalNot() (Object, error)

func (*Dict) LogicalOr

func (o *Dict) LogicalOr(rs Object) (Object, error)

func (*Dict) MethodCall

func (o *Dict) MethodCall(name string, args ...Object) (Object, error)

func (*Dict) MethodLen

func (o *Dict) MethodLen(args ...Object) (Object, error)

func (*Dict) MethodPop

func (o *Dict) MethodPop(args ...Object) (Object, error)

func (*Dict) NotEqual

func (o *Dict) NotEqual(rs Object) (Object, error)

func (*Dict) String

func (o *Dict) String() string

func (*Dict) TypeName

func (o *Dict) TypeName() string

func (*Dict) UnaryOp

func (o *Dict) UnaryOp(op int) (Object, error)

type Float

type Float struct {
	Impl
	// contains filtered or unexported fields
}

Float тип с плавающей точкой

func NewFloat

func NewFloat(value float64) *Float

func (*Float) Add

func (o *Float) Add(rs Object) (Object, error)

func (*Float) BinaryOp

func (o *Float) BinaryOp(op int, rhs Object) (Object, error)

func (*Float) Div

func (o *Float) Div(rs Object) (Object, error)

func (*Float) Equal

func (o *Float) Equal(rs Object) (Object, error)

func (*Float) GetValue

func (o *Float) GetValue() any

func (*Float) Gt

func (o *Float) Gt(rs Object) (Object, error)

func (*Float) GtEq

func (o *Float) GtEq(rs Object) (Object, error)

func (*Float) LogicalAnd

func (o *Float) LogicalAnd(rs Object) (Object, error)

func (*Float) LogicalNot

func (o *Float) LogicalNot() (Object, error)

func (*Float) LogicalOr

func (o *Float) LogicalOr(rs Object) (Object, error)

func (*Float) Lt

func (o *Float) Lt(rs Object) (Object, error)

func (*Float) LtEq

func (o *Float) LtEq(rs Object) (Object, error)

func (*Float) Mod

func (o *Float) Mod(rs Object) (Object, error)

func (*Float) Mul

func (o *Float) Mul(rs Object) (Object, error)

func (*Float) Negative

func (o *Float) Negative() (Object, error)

func (*Float) NotEqual

func (o *Float) NotEqual(rs Object) (Object, error)

func (*Float) Pow

func (o *Float) Pow(rs Object) (Object, error)

func (*Float) String

func (o *Float) String() string

func (*Float) Sub

func (o *Float) Sub(rs Object) (Object, error)

func (*Float) TypeName

func (o *Float) TypeName() string

func (*Float) UnaryOp

func (o *Float) UnaryOp(op int) (Object, error)

type Impl

type Impl struct{}

Impl базовая реализация объекта

func (*Impl) Add

func (a *Impl) Add(Object) (Object, error)

func (*Impl) BinaryOp

func (o *Impl) BinaryOp(_ int, _ Object) (Object, error)

func (*Impl) Call

func (o *Impl) Call(_ ...Object) (Object, error)

func (*Impl) CanCall

func (o *Impl) CanCall() bool

func (*Impl) CanIterate

func (o *Impl) CanIterate() bool

func (*Impl) Div

func (a *Impl) Div(Object) (Object, error)

func (*Impl) Equal

func (a *Impl) Equal(Object) (Object, error)

func (*Impl) GetValue

func (o *Impl) GetValue() any

func (*Impl) Gt

func (a *Impl) Gt(Object) (Object, error)

func (*Impl) GtEq

func (a *Impl) GtEq(Object) (Object, error)

func (*Impl) IndexGet

func (o *Impl) IndexGet(Object) (Object, error)

func (*Impl) IndexSet

func (o *Impl) IndexSet(Object, Object) error

func (*Impl) Iterate

func (o *Impl) Iterate() Iterator

func (*Impl) LogicalAnd

func (a *Impl) LogicalAnd(Object) (Object, error)

func (*Impl) LogicalNot

func (a *Impl) LogicalNot() (Object, error)

func (*Impl) LogicalOr

func (a *Impl) LogicalOr(Object) (Object, error)

func (*Impl) Lt

func (a *Impl) Lt(Object) (Object, error)

func (*Impl) LtEq

func (a *Impl) LtEq(Object) (Object, error)

func (*Impl) MethodCall

func (o *Impl) MethodCall(string, ...Object) (Object, error)

func (*Impl) Mod

func (a *Impl) Mod(Object) (Object, error)

func (*Impl) Mul

func (a *Impl) Mul(Object) (Object, error)

func (*Impl) Negative

func (a *Impl) Negative() (Object, error)

func (*Impl) NotEqual

func (a *Impl) NotEqual(Object) (Object, error)

func (*Impl) Pow

func (a *Impl) Pow(Object) (Object, error)

func (*Impl) String

func (o *Impl) String() string

func (*Impl) Sub

func (a *Impl) Sub(Object) (Object, error)

func (*Impl) TypeName

func (o *Impl) TypeName() string

func (*Impl) UnaryOp

func (o *Impl) UnaryOp(_ int) (Object, error)

func (*Impl) Xor

func (a *Impl) Xor(Object) (Object, error)

type Int

type Int struct {
	Impl
	// contains filtered or unexported fields
}

Int целочисленный тип

func NewInt

func NewInt(value int64) *Int

NewInt создание нового объекта с типом Int

func (*Int) Add

func (o *Int) Add(rs Object) (Object, error)

func (*Int) BinaryOp

func (o *Int) BinaryOp(op int, rhs Object) (Object, error)

func (*Int) Div

func (o *Int) Div(rs Object) (Object, error)

func (*Int) Equal

func (o *Int) Equal(rs Object) (Object, error)

func (*Int) GetValue

func (o *Int) GetValue() any

func (*Int) Gt

func (o *Int) Gt(rs Object) (Object, error)

func (*Int) GtEq

func (o *Int) GtEq(rs Object) (Object, error)

func (*Int) LogicalAnd

func (o *Int) LogicalAnd(rs Object) (Object, error)

func (*Int) LogicalNot

func (o *Int) LogicalNot() (Object, error)

func (*Int) LogicalOr

func (o *Int) LogicalOr(rs Object) (Object, error)

func (*Int) Lt

func (o *Int) Lt(rs Object) (Object, error)

func (*Int) LtEq

func (o *Int) LtEq(rs Object) (Object, error)

func (*Int) Mod

func (o *Int) Mod(rs Object) (Object, error)

func (*Int) Mul

func (o *Int) Mul(rs Object) (Object, error)

func (*Int) Negative

func (o *Int) Negative() (Object, error)

func (*Int) NotEqual

func (o *Int) NotEqual(rs Object) (Object, error)

func (*Int) Pow

func (o *Int) Pow(rs Object) (Object, error)

func (*Int) String

func (o *Int) String() string

func (*Int) Sub

func (o *Int) Sub(rs Object) (Object, error)

func (*Int) TypeName

func (o *Int) TypeName() string

func (*Int) UnaryOp

func (o *Int) UnaryOp(op int) (Object, error)

func (*Int) Xor

func (o *Int) Xor(rs Object) (Object, error)

type Iterator

type Iterator interface {
	Object
	// Next возвращает true если есть еще элементы для обработки
	Next() bool
	// Key возвращает ключ или индекс текущего элемента
	Key() Object
	// Value возвращает значение текущего элемента
	Value() Object
}

type List

type List struct {
	Impl
	// contains filtered or unexported fields
}

список, содержащий другие объекты

func NewList

func NewList(v []Object) *List

func (*List) Add

func (o *List) Add(rs Object) (Object, error)

func (*List) BinaryOp

func (o *List) BinaryOp(op int, rhs Object) (Object, error)

func (*List) CanIterate

func (o *List) CanIterate() bool

func (*List) Equal

func (o *List) Equal(rs Object) (Object, error)

func (*List) GetValue

func (o *List) GetValue() any

func (*List) IndexGet

func (o *List) IndexGet(rs Object) (Object, error)

func (*List) IndexSet

func (o *List) IndexSet(idx Object, rs Object) error

func (*List) Iterate

func (o *List) Iterate() Iterator

func (*List) LogicalAnd

func (o *List) LogicalAnd(rs Object) (Object, error)

func (*List) LogicalNot

func (o *List) LogicalNot() (Object, error)

func (*List) LogicalOr

func (o *List) LogicalOr(rs Object) (Object, error)

func (*List) MethodCall

func (o *List) MethodCall(name string, args ...Object) (Object, error)

func (*List) MethodLen

func (o *List) MethodLen(args ...Object) (Object, error)

func (*List) MethodPop

func (o *List) MethodPop(args ...Object) (Object, error)

func (*List) MethodReverse

func (o *List) MethodReverse(args ...Object) (Object, error)

func (*List) Mul

func (o *List) Mul(rs Object) (Object, error)

func (*List) NotEqual

func (o *List) NotEqual(rs Object) (Object, error)

func (*List) String

func (o *List) String() string

func (*List) TypeName

func (o *List) TypeName() string

func (*List) UnaryOp

func (o *List) UnaryOp(op int) (Object, error)

type ListIterator

type ListIterator struct {
	Impl
	// contains filtered or unexported fields
}

ListIterator используется для итерирования по списку

func (*ListIterator) Key

func (i *ListIterator) Key() Object

func (*ListIterator) Next

func (i *ListIterator) Next() bool

func (*ListIterator) String

func (i *ListIterator) String() string

func (*ListIterator) TypeName

func (i *ListIterator) TypeName() string

func (*ListIterator) Value

func (i *ListIterator) Value() Object

type MapIterator

type MapIterator struct {
	Impl
	// contains filtered or unexported fields
}

func (*MapIterator) Key

func (m *MapIterator) Key() Object

func (*MapIterator) Next

func (m *MapIterator) Next() bool

func (*MapIterator) String

func (m *MapIterator) String() string

func (*MapIterator) TypeName

func (m *MapIterator) TypeName() string

func (*MapIterator) Value

func (m *MapIterator) Value() Object

type NativeFunc

type NativeFunc struct {
	Impl
	// contains filtered or unexported fields
}

NativeFunc функция

func NewNativeFunc

func NewNativeFunc(
	args []string,
	argsLen int,
	code []parser.IStmtContext,
) *NativeFunc

func (*NativeFunc) CanCall

func (o *NativeFunc) CanCall() bool

func (*NativeFunc) GetArgs

func (o *NativeFunc) GetArgs() []string

func (*NativeFunc) GetArgsLen

func (o *NativeFunc) GetArgsLen() int

func (*NativeFunc) GetCode

func (o *NativeFunc) GetCode() []parser.IStmtContext

func (*NativeFunc) SetName

func (o *NativeFunc) SetName(name string)

func (*NativeFunc) String

func (o *NativeFunc) String() string

func (*NativeFunc) TypeName

func (o *NativeFunc) TypeName() string

type Null

type Null struct {
	Impl
}

Null нулевой тип

func NewNull

func NewNull() *Null

NewNull создание нового объекта

func (*Null) BinaryOp

func (o *Null) BinaryOp(op int, rhs Object) (Object, error)

func (*Null) Equal

func (o *Null) Equal(rs Object) (Object, error)

func (*Null) LogicalAnd

func (o *Null) LogicalAnd(rs Object) (Object, error)

func (*Null) LogicalNot

func (o *Null) LogicalNot() (Object, error)

func (*Null) LogicalOr

func (o *Null) LogicalOr(rs Object) (Object, error)

func (*Null) NotEqual

func (o *Null) NotEqual(rs Object) (Object, error)

func (*Null) String

func (o *Null) String() string

func (*Null) TypeName

func (o *Null) TypeName() string

func (*Null) UnaryOp

func (o *Null) UnaryOp(op int) (Object, error)

type Object

type Object interface {
	// возращение имени типа в виде строки
	TypeName() string
	// возвращение строковое представление типа
	String() string
	// выполнение бинарной операции
	BinaryOp(int, Object) (Object, error)
	// выполнение унарной операции
	UnaryOp(int) (Object, error)
	// может ли данный объект быть вызван как функция
	CanCall() bool
	// вызов объекта как функции с аргументами
	Call(...Object) (Object, error)
	// call method of object
	MethodCall(string, ...Object) (Object, error)
	// может ли данный объект итерироваться
	CanIterate() bool
	// возвращает итератор для объекта
	Iterate() Iterator
	// получение значения из объекта
	GetValue() any
	// получение значения объекта по его индексу внутри
	IndexGet(Object) (Object, error)
	// установка значения объекта по индексу
	IndexSet(Object, Object) error
	// LogicalNot реализация логического унарного НЕ
	LogicalNot() (Object, error)
	// LogicalOr реализация логического ИЛИ
	LogicalOr(Object) (Object, error)
	// LogicalAnd реализация логического И для объекта
	LogicalAnd(Object) (Object, error)
	// Equal реализация сравнения между объектами
	Equal(Object) (Object, error)
	// NotEqual реализация отрицательного сравнения между объектами
	NotEqual(Object) (Object, error)
	// Negative реализация унарного отрицания
	Negative() (Object, error)
	// GtEq реализация сравнения больше либо равно
	GtEq(Object) (Object, error)
	// Gt реализация сравнения строго больше
	Gt(Object) (Object, error)
	// LtEq реализация сравнения меньше либо равно
	LtEq(Object) (Object, error)
	// Lt реализация сравнения строго меньше
	Lt(Object) (Object, error)
	// Add сложение двух объектов
	Add(Object) (Object, error)
	// Sub вычитание двух объектов
	Sub(Object) (Object, error)
	// Pow возведение в степень
	Pow(Object) (Object, error)
	// Mul умножение объектов
	Mul(Object) (Object, error)
	// Div деление объектов
	Div(Object) (Object, error)
	// Mod получение целочисленного остатка
	Mod(Object) (Object, error)
	// Xor ксоринг объектов
	Xor(Object) (Object, error)
}

представляет собой элементарный объект для обработки

type Str

type Str struct {
	Impl
	// contains filtered or unexported fields
}

Str тип с плавающей точкой

func NewStr

func NewStr(v string) *Str

func (*Str) Add

func (o *Str) Add(rs Object) (Object, error)

func (*Str) BinaryOp

func (o *Str) BinaryOp(op int, rhs Object) (Object, error)

func (*Str) Equal

func (o *Str) Equal(rs Object) (Object, error)

func (*Str) GetValue

func (o *Str) GetValue() any

func (*Str) Gt

func (o *Str) Gt(rs Object) (Object, error)

func (*Str) GtEq

func (o *Str) GtEq(rs Object) (Object, error)

func (*Str) IndexGet

func (o *Str) IndexGet(rs Object) (Object, error)

func (*Str) IndexSet

func (o *Str) IndexSet(idx Object, rs Object) error

func (*Str) LogicalAnd

func (o *Str) LogicalAnd(rs Object) (Object, error)

func (*Str) LogicalNot

func (o *Str) LogicalNot() (Object, error)

func (*Str) LogicalOr

func (o *Str) LogicalOr(rs Object) (Object, error)

func (*Str) Lt

func (o *Str) Lt(rs Object) (Object, error)

func (*Str) LtEq

func (o *Str) LtEq(rs Object) (Object, error)

func (*Str) MethodCall

func (o *Str) MethodCall(name string, args ...Object) (Object, error)

func (*Str) MethodLen

func (o *Str) MethodLen(args ...Object) (Object, error)

func (*Str) MethodReverse

func (o *Str) MethodReverse(args ...Object) (Object, error)

func (*Str) MethodSplit

func (o *Str) MethodSplit(args ...Object) (Object, error)

func (*Str) Mul

func (o *Str) Mul(rs Object) (Object, error)

func (*Str) NotEqual

func (o *Str) NotEqual(rs Object) (Object, error)

func (*Str) String

func (o *Str) String() string

func (*Str) TypeName

func (o *Str) TypeName() string

func (*Str) UnaryOp

func (o *Str) UnaryOp(op int) (Object, error)

type UserFunc

type UserFunc struct {
	Impl
	// contains filtered or unexported fields
}

UserFunc функция, созданная пользователем

func NewUserFunc

func NewUserFunc(
	n string,
	c func(args ...Object) (Object, error),
) *UserFunc

NewUserFunc новая пользовательская функция

func (*UserFunc) BinaryOp

func (o *UserFunc) BinaryOp(_ int, _ Object) (Object, error)

func (*UserFunc) Call

func (o *UserFunc) Call(args ...Object) (Object, error)

func (*UserFunc) CanCall

func (o *UserFunc) CanCall() bool

func (*UserFunc) String

func (o *UserFunc) String() string

func (*UserFunc) TypeName

func (o *UserFunc) TypeName() string

func (*UserFunc) UnaryOp

func (o *UserFunc) UnaryOp(_ int) (Object, error)

Jump to

Keyboard shortcuts

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