pattern

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spec

type Spec struct {
	// A sequence of Token structs that indicates the new row layout.
	Tokens []Token `json:"tokens"`

	// CSV separator character.
	Comma string `json:"comma"`
}

Spec is derived from a user-provided string pattern. It contains information about the structure of the output CSV file.

func ParsePattern

func ParsePattern(pattern string) (Spec, error)

ParsePattern converts user input into a Specification struct.

type Token

type Token struct {
	// Indicates the value type stored in a Token struct.
	Type TokenType `json:"type"`

	// Column number. Content of the indicated column will be substituted
	// in place of this token during compilation process.
	Column int `json:"column"`

	// Arbitrary text that will be inserted as is during compilation process.
	Text string `json:"text"`
}

Token is an union-like type. It stores either CSV column number or an arbitrary text to be inserted.

func NewColumnToken

func NewColumnToken(columnNumber int) Token

Creates a new Token containing specified column number.

func NewTextToken

func NewTextToken(text string) Token

Creates a new Token containing specified text.

type TokenType

type TokenType byte

Indicates a type of value stored in a Token struct.

const (
	// Indicates that Token stores Column.
	TT_COLUMN TokenType = 'd'

	// Indicates that Token stores Text.
	TT_TEXT TokenType = 's'
)

Jump to

Keyboard shortcuts

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