token

package
v0.15.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 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 = 7
)

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
	FLOAT  // 1.23
	BOOL   // true
	IDENT  // vars

	ADD  // +
	SUB  // -
	MUL  // *
	QUO  // /
	REM  // %
	CALL // }}:\n

	LAND // &&
	LOR  // ||

	EQL // ==
	NEQ // !=
	LSS // <
	LEQ // <=
	GTR // >
	GEQ // >=
	NOT // !

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

	DEFINED // defined
)

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