pmmp

package module
v0.0.0-...-412ee12 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

README

Poor Man's MetaPost

Poor Man's MetaPost

This is an experimental fun project, currently without any practical purpose. The first draft used ANTLR as a parser generator, but I intend to migrate it to GoRGO as test case for GoRGO's shortcomings.

I don't strive for fancy graphics, but rather aim at simple figures like this one:

MetaPost Example

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConditionGuiStarted = newCondition("guiStarted")

ConditionGuiStarted is a condition variable for waiting/announcing that a window has been opened and therefore the GUI subsystem has been ramped up.

Wait for this condition with `ConditionGuiStarted.Wait()` and announce it with `ConditionGuiStarted.Broadcast()`.

View Source
var Configuration *koanf.Koanf

Configuration holds global configuration values. We use koanf.

View Source
var SignalContext context.Context

SignalContext is a global context for terminating the application by an interrupt signal.

View Source
var Tracefile io.WriteCloser

Tracefile is the file we write our log output, if not nil.

Functions

func Exit

func Exit(errcode int)

Exit exits the application. It gracefully shuts down all resources.

Types

type Numeric

type Numeric polyn.Polynomial

Numeric is a known or unknown scalar value.

func FromFloat

func FromFloat(f float64) Numeric

FromFloat creates a numeric value from a float.

func (Numeric) AsFloat

func (n Numeric) AsFloat() float64

AsFloat returns a known numeric value as a float, or NaN.

func (Numeric) IsKnown

func (n Numeric) IsKnown() bool

IsKnown is a predicate: is this a known value?

func (Numeric) Minus

func (n Numeric) Minus(m Numeric) Numeric

Minus is n - m.

func (Numeric) Plus

func (n Numeric) Plus(m Numeric) Numeric

Plus is n + m.

func (Numeric) Polynomial

func (n Numeric) Polynomial() polyn.Polynomial

Polynomial is a type-cast to type Polynomial.

func (Numeric) Self

func (n Numeric) Self() ValueBase

Self returns this numeric, wrapped into a ValueBase struct.

func (Numeric) Type

func (n Numeric) Type() ValueType

Type returns NumericType.

type Pair

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

Pair is a known or unknown pair value.

func ConvPair

func ConvPair(p arithm.Pair) Pair

ConvPair converts a pair to a pair value.

func NewPair

func NewPair(a, b Numeric) Pair

NewPair creates a new pair from two scalar values.

func NullPair

func NullPair() Pair

NullPair is an invalid pair.

func (Pair) AsPair

func (p Pair) AsPair() arithm.Pair

AsPair returns a known pair value.

func (Pair) IsKnown

func (p Pair) IsKnown() bool

IsKnown is a predicate: is this a known value?

func (Pair) Minus

func (p Pair) Minus(q Pair) Pair

Minus is p - q.

func (Pair) Self

func (p Pair) Self() ValueBase

Self returns this pair, wrapped into a ValueBase struct.

func (Pair) Type

func (p Pair) Type() ValueType

Type returns PairType

func (Pair) XNumeric

func (p Pair) XNumeric() Numeric

XNumeric returns the scalar xpart.

func (Pair) YNumeric

func (p Pair) YNumeric() Numeric

YNumeric returns the scalar ypart.

type TokenOperator

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

func NewTokenOperator

func NewTokenOperator(t gorgo.Token) TokenOperator

func (TokenOperator) Call

Call delegates the operator call to a symbol in the environment. The symbol is searched for with the literal value of the operator.

func (TokenOperator) Opname

func (top TokenOperator) Opname() string

func (TokenOperator) String

func (top TokenOperator) String() string

func (TokenOperator) Token

func (top TokenOperator) Token() gorgo.Token

type Value

type Value interface {
	Self() ValueBase // helper indirection, see type ValueBase
	IsKnown() bool   // is this a known value ?
	Type() ValueType // type of the value
}

Value is an interface for all values which PMMP can handle.

type ValueBase

type ValueBase struct {
	V Value
}

ValueBase is a helper struct for operations on values.

func (ValueBase) AsNumeric

func (b ValueBase) AsNumeric() Numeric

AsNumeric returns a value a Numeric, or an error and an invalid Numeric.

func (ValueBase) AsPair

func (b ValueBase) AsPair() Pair

AsPair returns a value as a Pair, or an error and a NullPair.

func (ValueBase) IsNumeric

func (b ValueBase) IsNumeric() bool

IsNumeric is a predicate: is it a Numeric?

func (ValueBase) IsPair

func (b ValueBase) IsPair() bool

IsPair is a predicate: is it a Pair?

func (ValueBase) Minus

func (b ValueBase) Minus(w Value) (Value, error)

Minus calculates a - b.

func (ValueBase) String

func (b ValueBase) String() string

func (ValueBase) Type

func (b ValueBase) Type() ValueType

Type returns the value type of a value.

type ValueType

type ValueType int8

ValueType represents the type of a value.

const (
	Undefined ValueType = iota
	NumericType
	PairType
	PathType
	ColorType
	PenType
	VardefType
	SubscriptType
	SuffixType
)

Predefined variable types

func TypeFromString

func TypeFromString(str string) ValueType

TypeFromString gets a type from a string.

func (ValueType) String

func (vt ValueType) String() string

Directories

Path Synopsis
Package corelang implements core commands for DSLs dealing with arithmetic expressions, pairs and paths.
Package corelang implements core commands for DSLs dealing with arithmetic expressions, pairs and paths.
Package pmmp is a poor man's version of MetaFont/MetaPost.
Package pmmp is a poor man's version of MetaFont/MetaPost.
cli
Package cli implements the pmmp command line interface.
Package cli implements the pmmp command line interface.
ui/termui
Package termui provides objects and methods for interactive UI in terminal windows.
Package termui provides objects and methods for interactive UI in terminal windows.
Package variables implements variables for programming languages similar to those in MetaFont and MetaPost.
Package variables implements variables for programming languages similar to those in MetaFont and MetaPost.
varparse
Package varparse implements functions to create variable declarations and references from syntax trees.
Package varparse implements functions to create variable declarations and references from syntax trees.

Jump to

Keyboard shortcuts

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