flex

package
v0.24.8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package flex reads tell files that are sectioned into alternating blocks of structured and plain text sections. The plain text sections are wrapped with commands and merged into the structured sections. The plain text sections can also "jump out" into structured sections on lines ending with colons.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadPlainText added in v0.24.8

func ReadPlainText(file string, lineOffset int, runes io.RuneReader) ([]story.StoryStatement, error)

Translate plain-text tell into StoryNote(s) and DeclareStatement(s). Each DeclareStatment can contain an Assignment, parsed from an indented sub-document. Because this wants to find those boundaries between comments and statements this doesn't package the whole section into a single declaration for later parsing.

func ReadStory

func ReadStory(in Unreader) (ret []story.StoryStatement, err error)

func ReadStorySource added in v0.24.8

func ReadStorySource(source string, in Unreader) (ret []story.StoryStatement, err error)

Types

type PlainText

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

func (*PlainText) Decoded

func (pt *PlainText) Decoded(tv match.TokenValue) (err error)

collects incoming tokens reconstructs the original text and parses tell sub-documents into assignments ie. for `Instead of jumping: - Say: "Hey, no way."`

func (*PlainText) Finalize

func (pt *PlainText) Finalize() (ret []story.StoryStatement, err error)

func (*PlainText) Read added in v0.24.8

func (pt *PlainText) Read(runes io.RuneReader) (ret []story.StoryStatement, err error)

consumes all text until eof ( and eats the eof error )

type Section

type Section struct {
	Source       string
	StartingLine int // newline count at start of section
	// contains filtered or unexported fields
}

read a structured block until it hits a structured ending.

func MakeSection

func MakeSection(source string, r Unreader) Section

return a reader that ends and restarts on every dashed divider in a flex document. must call "NextSection" to start reading.

func (*Section) NextSection

func (k *Section) NextSection() bool

valid at the start of a document or the after ReadRune() has returned eof; otherwise, panics. returns false at the end of a document.

func (*Section) ReadRune

func (k *Section) ReadRune() (r rune, n int, err error)

read the next rune unless the next rune is a dash. this buffers the dashes, counting them to search for an end of section

type Unreader

type Unreader interface {
	io.RuneReader
	UnreadRune() error
}

Jump to

Keyboard shortcuts

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