Standard library / go/token

go/token.Token.Precedence()

Returns binary operator precedence; non-binary tokens return LowestPrec. Expected stdout: '4 5 0\n'.

Formal Syntax & Structure

go syntaxgo
func (op Token) Precedence() int

Return Value

int

Returns binary operator precedence; non-binary tokens return LowestPrec.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/token")
func main() { fmt.Println(token.ADD.Precedence(), token.MUL.Precedence(), token.NOT.Precedence()) }
Go Reference