tokeniser

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package tokeniser implements a tokeniser for the format/transformer intermediate language

Index

Constants

View Source
const StringToken = -1

StringToken is the value given to Token instances holding a raw string

Variables

This section is empty.

Functions

func EmitColour

func EmitColour(in color.Color) string

EmitColour is the companion to ParseColour, it converts a color.Color to the intermediate representation for use in larger tooling

func Map

func Map(in string, mapping map[rune]string, fn func(color.Color) string) string

Map maps a string containing intermediate formatting to the strings specified by the mapping arg. Its a helper method to easily implement simple swapping for a Transformer implementation. If colourFn returns false, the sentinel and colour rune are added to the string as they are

func ParseColour

func ParseColour(in string) (color.RGBA, error)

ParseColour Converts a string hex colour to a color.RGBA colour

func Strip

func Strip(in string) string

Strip strips away all intermediate formatting

Types

type Token

type Token struct {
	TokenType      int
	Colour         color.Color
	OriginalString string
}

Token represents a single chunk of intermediate format information

func Tokenise

func Tokenise(in string) []Token

Tokenise turns an input string containing intermediate format codes and returns a slice of Tokens representing the data given. It is intended for use by Transformer implementations that do not want to do the heavy lifting required to parse the intermediate format

Jump to

Keyboard shortcuts

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