ops

package
v0.0.0-...-e0b5347 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op uint

Op represents a Lua binary or unary operator. It also encode its precedence.

const (
	OpLt Op = 2 + iota<<8
	OpLeq
	OpGt
	OpGeq
	OpEq
	OpNeq
)

Precedence 2 binary operators

const (
	OpShiftL Op = 6 + iota<<8
	OpShiftR
)

Precedence 6 binary operators (bitwise shifts)

const (
	OpAdd Op = 8 + iota<<8
	OpSub
)

Precendence 8 binary operators (add / subtract)

const (
	OpMul Op = 9 + iota<<8
	OpDiv
	OpFloorDiv
	OpMod
)

Precedence 9 binary operators (multiplication / division / modulo)

const (
	OpNeg Op = 10 + iota<<8
	OpNot
	OpLen
	OpBitNot
	OpId
)

Unary operators have precedence 10

const OpAnd Op = 1 + iota<<8

OpAnd is a logical and (precedence 1)

const OpBitAnd Op = 5 + iota<<8

OpBitAnd is bitwise and (precedence 5)

const OpBitOr Op = 3 + iota<<8

OpBitOr is bitwise or (precedence 3)

const OpBitXor Op = 4 + iota<<8

OpBitXor is bitwise exclusive or (precedence 4)

const OpConcat Op = 7 + iota<<8

OpConcat is the concatenate operator (precedence 7)

const OpOr Op = 0 + iota<<8

OpOr is a logical or (precedence 0)

const OpPow Op = 11 + iota<<8

OpPow (power) is special, precendence 10.

func (Op) Precedence

func (op Op) Precedence() int

Precedence returns the precedence of an operator (higher means binds more tightly).

func (Op) String

func (i Op) String() string

func (Op) Type

func (op Op) Type() Op

Type returns the type of operator (which coincides with the precedence atm).

Jump to

Keyboard shortcuts

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