token

package
v0.0.0-...-9b02bcc Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 1 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  Type
	Value string
}

Token consists of a type and value; it's the unit output of a lexer.

func LookupWordToken

func LookupWordToken(w string) Token

LookupWordToken returns the token for the given word. It checks against a static list of reserved keywords, and if the input matches, returns the corresponding type. If it doesn't, an WORD token is returned.

type Type

type Type int

Type represents the type of a given token.

const (
	ILLEGAL Type = iota + 128
	EOF

	// Words and digits.
	WORD   // x, yyz, ...
	DIGITS // 42, 1343, ...

	// Operations.
	PLUS     // +
	MINUS    // -
	BANG     // !
	ASTERISK // *
	SLASH    // /
	IMPL     // →
	MOD      // %
	LT       // <
	GT       // >
	EXISTS   // ∈
	NEXISTS  // ∉
	UNION    // ∪
	EQ       // ==
	NEQ      // !=

	// Delimiters.
	DOT      // .
	COLON    // :
	COMMA    // ,
	PIPE     // |
	SUM      // Σ
	LPAREN   // (
	RPAREN   // )
	LBRACKET // [
	RBRACKET // ]

	// Keywords.
	AS   // "as"
	IF   // "if"
	IN   // "in"
	MAX  // "max"
	MIN  // "min"
	TO   // "to"
	BOOL // "true" or "false"
)

func (Type) String

func (i Type) String() string

Jump to

Keyboard shortcuts

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