knuth

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

README

Package knuth

import path "modernc.org/knuth"

Package knuth collects utilities common to all other packages in this repository.

Documentation: godoc.org/modernc.org/knuth

Installation

To install all the included go... commands found in cmd/

$ go install modernc.org/knuth/cmd...@latest

Hacking

Make sure you have these utilities from the Tex-live package(s) installed in your $PATH:

dvitype
gftopk
gftype
mf
mft
pooltype
tangle
tex
tftopl
vftovp
vptovf
weave

These programs are used only to generate test data. Users of packages/commands in this repository do not need them installed.

You will also need to perform

$ go install modernc.org/unconvert2@latest

After modification of any sources, run '$ make' in the repository root. That will regenerate all applicable Go code and testdata, run the tests of all packages in this repository and install all the commands found in ./cmd

Documentation

Overview

Package knuth collects utilities common to all other packages in this repository.

To install all the included go* commands found in cmd/

$ go install modernc.org/knuth/cmd...@latest

Documentation

http://godoc.org/modernc.org/knuth

Hacking

Make sure you have these utilities from the Tex-live package(s) installed in your $PATH:

dvitype
gftopk
gftype
mf
mft
pooltype
tangle
tex
tftopl
vftovp
vptovf
weave

These programs are used only to generate test data. Users of packages/commands in this repository do not need them installed.

You will also need to perform

$ go install modernc.org/unconvert2@latest

After modification of any sources, run '$ make' in the repository root. That will regenerate all applicable Go code and testdata, run tests of all packages in this repository and install all the commands found in ./cmd.

If your local clone of the repository is private, you need to setup the GOPRIVATE environment variable properly for the tests to pass.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ASCII is a RuneValidator accepting runes '\x00' ... '\xff`.
	ASCII asciiValidator
	// Unicode is a RuneValidator accepting all valid unicode code points
	// except those in category Co and Cs.
	Unicode unicodeValidator

	// Assets provides some essential resources:
	//
	//  fonts/cm/mf/* from https://ctan.org/tex-archive/systems/knuth/dist/cm
	//  lib/* from https://ctan.org/tex-archive/systems/knuth/dist/lib
	Assets fs.FS = newCFS(assets)
)

Functions

func Open

func Open(name string, search []string) (f fs.File, err error)

Open attempts to open 'name'. If not successful then it tries to open 'name' using 'search' paths. If still not found then Open may try to find the resource in Assets.

If all letters of the base name of 'name' are upper case then the preceding steps may be extended by additionally looking for the lower case alternative of 'name'.

The caller is responsible to properly .Close any returned non-nil fs.Files to avoid resource exhaustion.

Types

type Changer

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

Changer is a RuneSource implementing patching source using a change file.

func NewChanger

func NewChanger(src, changes RuneSource) (*Changer, error)

NewChanger returns a newly created Changer or an error, if any.

func (*Changer) AddLineColumnInfo

func (c *Changer) AddLineColumnInfo(offset int, filename string, line, column int)

AddLineColumnInfo implements RuneSource, but is a no-op.

func (*Changer) C

func (c *Changer) C() (rune, error)

C implements RuneSource.

func (*Changer) Consume

func (c *Changer) Consume()

Consume implements RuneSource.

func (*Changer) Position

func (c *Changer) Position() (r token.Position)

Position implements RuneSource.

func (*Changer) PositionFor

func (c *Changer) PositionFor(off int) token.Position

PositionFor implements RuneSource.

type Error

type Error string

Error is a specific error implementation.

func (Error) Error

func (e Error) Error() string

type File

type File interface {
	ByteP() *byte
	Close()
	CurPos() int32
	Data4P() *[4]byte
	EOF() bool
	EOLN() bool
	ErStat() int32
	Get()
	Put()
	Read(args ...interface{})
	Readln(args ...interface{})
	Reset(args ...interface{})
	Rewrite(args ...interface{})
	SetPos(int32)
	Write(args ...interface{})
	Writeln(args ...interface{})
}

File represents a Pascal file.

func NewBinaryFile

func NewBinaryFile(r io.Reader, w io.Writer, sizeofT int, open func(string) (io.Reader, error)) File

NewBinaryFile returns a File suitable for Pascal file type 'file of T'.

func NewPoolFile

func NewPoolFile(pool string) File

NewPoolFile returns a read only File with a string pool.

