token

package
v0.0.0-...-70fd0a4 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package token contains types and functions dedicated for lexical tokens generated by lexer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsClosingFlowIndicator

func IsClosingFlowIndicator(tok Token) bool

IsClosingFlowIndicator shows if provided token represents a closing flow object like mapping, sequence or their single element.

func IsNonBreak

func IsNonBreak(tok Token) bool

IsNonBreak shows if provided token is not a line-breaking token. EOF also considered line-breaking.

func IsOpeningFlowIndicator

func IsOpeningFlowIndicator(tok Token) bool

IsOpeningFlowIndicator shows if provided token represents an opening flow object like mapping, sequence or their single element.

func IsWhiteSpace

func IsWhiteSpace(tok Token) bool

IsWhiteSpace shows if provided token is whitespace (meaning space or tab)

func MayPrecedeWord

func MayPrecedeWord(tok Token) bool

MayPrecedeWord shows if given token may precede word (or string).

Types

type Position

type Position struct {
	Row    int
	Column int
}

Position represents token position in source text.

func (Position) String

func (p Position) String() string

type Token

type Token struct {
	Type   Type
	Start  Position
	End    Position
	Origin string
	// contains filtered or unexported fields
}

Token represents a lexical unit produced by lexer.

func (*Token) ConformsCharSet

func (t *Token) ConformsCharSet(cst yamlchar.CharSetType) bool

func (Token) String

func (t Token) String() string

type Type

type Type uint8

Type defines token type.

const (
	UnknownType Type = iota
	// SequenceEntryType represents a block style sequence entry indicator ("-")
	SequenceEntryType
	// MappingKeyType represents an explicit mapping key indicator ("?")
	MappingKeyType
	// MappingValueType represents a mapping value indicator (":")
	MappingValueType
	// CollectEntryType represents a flow style collect entry separator (",")
	CollectEntryType
	// SequenceStartType represents a flow style sequence start indicator ("[")
	SequenceStartType
	// SequenceEndType represents a flow style sequence end indicator ("]")
	SequenceEndType
	// MappingStartType represents a flow style mapping start indicator ("{")
	MappingStartType
	// MappingEndType represents a flow style mapping en indicator ("}")
	MappingEndType
	// CommentType represents a comment indicator ("#")
	CommentType
	// AnchorType represents an anchor indicator ("&")
	AnchorType
	// AliasType represents an alias indicator ("*")
	AliasType
	// TagType represents a tag indicator ("!")
	TagType
	// LiteralType represents a block style literal scalar start indicator ("|")
	LiteralType
	// FoldedType represents a block style folded scalar start indicator (">")
	FoldedType
	// SingleQuoteType represents a single quote ("'")
	SingleQuoteType
	// DoubleQuoteType represents a double quote ('"')
	DoubleQuoteType
	// DirectiveType represents a YAML directive indicator ("%")
	DirectiveType
	// LineBreakType represents a line break character sequence ("\n", "\r" or "\r\n")
	LineBreakType
	// SpaceType represents a single whitespace (" ")
	SpaceType
	// TabType represents a single tab ("\t")
	TabType
	// BOMType represents a byte-order mark
	BOMType
	// EOFType represents an end of file.
	EOFType
	// DocumentEndType represents a document end indicator ("...")
	DocumentEndType
	// DirectiveEndType represents a directive end indicator ("---")
	DirectiveEndType
	// StringType represents any string (like "key")
	StringType
	// StripChompingType represents a strip chomping indicator ("-")
	StripChompingType
	// KeepChompingType represents a keep chomping indicator ("+")
	KeepChompingType
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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