token

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (

	/*
		Special Types
	*/
	EOF     = "EOF"
	ILLEGAL = "ILLEGAL"
	NEWLINE = "NEWLINE"

	/*
		Identifiers & Literals
	*/
	IDENT   = "IDENT"
	STRING  = "STRING"
	INTEGER = "INTEGER"
	DOUBLE  = "DOUBLE"
	BOOLEAN = "BOOLEAN"

	/*
		Symbols
	*/
	COMMA     = "COMMA"
	LCB       = "LCB"
	RCB       = "RCB"
	LP        = "LP"
	RP        = "RP"
	ASSIGN    = "ASSIGN"
	SIGN      = "SIGN"
	COLON     = "COLON"
	HASH      = "HASH"
	QM        = "QM"
	DOT       = "DOT"
	LSB       = "LSB"
	RSB       = "RSB"
	EXCL      = "EXCL"
	PLUS      = "PLUS"
	MINUS     = "MINUS"
	TIMES     = "TIMES"
	DIVIDE    = "DIVIDE"
	MOD       = "MOD"
	POW       = "POW"
	GT        = "GT"
	LT        = "LT"
	APOS      = "APOSTROPHE"
	AMPERSAND = "AMPERSAND"

	/*
		Keywords
	*/
	ENTITY     = "ENTITY"
	RELATION   = "RELATION"
	PERMISSION = "PERMISSION"
	ATTRIBUTE  = "ATTRIBUTE"
	RULE       = "RULE"
	AND        = "AND"
	OR         = "OR"
	NOT        = "NOT"
	IN         = "IN"

	/*
		Comments
	*/
	SINGLE_LINE_COMMENT = "SINGLE_LINE_COMMENT"
	MULTI_LINE_COMMENT  = "MULTI_LINE_COMMENT"

	/*
		Whitespace
	*/
	SPACE = "SPACE"
	TAB   = "TAB"
)

Variables

This section is empty.

Functions

func IsIgnores added in v0.3.1

func IsIgnores(typ Type) bool

IsIgnores - checks if the given Type is an ignored token type.

Types

type PositionInfo added in v0.3.8

type PositionInfo struct {
	// The current line position in the input source code.
	LinePosition int
	// The current column position in the input source code.
	ColumnPosition int
}

PositionInfo - represents the current position in the input source code.

type Token

type Token struct {
	// The current position in the input source code.
	PositionInfo PositionInfo
	// The type of the token.
	Type Type
	// The literal value of the token.
	Literal string
}

Token - represents a lexical token in the input source code.

func New

func New(positionInfo PositionInfo, typ Type, ch byte) Token

New - creates a new Token with the given type and literal value.

type Type

type Type string

Type - defines a custom type for tokens.

func LookupKeywords

func LookupKeywords(ident string) Type

LookupKeywords - looks up a keyword in the keywords map and returns its corresponding Type.

func (Type) String

func (t Type) String() string

String - converts the Type to a string.

type WithIgnores added in v0.3.1

type WithIgnores struct {
	Token   Token
	Ignores []Token
}

WithIgnores - is a helper struct that includes a token and a list of ignored tokens.

Jump to

Keyboard shortcuts

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