Documentation
¶
Index ¶
Constants ¶
View Source
const ( LITERAL uint8 = 1 NAME uint8 = 2 FUNCTION_NAME uint8 = 3 ADD_OPERATOR uint8 = 4 SUB_OPERATOR uint8 = 5 TIMES_OPERATOR uint8 = 6 DIV_OPERATOR uint8 = 7 OPEN_PARENTHESIS uint8 = 8 CLOSE_PARENTHESIS uint8 = 9 EMPTY uint8 = 10 )
types of tokens used in expressions (terminal symbols)
View Source
const ( TARGET uint8 = 101 EXPRESSION uint8 = 102 TERM uint8 = 103 EXPRESSION_LINE uint8 = 104 FACTOR uint8 = 105 TERM_LINE uint8 = 106 PARAMETER_LIST uint8 = 107 )
types of syntax elements used in expressions
View Source
const ( UNKNOWN uint8 = 0 CONSTANT uint8 = 1 VARIABLE uint8 = 2 FUNCTION uint8 = 3 )
types of symbols
Variables ¶
This section is empty.
Functions ¶
func AddStandardMathFuncs ¶
func AddStandardMathFuncs(s SymbolTable)
AddStandardMathFuncs add to symbol table all standard mathematical functions
Types ¶
type Expression ¶
type Expression interface {
Evaluate(symbol SymbolTable) (float64, error)
}
func NewExpression ¶
func NewExpression(expression string) (Expression, error)
New create a new parsed expression
type ParsedExpression ¶
type ParsedExpression struct {
// contains filtered or unexported fields
}
func (*ParsedExpression) Evaluate ¶
func (p *ParsedExpression) Evaluate(symbol SymbolTable) (float64, error)
evaluatePolishReverse evaluate the Polish reverse expression (postfix) and return a numerical result
type QueueAsArray ¶
type QueueAsArray struct {
// contains filtered or unexported fields
}
func (*QueueAsArray) Get ¶
func (q *QueueAsArray) Get() interface{}
func (*QueueAsArray) IsEmpty ¶
func (q *QueueAsArray) IsEmpty() bool
func (*QueueAsArray) Put ¶
func (q *QueueAsArray) Put(value interface{})
type StackAsArray ¶
type StackAsArray struct {
// contains filtered or unexported fields
}
func (*StackAsArray) IsEmpty ¶
func (s *StackAsArray) IsEmpty() bool
IsEmpty return true if the stack is empty
func (*StackAsArray) Pop ¶
func (s *StackAsArray) Pop() interface{}
Pop return the item in the top of the stack after removing it
func (*StackAsArray) Push ¶
func (s *StackAsArray) Push(value interface{})
Push pushes a new item to the top of the stack
type SymbolTable ¶
type SymbolTable interface { Exists(name string) bool SetValue(name string, value float64) GetValue(name string) (float64, error) DefineFunc(name string, function func(parameter ...float64) float64, params int) InvokeFunc(name string, parameter ...float64) (float64, error) }
func NewFloatSymbolTable ¶
func NewFloatSymbolTable() SymbolTable
New create a new float64 onlye symbol table
Click to show internal directories.
Click to hide internal directories.