lex

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathToken     token = "path"
	SlashToken    token = "slash"
	SlotToken     token = "slot"
	QuestionToken token = "question"
	StarToken     token = "star"
	ErrorToken    token = "error"
	EndToken      token = "end"
)

Types of tokens

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

type Lexer interface {
	Next() Token
}

Lexer interface

func New

func New(route string) Lexer

New lexer

type Token

type Token struct {
	Type  token
	Value string
}

Token produced by the lexer

func (Token) String

func (t Token) String() string

type Tokens

type Tokens []Token

Tokens is a list of tokens

func (Tokens) At

func (tokens Tokens) At(i int) string

At returns the individual value at i. For paths, this will be a single character, for slots, this will be the whole slot name.

func (Tokens) Size

func (tokens Tokens) Size() (n int)

Size returns the number individual values. For paths, this will count the number of characters, whereas slots will count as one.

func (Tokens) Split

func (tokens Tokens) Split(at int) []Tokens

Split the token list into two lists of tokens. If we land in the middle of a path token then split that token into two path tokens.

func (Tokens) String

func (tokens Tokens) String() string

String returns a string of tokens for testing

Jump to

Keyboard shortcuts

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