token

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (

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

	/*
		Identifiers & Literals
	*/
	IDENT = "IDENT"

	/*
		Delimiters
	*/
	COMMA   = "COMMA"
	LBRACE  = "LBRACE"
	RBRACE  = "RBRACE"
	LPAREN  = "LPAREN"
	RPAREN  = "RPAREN"
	ASSIGN  = "ASSIGN"
	SIGN    = "SIGN"
	HASH    = "HASH"
	DOT     = "DOT"
	NEWLINE = "NEWLINE"

	/*
		Keywords
	*/
	ENTITY     = "ENTITY"
	RELATION   = "RELATION"
	PERMISSION = "PERMISSION"

	/*
		Logical
	*/
	AND = "AND"
	OR  = "OR"
	NOT = "NOT"

	/*
		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