token

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Key   string
	Value string
}

func (Annotation) IsDottie

func (a Annotation) IsDottie() bool

func (Annotation) String

func (a Annotation) String() string

type Option

type Option func(*Token)

func WithAnnotation

func WithAnnotation(key, value string) Option

func WithLineNumber

func WithLineNumber(in uint) Option

func WithLiteral

func WithLiteral(in string) Option

func WithLiteralRune

func WithLiteralRune(in rune) Option

func WithOffset

func WithOffset(in int) Option

func WithQuoteType

func WithQuoteType(in Quote) Option

type Quote

type Quote uint
const (
	InvalidQuotes Quote = iota
	DoubleQuotes
	SingleQuotes
	NoQuotes
)

func QuoteFromString added in v0.5.0

func QuoteFromString(in string) Quote

func (Quote) Is

func (qt Quote) Is(in rune) bool

func (Quote) Rune

func (qt Quote) Rune() rune

func (Quote) String

func (qt Quote) String() string

String returns the string corresponding to the token.

func (Quote) Valid added in v0.5.0

func (qt Quote) Valid() bool

type Token

type Token struct {
	Type       Type
	Literal    string
	Offset     int
	Length     int
	LineNumber uint
	Commented  bool
	Quote      Quote
	Annotation *Annotation
}

func New

func New(t Type, options ...Option) Token

type Type

type Type uint

Type is the set of lexical tokens.

const (
	Illegal Type = iota
	EOF

	GroupBanner       // # -- ### (3 or more hashtags)
	Comment           // # -- # <anything>
	CommentAnnotation // # -- # @<name> <value>
	Assign            // = -- KEY=VALUE

	Identifier // Name of the variable
	Value      // Value is an interpreted value of the variable, if it contains special characters, they will be escaped
	RawValue   // RawValue is used as-is. Special characters are not escaped.
	Space      // All whitespace symbols except \n (new line)
	NewLine    // A new line symbol (\n)
)

The list of tokens.

func (Type) String

func (t Type) String() string

String returns the string corresponding to the token.

Jump to

Keyboard shortcuts

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