token

package
v0.0.0-...-326851e Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Type TokenType
	Text string
	Pos  int
}

func Lex

func Lex(input string) []Token

Lex the input into token tokens

func (Token) String

func (tok Token) String() string

type TokenType

type TokenType int

TokenType describes the type of token

const (
	// Special Tokens
	Illegal TokenType = iota
	EOF

	// Literal types
	Ident  // main
	Int    // 42
	Float  // 42.3
	String // 42

	// grouping, calls, indexing, fields and func args
	LParen // '('
	RParen // ')'
	LBrack // '['
	RBrack // ']'
	Dot    // '.'
	Comma  // ','

	Add // +
	Sub // -
	Mul // *
	Quo // /
	Rem // %

	Equal    // ==
	NotEqual // !=
	LTE      // <=
	GTE      // >=
	LT       // <
	GT       // >
	Not      // !

)

func (TokenType) IsOperator

func (tt TokenType) IsOperator() bool

func (TokenType) String

func (tt TokenType) String() string

Jump to

Keyboard shortcuts

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