token

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ILLEGAL represents an illegal token
	ILLEGAL = "ILLEGAL"

	// EOF end of file
	EOF = "EOF"

	// COMMENT a line comment, e.g: # this is a comment
	COMMENT = "COMMENT"

	// IDENT an identifier, e.g: add, foobar, x, y, ...
	IDENT = "IDENT"
	// INT an integer, e.g: 1234
	INT = "INT"
	// STRING a string, e.g: "1234"
	STRING = "STRING"

	// BIND the bind operator
	BIND = ":="
	// ASSIGN the assignment operator
	ASSIGN = "="
	// PLUS the addition operator
	PLUS = "+"
	// MINUS the substraction operator
	MINUS = "-"
	// MULTIPLY the multiplication operator
	MULTIPLY = "*"
	// DIVIDE the division operator
	DIVIDE = "/"
	// MODULO the modulo operator
	MODULO = "%"
	// LeftShift
	LeftShift = "<<"
	// RightShift
	RightShift = ">>"

	// Bitwise AND
	BitwiseAND = "&"
	// Bitwise OR
	BitwiseOR = "|"
	// Bitwise XOR
	BitwiseXOR = "^"
	// Bitwise NOT
	BitwiseNOT = "~"

	// NOT the not operator
	NOT = "!"
	// AND the and operator
	AND = "&&"
	// OR the or operator
	OR = "||"

	// LT the less than comparision operator
	LT = "<"
	// LTE  the less than or equal comparision operator
	LTE = "<="

	// GT the greater than comparision operator
	GT = ">"
	// GTE the grather than or equal comparision operator
	GTE = ">="

	// EQ the equality operator
	EQ = "=="
	// NEQ the inequality operator
	NEQ = "!="

	// COMMA a comma
	COMMA = ","
	// SEMICOLON a semi-colon
	SEMICOLON = ";"
	// COLON a comon
	COLON = ":"
	// DOT a dot
	DOT = "."

	// LPAREN a left paranthesis
	LPAREN = "("
	// RPAREN a right parenthesis
	RPAREN = ")"
	// LBRACE a left brace
	LBRACE = "{"
	// RBRACE a right brace
	RBRACE = "}"
	// LBRACKET a left bracket
	LBRACKET = "["
	// RBRACKET a right bracket
	RBRACKET = "]"

	// FUNCTION the `fn` keyword (function)
	FUNCTION = "FUNCTION"
	// TRUE the `true` keyword (true)
	TRUE = "TRUE"
	// FALSE the `false` keyword (false)
	FALSE = "FALSE"
	// NULL the `null` keyword (null)
	NULL = "NULL"
	// IF the `if` keyword (if)
	IF = "IF"
	// ELSE the `else` keyword (else)
	ELSE = "ELSE"
	// RETURN the `return` keyword (return)
	RETURN = "RETURN"
	// WHILE the `while` keyword (while)
	WHILE = "WHILE"
	// IMPORT the `import` keyword (import)
	IMPORT = "IMPORT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Type    Type
	Literal string
}

Token holds a single token type and its literal value

type Type

type Type string

Type represents the type of a token

func LookupIdent

func LookupIdent(ident string) Type

LookupIdent looks up the identifier in ident and returns the appropriate token type depending on whether the identifier is user-defined or a keyword

Jump to

Keyboard shortcuts

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