func NewTextFile

func NewTextFile(r io.Reader, w io.Writer, open func(string) (io.Reader, error)) File

NewTextFile returns File suitable for Pascal file type 'text'.

type Line

type Line struct {
	Position token.Position
	Src      string
}

Line represents a source line and its position.

func ReadLine

func ReadLine(s RuneSource) (line *Line, err error)

ReadLine reads from s up to and including the next newline, if any. If s is at EOF, (nil, io.EOF) is returned.

func ReadLine2

func ReadLine2(s RuneSource) (line *Line, err error)

ReadLine2 is like ReadLine but additionally trims trailing space. The final '\n' is preserved, if any.

type RuneSource

type RuneSource interface {
	// AddLineColumnInfo adds alternative file, line, and column number information
	// for a given file offset. The offset must be larger than the offset for the
	// previously added alternative line info and smaller than the file size;
	// otherwise the information is ignored.
	//
	// AddLineColumnInfo is typically used to register alternative position
	// information for line directives such as //line filename:line:column.
	AddLineColumnInfo(offset int, filename string, line, column int)
	// C returns the current rune or and error, if any.
	C() (rune, error)
	// Consume moves to the next rune, if any.
	Consume()
	// Position returns the current position.
	Position() token.Position
	// PositionFor returns the position for zero based offset.
	PositionFor(off int) token.Position
}

RuneSource provides a finite stream of runes.

func NewRuneSource

func NewRuneSource(name string, src []byte, validator RuneValidator) RuneSource

NewRuneSource returns a newly created Source. Positions will be reported as coming from 'name'. 'src' is UTF-8 encoded. Decoded runes will be validated by 'validator'.

type RuneValidator

type RuneValidator interface {
	// Validate returns true if its argument is in the accepted rune set.
	Validate(rune) bool
}

RuneValidator validates runes.

type WriteWidth

type WriteWidth int

WriteWidth is the type of width in `writeln(foo: width);`.

Directories

