token

package
v0.0.0-...-e334538 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const (
	EOF = "EOF"

	Illegal = "illegal"
	Number  = "number"
	String  = "string"
	ID      = "identifier"

	Plus           = "plus"
	Minus          = "minus"
	Star           = "star"
	Exp            = "exponent"
	Slash          = "slash"
	FloorDiv       = "floor-div"
	Mod            = "modulo"
	LeftParen      = "left-paren"
	RightParen     = "right-paren"
	LessThan       = "less-than"
	GreaterThan    = "greater-than"
	LessThanEq     = "less-than-or-equal"
	GreaterThanEq  = "greater-than-or-equal"
	LeftBrace      = "left-brace"
	RightBrace     = "right-brace"
	LeftSquare     = "left-square"
	RightSquare    = "right-square"
	Semi           = "semi"
	Equal          = "equal"
	NotEqual       = "not-equal"
	Or             = "or"
	And            = "and"
	BitOr          = "bitwise-or"
	BitAnd         = "bitwise-and"
	Assign         = "assign"
	Declare        = "declare"
	Comma          = "comma"
	RightArrow     = "right-arrow"
	LambdaArrow    = "lambda-arrow"
	Colon          = "colon"
	Dot            = "dot"
	Bang           = "bang"
	PlusEquals     = "assign-plus"
	MinusEquals    = "assign-minus"
	StarEquals     = "assign-star"
	ExpEquals      = "assign-exponent"
	SlashEquals    = "assign-slash"
	FloorDivEquals = "assign-floor-div"
	ModEquals      = "assign-modulo"
	OrEquals       = "assign-or"
	AndEquals      = "assign-and"
	BitOrEquals    = "assign-bitwise-or"
	BitAndEquals   = "assign-bitwise-and"

	Return = "return"
	True   = "true"
	False  = "false"
	Nil    = "nil"
	If     = "if"
	Then   = "then"
	Else   = "else"
	While  = "while"
	For    = "for"
	Do     = "do"
	End    = "end"
	Next   = "next"
	Break  = "break"
	Match  = "match"
	Model  = "model"
	Where  = "where"
	Import = "import"
	In     = "in"
	Export = "export"
)

All the possible types of tokens.

Variables

View Source
var Keywords = map[string]Type{
	"return": Return,
	"true":   True,
	"false":  False,
	"nil":    Nil,
	"if":     If,
	"then":   Then,
	"else":   Else,
	"while":  While,
	"for":    For,
	"next":   Next,
	"break":  Break,
	"match":  Match,
	"model":  Model,
	"where":  Where,
	"import": Import,
	"do":     Do,
	"end":    End,
	"in":     In,
	"export": Export,
}

Keywords maps all possible keyword literals to their corresponding token types

Functions

func IsKeyword

func IsKeyword(t Type) bool

IsKeyword checks if a token type is a keyword type.

Types

type Position

type Position struct {
	Line, Column int
	Filename     string
}

A Position represents the position of a token in the source code.

func (*Position) String

func (p *Position) String() string

type Token

type Token struct {
	Type       Type
	Literal    string
	Start, End Position
}

A Token is a lexical token representing a part of the source code.

func (*Token) String

func (t *Token) String() string

type Type

type Type string

Type is the type of a token

Jump to

Keyboard shortcuts

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