token

package
v0.0.0-...-8cdf743 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

View Source
const LowestPrec = 0

LowestPrec represents lowest operator precedence.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token int

Token represents a token.

const (
	Illegal Token = iota
	EOF
	Comment

	Ident
	Int
	Uint
	Float
	Char
	String

	Add          // +
	Sub          // -
	Mul          // *
	Quo          // /
	Rem          // %
	And          // &
	Or           // |
	Xor          // ^
	Shl          // <<
	Shr          // >>
	AndNot       // &^
	AddAssign    // +=
	SubAssign    // -=
	MulAssign    // *=
	QuoAssign    // /=
	RemAssign    // %=
	AndAssign    // &=
	OrAssign     // |=
	XorAssign    // ^=
	ShlAssign    // <<=
	ShrAssign    // >>=
	AndNotAssign // &^=
	LAnd         // &&
	LOr          // ||
	Inc          // ++
	Dec          // --
	Equal        // ==
	Less         // <
	Greater      // >
	Assign       // =
	Not          // !
	NotEqual     // !=
	LessEq       // <=
	GreaterEq    // >=
	Define       // :=
	Ellipsis     // ...
	LParen       // (
	LBrack       // [
	LBrace       // {
	Comma        // ,
	Period       // .
	RParen       // )
	RBrack       // ]
	RBrace       // }
	Semicolon    // ;
	Colon        // :
	Question     // ?

	Break
	Continue
	Else
	For
	Func
	If
	Return
	True
	False
	In
	Undefined
	Import
	Param
	Global
	Var
	Const
	Try
	Catch
	Finally
	Throw
)

List of tokens

func Lookup

func Lookup(ident string) Token

Lookup returns corresponding keyword if ident is a keyword.

func (Token) IsBinaryOperator

func (tok Token) IsBinaryOperator() bool

IsBinaryOperator reports whether token is a binary operator.

func (Token) IsKeyword

func (tok Token) IsKeyword() bool

IsKeyword returns true if the token is a keyword.

func (Token) IsLiteral

func (tok Token) IsLiteral() bool

IsLiteral returns true if the token is a literal.

func (Token) IsOperator

func (tok Token) IsOperator() bool

IsOperator returns true if the token is an operator.

func (Token) Precedence

func (tok Token) Precedence() int

Precedence returns the precedence for the operator token.

func (Token) String

func (tok Token) String() string

Jump to

Keyboard shortcuts

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