token

package
v0.0.0-...-21f6697 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 0 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
	Literal string
}

Token represents a valid token of the monkey language

type Type

type Type string

Type is the set of lexical token types of the Monkey programming language.

const (
	ILLEGAL Type = "ILLEGAL"
	EOF     Type = "EOF"

	// Identifiers + literals
	IDENT  Type = "IDENT" // add, foobar, x, y, ...
	INT    Type = "INT"
	STRING Type = "STRING"

	// Operators
	ASSIGN   Type = "="
	PLUS     Type = "+"
	MINUS    Type = "-"
	BANG     Type = "!"
	ASTERISK Type = "*"
	SLASH    Type = "/"
	LT       Type = "<"
	GT       Type = ">"
	EQ       Type = "=="
	NotEQ    Type = "!="

	// Delimiters
	COMMA     Type = ","
	SEMICOLON Type = ";"
	LPAREN    Type = "("
	RPAREN    Type = ")"
	LBRACE    Type = "{"
	RBRACE    Type = "}"
	LBRACKET  Type = "["
	RBRACKET  Type = "]"
	COLON     Type = ":"

	// Keywords
	FUNCTION Type = "FUNCTION"
	LET      Type = "LET"
	IF       Type = "IF"
	ELSE     Type = "ELSE"
	RETURN   Type = "RETURN"
	FALSE    Type = "FALSE"
	TRUE     Type = "TRUE"
	MACRO    Type = "MACRO"
)

func LookupIdent

func LookupIdent(ident string) Type

LookupIdent returns the appropriate keyword token type or IDENT

Jump to

Keyboard shortcuts

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