token

package
v0.0.0-...-2577f20 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

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

	// Identifiers + literals
	IDENT        = "IDENT"  // add, foobar, x, y, ...
	NUMBER       = "NUMBER" // 1343456, 1.23456
	STRING       = "STRING" // "foobar"
	AT           = "@"      // @ At symbol
	NULL         = "NULL"   // # null
	CURRENT_ARGS = "..."    // # ... function args

	// Operators
	TILDE         = "~"
	BANG          = "!"
	ASSIGN        = "="
	PLUS          = "+"
	MINUS         = "-"
	ASTERISK      = "*"
	SLASH         = "/"
	EXPONENT      = "**"
	MODULO        = "%"
	COMP_PLUS     = "+="
	COMP_MINUS    = "-="
	COMP_ASTERISK = "*="
	COMP_SLASH    = "/="
	COMP_EXPONENT = "**="
	COMP_MODULO   = "%="
	RANGE         = ".."

	// Logical operators
	AND = "&&"
	OR  = "||"

	// Bitwise operators
	// It might be worth
	// to rename these
	// to AMPERSAND / CARET / etc
	BIT_AND    = "&"
	BIT_XOR    = "^"
	BIT_RSHIFT = ">>"
	BIT_LSHIFT = "<<"
	PIPE       = "|"

	LT            = "<"
	LT_EQ         = "<="
	GT            = ">"
	GT_EQ         = ">="
	COMBINED_COMP = "<=>"

	EQ     = "=="
	NOT_EQ = "!="

	// Delimiters
	COMMA     = ","
	SEMICOLON = ";"
	COLON     = ":"

	LPAREN   = "("
	RPAREN   = ")"
	LBRACE   = "{"
	RBRACE   = "}"
	LBRACKET = "["
	RBRACKET = "]"
	DOT      = "."
	QUESTION = "?"
	COMMAND  = "$()"

	// Keywords
	FUNCTION = "F"
	TRUE     = "TRUE"
	FALSE    = "FALSE"
	IF       = "IF"
	ELSE     = "ELSE"
	RETURN   = "RETURN"
	WHILE    = "WHILE"
	FOR      = "FOR"
	IN       = "IN"
	NOT_IN   = "NOT_IN"
	BREAK    = "BREAK"
	CONTINUE = "CONTINUE"
	DEFER    = "DEFER"
)

Variables

View Source
var NumberAbbreviations = map[string]float64{
	"k": 1000,
	"m": 1000000,
	"b": 1000000000,
	"t": 1000000000000,
}

NumberAbbreviations is a list of abbreviations that can be used in numbers eg. 1k, 20B

View Source
var NumberSeparator = '_'

NumberSeparator is a separator for numbers eg. 1_000_000

Functions

This section is empty.

Types

type Token

type Token struct {
	Type     TokenType
	Position int // lexer position in file before token
	Literal  string
}

type TokenType

type TokenType string

func LookupIdent

func LookupIdent(ident string) TokenType

Jump to

Keyboard shortcuts

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