token

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2019 License: MIT Imports: 1 Imported by: 0

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
	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
	Error
	Immutable
	If
	Return
	Export
	True
	False
	In
	Undefined
	Import
)

List of tokens

func Lookup

func Lookup(ident string) Token

Lookup returns corresponding keyword if ident is a keyword.

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