token

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOWEST      = iota
	EQUALS      // ==
	LESSGREATER // >, >=, <, <=
	SUM         // +
	PRODUCT     // *
	PREFIX      // -x or !x
	CALL        // fn(x) { return x + 1; } (1);
)

precedence levels

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

	// identifiers + literals
	IDENT  = "IDENT" // add, foobar, x, y, ...
	INT    = "INT"   // 123456
	STRING = "STRING"

	// operators
	ASSIGN   = "="
	PLUS     = "+"
	MINUS    = "-"
	BANG     = "!"
	ASTERISK = "*"
	SLASH    = "/"
	LT       = "<"
	LTE      = "<="
	GT       = ">"
	GTE      = ">="
	EQ       = "=="
	NOT_EQ   = "!="

	// delimiters
	COMMA     = ","
	SEMICOLON = ";"

	LPAREN = "("
	RPAREN = ")"
	LBRACE = "{"
	RBRACE = "}"

	// keywords
	FUNC   = "FUNC"
	LET    = "LET"
	TRUE   = "TRUE"
	FALSE  = "FALSE"
	IF     = "IF"
	ELSE   = "ELSE"
	RETURN = "RETURN"
)

Variables

This section is empty.

Functions

func GetPrecedence

func GetPrecedence(tokenType TokenType) int

Types

type Token

type Token struct {
	Type    TokenType
	Literal string
}

func New

func New(tokenType TokenType, literal string) Token

type TokenType

type TokenType string

func LookupTokenType

func LookupTokenType(literal string) TokenType

Jump to

Keyboard shortcuts

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