token

package
v0.0.0-...-56748ea Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDENTIFIER = "IDENTIFIER"
	INTEGER    = "INTEGER"
	FLOAT      = "FLOAT"
	TRUE       = "TRUE"
	FALSE      = "FALSE"
	STRING     = "STRING"
)

Identifiers and Literals

View Source
const (
	PLUS     = "+"
	MINUS    = "-"
	ASTERISK = "*"
	SLASH    = "/"
	BANG     = "!"
	ASSIGN   = "="
)

Arithmetic Operators

View Source
const (
	EQ     = "=="
	NOT_EQ = "!="
	LT     = "<"
	LT_EQ  = "<="
	GT     = ">"
	GT_EQ  = ">="
)

Comparison Operators

View Source
const (
	AND = "&"
	OR  = "|"
)

Logical Operators

View Source
const (
	L_PAREN   = "("
	R_PAREN   = ")"
	L_BRACE   = "{"
	R_BRACE   = "}"
	L_BRACKET = "["
	R_BRACKET = "]"
	COMMA     = ","
	SEMICOLON = ";"
	COLON     = ":"
	O_COMMENT = "/*"
	C_COMMENT = "*/"
)

Parentheses, Braces and Special characters

View Source
const (
	LET      = "LET"
	IF       = "IF"
	ELSE     = "ELSE"
	FOR      = "FOR"
	WHILE    = "WHILE"
	BREAK    = "break"
	CONTINUE = "continue"
	FUNCTION = "FUNCTION"
	RETURN   = "RETURN"
	IN       = "in"
	TRY      = "TRY"
	CATCH    = "CATCH"
	FINALLY  = "FINALLY"
)

Keywords

View Source
const (
	EOF     = "EOF"
	ILLEGAL = "ILLEGAL"
)

Others

Variables

View Source
var Keywords = map[string]TokenType{
	"let":      LET,
	"true":     TRUE,
	"false":    FALSE,
	"in":       IN,
	"if":       IF,
	"else":     ELSE,
	"for":      FOR,
	"while":    WHILE,
	"break":    BREAK,
	"continue": CONTINUE,
	"fn":       FUNCTION,
	"return":   RETURN,
	"try":      TRY,
	"catch":    CATCH,
	"finally":  FINALLY,
}

Functions

This section is empty.

Types

type Token

type Token struct {
	Type     TokenType
	Literal  string
	Location string
}

type TokenType

type TokenType string

func LookUpKeywords

func LookUpKeywords(word string) TokenType

Helper function to lookup a word in keyword dictionary If word id present, then return its corresponding type Else, return identifier type

Jump to

Keyboard shortcuts

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