Path Synopsis
cmd
godvitype
Command godvitype is the DVItype program by D. E. Knuth, transpiled to Go.
Command godvitype is the DVItype program by D. E. Knuth, transpiled to Go.
gogftodvi
Command gftodvi is the GFtoDVI program by Tomas Rokicki, transpiled to Go.
Command gftodvi is the GFtoDVI program by Tomas Rokicki, transpiled to Go.
gogftopk
For more details about the original Pascal program and its usage please see the modernc.org/knuth/gftype package.
For more details about the original Pascal program and its usage please see the modernc.org/knuth/gftype package.
gogftype
Command gogftype is the GFtype program by D. R. Fuchs, transpiled to Go.
Command gogftype is the GFtype program by D. R. Fuchs, transpiled to Go.
gomf
Command gomf is the METAFONT program by D. E. Knuth, transpiled to Go.
Command gomf is the METAFONT program by D. E. Knuth, transpiled to Go.
gomft
Command gomft is the MFT program by D. E. Knuth, transpiled to Go.
Command gomft is the MFT program by D. E. Knuth, transpiled to Go.
gopktype
Command gopktype is the PKtype program by D. E. Knuth, transpiled to Go.
Command gopktype is the PKtype program by D. E. Knuth, transpiled to Go.
gopltotf
Command gopltotf is the PLtoTF program by D. E. Knuth, transpiled to Go.
Command gopltotf is the PLtoTF program by D. E. Knuth, transpiled to Go.
gopooltype
Command gopooltype is the POOLtype program by D. E. Knuth, transpiled to Go.
Command gopooltype is the POOLtype program by D. E. Knuth, transpiled to Go.
gotangle
Command gotangle is the TANGLE program by D. E. Knuth, transpiled to Go.
Command gotangle is the TANGLE program by D. E. Knuth, transpiled to Go.
gotex
Command gotex is the TeX program by D. E. Knuth, transpiled to Go.
Command gotex is the TeX program by D. E. Knuth, transpiled to Go.
gotftopl
Command gotftopl is the TFtoPL program by D. E. Knuth, transpiled to Go.
Command gotftopl is the TFtoPL program by D. E. Knuth, transpiled to Go.
govftovp
Command govftovp is the VFtoVP program by D. E. Knuth, transpiled to Go.
Command govftovp is the VFtoVP program by D. E. Knuth, transpiled to Go.
govptovf
Command govftovp is the VPtoVF program by D. E. Knuth, transpiled to Go.
Command govftovp is the VPtoVF program by D. E. Knuth, transpiled to Go.
goweave
Command goweave is the WEAVE program by D. E. Knuth, transpiled to Go.
Command goweave is the WEAVE program by D. E. Knuth, transpiled to Go.
Package dvi implements encoding and decoding DVI documents.
Package dvi implements encoding and decoding DVI documents.
Package dvitype is the DVItype program by D. E. Knuth, transpiled to Go.
Package dvitype is the DVItype program by D. E. Knuth, transpiled to Go.
font
afm
Package afm implements a decoder for AFM (Adobe Font Metrics) files.
Package afm implements a decoder for AFM (Adobe Font Metrics) files.
fixed
Package fixed provides types to work with fixed-point numbers.
Package fixed provides types to work with fixed-point numbers.
pkf
Package pkf implements a decoder for the Packed (PK) Font file format.
Package pkf implements a decoder for the Packed (PK) Font file format.
tfm
Package tfm implements a decoder for TFM (TeX Font Metrics) files.
Package tfm implements a decoder for TFM (TeX Font Metrics) files.
Package gftodvi is the GFtoDVI program by Tomas Rokicki, transpiled to Go.
Package gftodvi is the GFtoDVI program by Tomas Rokicki, transpiled to Go.
Package gftopk is the GFtype program by Tomas Rokicki, transpiled to Go.
Package gftopk is the GFtype program by Tomas Rokicki, transpiled to Go.
Package gftype is the GFtype program by D. R. Fuchs, transpiled to Go.
Package gftype is the GFtype program by D. R. Fuchs, transpiled to Go.
internal
iobuf
Package iobuf provides buffered I/O tailored for TeX and DVI semantics.
Package iobuf provides buffered I/O tailored for TeX and DVI semantics.
tds
Package tds provides a minimal TeX Directory Structure.
Package tds provides a minimal TeX Directory Structure.
Package kpath provides tools to locate TeX related files.
Package kpath provides tools to locate TeX related files.
mf
Package mf is the METAFONT program by D. E. Knuth, transpiled to Go.
Package mf is the METAFONT program by D. E. Knuth, transpiled to Go.
internal/trap
Package trap is the TRAP variant of the METAFONT program by D. E. Knuth, transpiled to Go.
Package trap is the TRAP variant of the METAFONT program by D. E. Knuth, transpiled to Go.
Package mft is the MFT program by D. E. Knuth, transpiled to Go.
Package mft is the MFT program by D. E. Knuth, transpiled to Go.
Package pktype is the PKtype program by D. E. Knuth, transpiled to Go.
Package pktype is the PKtype program by D. E. Knuth, transpiled to Go.
Package pltotf is the PLtoTF program by D. E. Knuth, transpiled to Go.
Package pltotf is the PLtoTF program by D. E. Knuth, transpiled to Go.
Package pooltype is the POOLtype program by D. E. Knuth, transpiled to Go.
Package pooltype is the POOLtype program by D. E. Knuth, transpiled to Go.
Package tangle is the TANGLE program by D. E. Knuth, transpiled to Go.
Package tangle is the TANGLE program by D. E. Knuth, transpiled to Go.
tex
Package tex is the TEX program by D. E. Knuth, transpiled to Go.
Package tex is the TEX program by D. E. Knuth, transpiled to Go.
internal/trip
Package trip is the TRIP variant of the TeX program by D. E. Knuth, transpiled to Go.
Package trip is the TRIP variant of the TeX program by D. E. Knuth, transpiled to Go.
Package tftopl is the TFtoPL program by D. E. Knuth, transpiled to Go.
Package tftopl is the TFtoPL program by D. E. Knuth, transpiled to Go.
Package vftovp is the VFtoVP program by D. E. Knuth, transpiled to Go.
Package vftovp is the VFtoVP program by D. E. Knuth, transpiled to Go.
Package vptovf is the VPtoVF program by D. E. Knuth, transpiled to Go.
Package vptovf is the VPtoVF program by D. E. Knuth, transpiled to Go.
Package weave is the WEAVE program by D. E. Knuth, transpiled to Go.
Package weave is the WEAVE program by D. E. Knuth, transpiled to Go.
Package web deals with .web files.
Package web deals with .web files.

Jump to

Keyboard shortcuts

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