token

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ILLEGAL = "ILLEGAL"

	EOF     = "EOF"
	COMMENT = "COMMENT"

	IDENT  = "IDENT"
	INT    = "INT"
	FLOAT  = "FLOAT"
	STRING = "STRING"

	ADD = "+"
	SUB = "-"
	MUL = "*"
	QUO = "/"
	REM = "%"

	ADD_ASSIGN = "+="
	SUB_ASSIGN = "-="
	MUL_ASSIGN = "*="
	QUO_ASSIGN = "/="
	REM_ASSIGN = "%="

	EQL = "=="
	LSS = "<"
	GTR = ">"
	NEQ = "!="
	LEQ = "<="
	GEQ = ">="

	ASSIGN = "="

	NOT    = "!"
	NOTSTR = "not"

	LPAREN = "("
	LBRACK = "["
	LBRACE = "{"

	RPAREN    = ")"
	RBRACK    = "]"
	RBRACE    = "}"
	COMMA     = ","
	PERIOD    = "."
	SEMICOLON = ";"
	COLON     = ":"

	LAND = "and"
	LOR  = "or"
	LXOR = "xor"

	CONTAINS    = "contains"
	NOTCONTAINS = "not contains"
	IN          = "in"
	NOTIN       = "not in"
	MATCHES     = "matches"
	NOTMATCHES  = "not matches"
	IS          = "is"
	ISNOT       = "is not"

	IMPORT  = "import"
	PARAM   = "param"
	AS      = "as"
	DEFAULT = "default"
	WHEN    = "when"

	FUNC     = "func"
	RULE     = "rule"
	RETURN   = "return"
	BREAK    = "break"
	CONTINUE = "continue"

	IF     = "if"
	ELSE   = "else"
	ANY    = "any"
	ALL    = "all"
	FOR    = "for"
	FILTER = "filter"
	MAP    = "map"

	CASE = "case"

	EMPTY      = "empty"
	ISEMPTY    = "is empty"
	ISNOTEMPTY = "is not empty"

	DEFINED      = "defined"
	ISDEFINED    = "is defined"
	ISNOTDEFINED = "is not defined"
)
View Source
const NoPos = -1

Variables

This section is empty.

Functions

func SingleWordKeyword

func SingleWordKeyword(sentinelVersion string, tt TokenType) bool

Types

type Locator

type Locator interface {
	PositionOf(int) SourcePosition
	AddLine(int)
	Filename() string
}

func NewContentLocator

func NewContentLocator(filename string, content []byte) Locator

func NewProgressiveLocator

func NewProgressiveLocator() Locator

type Pos

type Pos int

type SourcePosition

type SourcePosition struct {
	Filename string
	Line     int // Line number starting at 0
	Column   int // Column starting at 0
}

func (SourcePosition) IsValid

func (o SourcePosition) IsValid() bool

type Token

type Token struct {
	Type    TokenType
	Literal string
}

type TokenType

type TokenType string

func LookupIdent

func LookupIdent(sentinelVersion, ident string) TokenType

Jump to

Keyboard shortcuts

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