-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoperator.go
More file actions
26 lines (22 loc) · 775 Bytes
/
operator.go
File metadata and controls
26 lines (22 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package arithmetic
// operator designates an object that combines one or two operands to another.
type operator interface {
// precedence or priority of the operator.
precedence() uint8
// solve is the function the operator uses to transform the operand. The stack
// contains the operands to use. solve returns an transformed operand and an error.
solve(*stack) (interface{}, error)
}
// precedence defines the priority between operations.
// For this implementation, a higher precedence means a higher priority.
// https://en.wikipedia.org/wiki/Order_of_operations#Programming_languages
const (
precedenceOr uint8 = iota
precedenceAnd
precedenceEqual
precedenceLowerGreater
precedenceMinusPlus
precedenceDivideMultiply
precedenceExponant
precedenceUnary
)