tokens

package
v0.0.0-...-6ef3c0b Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Position

type Position struct {
	File   string
	Line   int
	Column int
}

func (Position) IsZero

func (p Position) IsZero() bool

func (Position) String

func (p Position) String() string

type Token

type Token struct {
	Type  TokenType `json:"type"`
	Value string    `json:"value"`
	Pos   Position  `json:"pos"`
	Err   error     `json:"error"`
}

func (Token) String

func (t Token) String() string

type TokenType

type TokenType int
const (
	EOF        TokenType = iota // End of file
	ILLEGAL                     // Illegal token
	WHITESPACE                  // Whitespace

	IDENT  // Identifier
	ASSIGN // Assignment operator (=)

	LIT_INT    // Integer literal
	LIT_FLOAT  // Float literal
	LIT_DEGREE // Degree literal
	LIT_STRING // String literal

	OP_PLUS    // Infix addition (+)
	OP_MINUS   // Infix subtraction (-)
	OP_STAR    // Infix multiplication (*)
	OP_SLASH   // Infix division (/)
	OP_PERCENT // Infix modulo (%)
	OP_ROOT    // Root operator (√)
	OP_SHL     // Left shift (<<)
	OP_SHR     // Right shift (>>)
	OP_POW     // Exponentiation (**)

	LPAREN // (
	RPAREN // )
)

func (TokenType) String

func (t TokenType) String() string

Jump to

Keyboard shortcuts

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