token

package
v0.0.0-...-95ae90b Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: BSD-3-Clause 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 {
	Line, Col uint
}

Position represents the line and column number where a token starts in a source file.

type Token

type Token struct {
	Type     TokenType
	Literal  string
	Pos      Position
	Filename string
}

TODO: Add filename to token

type TokenType

type TokenType int
const (
	Illegal TokenType = iota + 1
	EOF
	Comment
	EOL

	// Identifiers & literals
	Identifier
	Integer
	Float
	String

	// Operators
	Assign
	Plus
	Dash
	Bang
	Asterisk
	Slash
	Modulo
	Dot

	PlusAssign
	MinusAssign
	TimesAssign
	SlashAssign
	ModAssign

	LessThan
	GreaterThan
	LessThanEq
	GreaterThanEq
	Equal
	NotEqual

	BitwiseAnd
	BitwiseOr
	BitwiseAndNot

	ShiftLeft
	ShiftRight

	// Delimiters
	Comma
	Semicolon
	Colon
	Carrot

	// Groups and blocks
	LParen
	RParen
	LBrace
	RBrace
	LSquare
	RSquare

	LAnd
	LOr

	Function
	Let
	Const
	True
	False
	If
	Elif
	Else
	Return
	Nil
	For
	While
	Loop
	Continue
	Break
	Try
	Catch
	Throw
	Class
	New
	Pass
	Import
	As
	Delete
	Use
	Native
	Do
	In
	Interface
	Implements
)

All tokens in Nitrogen

func LookupIdent

func LookupIdent(ident string) TokenType

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