token

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package token defines constants representing the lexical tokens.

Index

Constants

View Source
const (
	LowestPrec  = 0 // non-operators
	HighestPrec = 3
)

A set of constants for precedence-based expression parsing. Non-operators have lowest precedence.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token int
const (
	ILLEGAL Token = iota
	EOF

	STRING // "text"
	INT    // 123
	BOOL   // true
	IDENT  // vars

	ADD  // +
	CALL // }}:\n

	LPAREN    // (
	RPAREN    // )
	LBRACK    // [
	RBRACK    // ]
	LDBRACE   // {{
	RDBRACE   // }}
	COMMA     // ,
	PERIOD    // .
	LARROW    // <-
	LINEBREAK // end of a larrow expression argument
)

func (Token) Precedence

func (t Token) Precedence() int

Precedence returns the operator precedence of the binary operator op. If op is not a binary operator, the result is LowestPrecedence.

func (Token) String

func (t Token) String() string

String returns t as string.

Jump to

Keyboard shortcuts

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