parser

package
v0.0.0-...-f4e5431 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVarList

func GetVarList(expr interfaces.Expression) []string

GetVarList - return list of variables which are used in the expression

Types

type Parser

type Parser struct {
	Operators  [funcs.LevelsOfPriorities]map[string]funcs.FuncType
	Expression interfaces.Expression
}

Parser - context structure, which contains user-defined function

func NewParser

func NewParser() *Parser

NewParser - create a Parser object with default set of operators and functions

func (*Parser) AddFunction

func (p *Parser) AddFunction(f funcs.FuncType, s string)

AddFunction - add user's function and it string representation

func (*Parser) Evaluate

func (p *Parser) Evaluate(vars map[string]decimal.Decimal) (decimal.Decimal, error)

Evaluate - execute expression and return result

func (*Parser) GetFunctions

func (p *Parser) GetFunctions() [funcs.LevelsOfPriorities]map[string]funcs.FuncType

func (*Parser) Parse

func (p *Parser) Parse(str string) (interfaces.Expression, error)

Parse - parsing a string format math expression, return Exp tree

func (*Parser) String

func (p *Parser) String() string

String - string representation of expression

Jump to

Keyboard shortcuts

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