Documentation ¶
Index ¶
- Variables
- type Evaluator
- type Operator
- type Stack
- type Token
- func (t *Token) Error() error
- func (t *Token) Float() float64
- func (t *Token) Int() (int, bool)
- func (t *Token) IsError() bool
- func (t *Token) IsFunc() bool
- func (t *Token) IsNumber() bool
- func (t *Token) IsOperator() bool
- func (t *Token) IsSeparator() bool
- func (t *Token) LP() bool
- func (t *Token) RP() bool
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultFunctions = map[string]func(stack *Stack) error{ "max": func(stack *Stack) error { a := stack.Pop() b := stack.Pop() n1, isInt1 := a.Int() if !isInt1 { return fmt.Errorf("Token %s must be integer", a.Literal) } n2, isInt2 := b.Int() if !isInt2 { return fmt.Errorf("Token %s must be integer", b.Literal) } r := n2 if n2 < n1 { r = n1 } stack.Push(Token{ Token: token.INT, Literal: strconv.Itoa(r), Pos: b.Pos, }) return nil }, "min": func(stack *Stack) error { a := stack.Pop() b := stack.Pop() n1, isInt1 := a.Int() if !isInt1 { return fmt.Errorf("Token %s must be integer", a.Literal) } n2, isInt2 := b.Int() if !isInt2 { return fmt.Errorf("Token %s must be integer", b.Literal) } r := n2 if n2 > n1 { r = n1 } stack.Push(Token{ Token: token.INT, Literal: strconv.Itoa(r), Pos: b.Pos, }) return nil }, }
View Source
var DefaultOperators = map[token.Token]Operator{ token.ADD: { // contains filtered or unexported fields }, token.SUB: { // contains filtered or unexported fields }, token.MUL: { // contains filtered or unexported fields }, token.QUO: { // contains filtered or unexported fields }, token.REM: { // contains filtered or unexported fields }, token.AND: { // contains filtered or unexported fields }, token.OR: { // contains filtered or unexported fields }, token.XOR: { // contains filtered or unexported fields }, token.SHL: { // contains filtered or unexported fields }, token.SHR: { // contains filtered or unexported fields }, token.LAND: { // contains filtered or unexported fields }, token.LOR: { // contains filtered or unexported fields }, token.EQL: { // contains filtered or unexported fields }, token.LSS: { // contains filtered or unexported fields }, token.GTR: { // contains filtered or unexported fields }, token.NEQ: { // contains filtered or unexported fields }, token.LEQ: { // contains filtered or unexported fields }, token.GEQ: { // contains filtered or unexported fields }, token.NOT: { // contains filtered or unexported fields }, }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.