token

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package token defines a Token struct.

Index

Constants

View Source
const (
	// TokenTypeOperationAdd represents the addition operation.
	TokenTypeOperationAdd = iota
	// TokenTypeOperationSub represents the subtraction operation.
	TokenTypeOperationSub
	// TokenTypeOperationMul represents the multiplication operation.
	TokenTypeOperationMul
	// TokenTypeOperationDiv represents the division operation.
	TokenTypeOperationDiv
	// TokenTypeOperationPow represents the power operation.
	TokenTypeOperationPow
	// TokenTypeOperationMod represents the modulo operation.
	TokenTypeOperationMod
	// TokenTypeOperationSpread represents the spread operator.
	TokenTypeOperationSpread

	// TokenTypeOperationAddAssign represents the shorthand addition assignment operator.
	TokenTypeOperationAddAssign
	// TokenTypeOperationSubAssign represents the shorthand subtraction assignment operator.
	TokenTypeOperationSubAssign
	// TokenTypeOperationMulAssign represents the shorthand multiplication assignment operator.
	TokenTypeOperationMulAssign
	// TokenTypeOperationDivAssign represents the shorthand division assignment operator.
	TokenTypeOperationDivAssign
	// TokenTypeOperationModAssign represents the shorthand modulo assignment operator.
	TokenTypeOperationModAssign
	// TokenTypeOperationPowAssign represents the shorthand power assignment operator.
	TokenTypeOperationPowAssign

	// TokenTypeNumber represents a number literal.
	TokenTypeNumber
	// TokenTypeString represents a string literal.
	TokenTypeString
	// TokenTypeBool represents a boolean value.
	TokenTypeBool
	// TokenTypeIdentifier represents an identifier.
	TokenTypeIdentifier
	// TokenTypeNull represents the null keyword.
	TokenTypeNull
	// TokenTypeError represents the error keyword.
	TokenTypeError

	// TokenTypeLParen represents a left parenthesis.
	TokenTypeLParen
	// TokenTypeRParen represents a right parenthesis.
	TokenTypeRParen
	// TokenTypeFunction represents a function name.
	TokenTypeFunction
	// TokenTypeDot represents a single dot.
	TokenTypeDot
	// TokenTypeComma represents a comma separator.
	TokenTypeComma
	// TokenTypeNewline represents a newline separator.
	TokenTypeNewline
	// TokenTypeAssign represents the assignment operator.
	TokenTypeAssign
	// TokenTypeEqual represents the equality operator.
	TokenTypeEqual
	// TokenTypeNotEqual represents the inequality operator.
	TokenTypeNotEqual
	// TokenTypeGreaterThan represents the greater than operator.
	TokenTypeGreaterThan
	// TokenTypeGreaterThanOrEqual represents the greater than or equal to operator.
	TokenTypeGreaterThanOrEqual
	// TokenTypeLessThan represents the less than operator.
	TokenTypeLessThan
	// TokenTypeLessThanOrEqual represents the less than or equal to operator.
	TokenTypeLessThanOrEqual
	// TokenTypeLogicalAnd represents the logical and operator.
	TokenTypeLogicalAnd
	// TokenTypeLogicalOr represents the logical or operator.
	TokenTypeLogicalOr
	// TokenTypeNot represents the logical not operator.
	TokenTypeNot
	// TokenTypeIf represents the if keyword.
	TokenTypeIf
	// TokenTypeElse represents the else keyword.
	TokenTypeElse
	// TokenTypeLBrace represents a left brace.
	TokenTypeLBrace
	// TokenTypeRBrace represents a right brace.
	TokenTypeRBrace
	// TokenTypeLBracket represents a left bracket.
	TokenTypeLBracket
	// TokenTypeRBracket represents a right bracket.
	TokenTypeRBracket
	// TokenTypeVar represents the 'var' keyword.
	TokenTypeVar
	// TokenTypeConst represents the 'const' keyword.
	TokenTypeConst
	// TokenTypeFor represents the 'for' keyword.
	TokenTypeFor
	// TokenTypeBreak represents the 'break' keyword.
	TokenTypeBreak
	// TokenTypeContinue represents the 'continue' keyword.
	TokenTypeContinue
	// TokenTypeFrom represents the 'from' keyword.
	TokenTypeFrom
	// TokenTypeTo represents the 'to' keyword.
	TokenTypeTo
	// TokenTypeFunc represents the 'func' keyword.
	TokenTypeFunc
	// TokenTypeReturn represents the 'return' keyword.
	TokenTypeReturn
	// TokenTypeImport represents the 'import' keyword.
	TokenTypeImport
	// TokenTypeAs represents the 'as' keyword.
	TokenTypeAs

	// TokenTypeTypeNumber represents the 'number' type keyword.
	TokenTypeTypeNumber
	// TokenTypeTypeString represents the 'string' type keyword.
	TokenTypeTypeString
	// TokenTypeTypeBool represents the 'bool' type keyword.
	TokenTypeTypeBool
	// TokenTypeTypeArray represents the '[]' array type keyword.
	TokenTypeTypeArray
	// TokenTypeTypeError represents the 'error' type keyword.
	TokenTypeTypeError
	// TokenTypeTypeAny represents the 'any' type keyword.
	TokenTypeTypeAny
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Atom      string
	TokenType Type
	StartPos  int
	EndPos    int
}

Token defines a single expression token.

func NewToken

func NewToken(atom string, tokenType Type, startPos int, endPos int) *Token

NewToken creates a new Token.

func (*Token) IsDataType

func (t *Token) IsDataType() bool

IsDataType checks if the token is a data type.

type Type

type Type int

Type defines an enum of possible token types.

Jump to

Keyboard shortcuts

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