Documentation
¶
Overview ¶
Package operator have a bundle of code describing operator of arithmetics expression
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Operators = map[token.Token]*Operator{ token.ADD: { Lit: "+", Tok: token.ADD, Precedence: 2, Associativity: L, ArgsLen: 2, Operation: func(args []float64) float64 { return args[1] + args[0] }, }, token.SUB: { Lit: "-", Tok: token.SUB, Precedence: 2, Associativity: L, ArgsLen: 2, Operation: func(args []float64) float64 { return args[1] - args[0] }, }, token.MUL: { Lit: "*", Tok: token.MUL, Precedence: 3, Associativity: L, ArgsLen: 2, Operation: func(args []float64) float64 { return args[1] * args[0] }, }, token.QUO: { Lit: "/", Tok: token.QUO, Precedence: 3, Associativity: L, ArgsLen: 2, Operation: func(args []float64) float64 { return args[1] / args[0] }, }, token.REM: { Lit: "%", Tok: token.REM, Precedence: 3, Associativity: L, ArgsLen: 2, Operation: func(args []float64) float64 { return math.Mod(args[1], args[0]) }, }, token.XOR: { Lit: "^", Tok: token.XOR, Precedence: 4, Associativity: R, ArgsLen: 2, Operation: func(args []float64) float64 { return math.Pow(args[1], args[0]) }, }, }
Operators is a map of all supported operator
Functions ¶
This section is empty.
Types ¶
type Associativity ¶
type Associativity uint
Associativity is an artificial type to declare an Associativity constants
const ( // L is an Associativity for the LEFT L Associativity = iota // R is an Associativity for the RIGHT R )
Click to show internal directories.
Click to hide internal directories.