internal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer is a lexer for format strings.

func NewLexer

func NewLexer(prefix rune, allowed_verbs []rune) *Lexer

func (*Lexer) Lex

func (l *Lexer) Lex() error

Lex lexes the stream. Does nothing if the receiver or the stream are nil.

Returns:

  • error: An error if the stream could not be lexed.

NOTES:

  • Remember to call Reset() after the stream has been lexed to avoid previous tokens being left in the stream.

func (*Lexer) Reset

func (l *Lexer) Reset()

Reset resets the lexer to make it reusable.

func (*Lexer) SetInputStream

func (l *Lexer) SetInputStream(stream io.RuneScanner)

SetInputStream sets the stream to lex. Does nothing if the receiver is nil.

Parameters:

  • stream: The stream to lex.

func (Lexer) Tokens

func (l Lexer) Tokens() []*Token

Tokens returns the list of tokens.

Returns:

  • []*Token: The list of tokens.

type Token

type Token struct {
	// IsVerb specifies if the token is a verb.
	IsVerb bool

	// Data is the data of the token.
	Data string
}

Token is a token in a format string.

func NewToken

func NewToken(is_verb bool, data string) *Token

NewToken creates a new token.

Parameters:

  • is_verb: Specifies if the token is a verb.
  • data: The data of the token.

Returns:

  • *Token: The new token. Never returns nil.

Jump to

Keyboard shortcuts

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