token

package
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package token defines language keywords and tokens used when lexing source code.

Index

Constants

View Source
const (
	AND             = "&&"
	ASSIGN          = "="
	ASTERISK        = "*"
	ASTERISK_EQUALS = "*="
	BACKTICK        = "`"
	FSTRING         = "'"
	BANG            = "!"
	CASE            = "case"
	COLON           = ":"
	COMMA           = ","
	CONST           = "CONST"
	DECLARE         = ":="
	DEFAULT         = "DEFAULT"
	DEFER           = "DEFER"
	FUNC            = "FUNC"
	ELSE            = "ELSE"
	EOF             = "EOF"
	EQ              = "=="
	FALSE           = "FALSE"
	FLOAT           = "FLOAT"
	FOR             = "FOR"
	GT              = ">"
	GT_GT           = ">>"
	GT_EQUALS       = ">="
	GO              = "GO"
	IDENT           = "IDENT"
	IF              = "IF"
	ILLEGAL         = "ILLEGAL"
	INT             = "INT"
	LBRACE          = "{"
	LBRACKET        = "["
	LPAREN          = "("
	LT              = "<"
	LT_LT           = "<<"
	LT_EQUALS       = "<="
	MINUS           = "-"
	MINUS_EQUALS    = "-="
	MINUS_MINUS     = "--"
	MOD             = "%"
	NOT_EQ          = "!="
	NIL             = "nil"
	PIPE            = "|"
	OR              = "||"
	PERIOD          = "."
	PLUS            = "+"
	PLUS_EQUALS     = "+="
	PLUS_PLUS       = "++"
	POW             = "**"
	QUESTION        = "?"
	RBRACE          = "}"
	RBRACKET        = "]"
	RETURN          = "RETURN"
	RPAREN          = ")"
	SEMICOLON       = ";"
	SEND            = "<-"
	SLASH           = "/"
	SLASH_EQUALS    = "/="
	STRING          = "STRING"
	STRUCT          = "STRUCT"
	SWITCH          = "switch"
	TRUE            = "TRUE"
	NEWLINE         = "EOL"
	IMPORT          = "IMPORT"
	BREAK           = "BREAK"
	CONTINUE        = "CONTINUE"
	VAR             = "VAR"
	IN              = "IN"
	RANGE           = "RANGE"
	FROM            = "FROM"
	AS              = "AS"
)

Token types

Variables

This section is empty.

Functions

This section is empty.

Types

type Position

type Position struct {
	Value     rune
	Char      int
	LineStart int
	Line      int
	Column    int
	File      string
}

Position points to a particular location in an input string.

func (Position) ColumnNumber

func (p Position) ColumnNumber() int

ColumnNumber returns the 1-indexed column number for this position in the input.

func (Position) LineNumber

func (p Position) LineNumber() int

LineNumber returns the 1-indexed line number for this position in the input.

type Token

type Token struct {
	Type          Type
	Literal       string
	StartPosition Position
	EndPosition   Position
}

Token represents one token lexed from the input source code.

type Type

type Type string

Type describes the type of a token as a string.

func LookupIdentifier

func LookupIdentifier(identifier string) Type

LookupIdentifier used to determinate whether identifier is keyword nor not

Jump to

Keyboard shortcuts

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