html

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PX_PER_REM = 0
View Source
var (
	VERBOSITY = 0
)

Functions

func AssertFlag

func AssertFlag(t Token) error

func DictHasFlag

func DictHasFlag(d KeyDict, x interface{}) (bool, error)

func DictOptionString

func DictOptionString(d KeyDict, x interface{}, def string) (string, error)

func IsAnyFunction

func IsAnyFunction(t Token) bool

func IsBool

func IsBool(t Token) bool

func IsColor

func IsColor(t Token) bool

func IsContainer

func IsContainer(t Token) bool

func IsDict

func IsDict(t Token) bool

func IsFalseBool

func IsFalseBool(t_ Token) bool

func IsFlag

func IsFlag(t Token) bool

func IsFloat

func IsFloat(t Token) bool

func IsFunction

func IsFunction(t Token, name string) bool

func IsIndexable

func IsIndexable(t Token) bool

func IsInt

func IsInt(t Token) bool

func IsIntDict

func IsIntDict(t Token) bool

func IsIntList

func IsIntList(t Token) bool

func IsIntOrFloat

func IsIntOrFloat(t Token) bool

always unitless

func IsKeyDict

func IsKeyDict(t Token) bool

func IsList

func IsList(t Token) bool

func IsNull

func IsNull(t Token) bool

func IsParens

func IsParens(t Token) bool

func IsPrimitive

func IsPrimitive(t Token) bool

func IsRawDict

func IsRawDict(t Token) bool

func IsString

func IsString(t Token) bool

func IsStringDict

func IsStringDict(t Token) bool

func IsStringList

func IsStringList(t Token) bool

func IsTrueBool

func IsTrueBool(t_ Token) bool

func MergeContexts

func MergeContexts(ts ...Token) context.Context

Types

type ArgsWithDefaults

type ArgsWithDefaults struct {
	TokenData
	// contains filtered or unexported fields
}

temporary data structure for function and for class

type Bool

type Bool struct {
	TokenData
	// contains filtered or unexported fields
}

func AssertBool

func AssertBool(t Token) (*Bool, error)

func DictBool

func DictBool(d KeyDict, x interface{}) (*Bool, error)

func NewBool

func NewBool(x interface{}, ctx context.Context) (*Bool, error)

func NewValueBool

func NewValueBool(b bool, ctx context.Context) *Bool

func (*Bool) Dump

func (t *Bool) Dump(indent string) string

func (*Bool) Eval

func (t *Bool) Eval(scope Scope) (Token, error)

func (*Bool) IsPrimitive

func (t *Bool) IsPrimitive() bool

func (*Bool) IsSame

func (a *Bool) IsSame(other Token) bool

func (*Bool) Value

func (t *Bool) Value() bool

func (*Bool) Write

func (t *Bool) Write() string

type Color

type Color struct {
	TokenData
	// contains filtered or unexported fields
}

func AssertColor

func AssertColor(t Token) (*Color, error)

func DictColor

func DictColor(d KeyDict, x interface{}) (*Color, error)

func NewColor

func NewColor(r, g, b, a int, ctx context.Context) (*Color, error)

func NewValueColor

func NewValueColor(r, g, b, a int, ctx context.Context) *Color

func (*Color) Dump

func (t *Color) Dump(indent string) string

func (*Color) Eval

func (t *Color) Eval(scope Scope) (Token, error)

func (*Color) FloatValues

func (t *Color) FloatValues() (float64, float64, float64, float64)

func (*Color) IsPrimitive

func (t *Color) IsPrimitive() bool

func (*Color) IsSame

func (a *Color) IsSame(other Token) bool

func (*Color) Values

func (t *Color) Values() (r, g, b, a int)

func (*Color) Write

func (t *Color) Write() string

type Container

type Container interface {
	Token
	Len() int
	Copy(ctx context.Context) (Token, error)
	LoopValues(func(Token) error) error // indices in list or keys dict are ignored
}

func AssertContainer

func AssertContainer(t Token) (Container, error)

type Dict

type Dict interface {
	Container
	IsEmpty() bool
}

func AssertDict

func AssertDict(t Token) (Dict, error)

type DictType

type DictType int
const (
	ANY DictType = iota
	STRING
	INT
)

type DumpableData

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

func NewDumpableData

func NewDumpableData(name string) DumpableData

func (*DumpableData) Dump

func (t *DumpableData) Dump(indent string) string

type Flag

type Flag struct {
	TokenData
}

func NewFlag

func NewFlag(ctx context.Context) *Flag

func (*Flag) Dump

func (t *Flag) Dump(indent string) string

func (*Flag) Eval

func (t *Flag) Eval(scope Scope) (Token, error)

func (*Flag) IsSame

func (a *Flag) IsSame(other Token) bool

func (*Flag) Write

func (t *Flag) Write() string

type Float

type Float struct {
	TokenData
	// contains filtered or unexported fields
}

func AssertAnyIntOrFloat

func AssertAnyIntOrFloat(t Token) (*Float, error)

can contain units, ints converted to non-unit float

func AssertFloat

func AssertFloat(t Token, unit string) (*Float, error)

unit can be wild card

func AssertFractionFloat

func AssertFractionFloat(t Token) (*Float, error)

func AssertIntOrFloat

func AssertIntOrFloat(t Token) (*Float, error)

unitless!

func DictFloat

func DictFloat(d KeyDict, x interface{}) (*Float, error)

func NewValueFloat

func NewValueFloat(value float64, ctx context.Context) *Float

func NewValueUnitFloat

func NewValueUnitFloat(value float64, unit string, ctx context.Context) *Float

func (*Float) Dump

func (t *Float) Dump(indent string) string

func (*Float) Eval

func (t *Float) Eval(scope Scope) (Token, error)

func (*Float) IsSame

func (a *Float) IsSame(other Token) bool

func (*Float) Unit

func (t *Float) Unit() string

func (*Float) Value

func (t *Float) Value() float64

func (*Float) Write

func (t *Float) Write() string

type Function

type Function struct {
	TokenData
	// contains filtered or unexported fields
}

func AssertFunction

func AssertFunction(t Token) (*Function, error)

func NewFunction

func NewFunction(name string, args []Token, ctx context.Context) *Function

func NewValueFunction

func NewValueFunction(name string, args []Token, ctx context.Context) *Function

func (*Function) Args

func (t *Function) Args() []Token

func (*Function) Dump

func (t *Function) Dump(indent string) string

func (*Function) Eval

func (t *Function) Eval(scope Scope) (Token, error)

func (*Function) IsSame

func (a *Function) IsSame(other Token) bool

type Indexable

type Indexable interface {
	Get(scope Scope, x Token, ctx context.Context) (Token, error)
}

implemented specifically by directives.PStyle TODO: should this be implemented by RawDict, List etc? (right Get() for those containers is a little different)

func AssertIndexable

func AssertIndexable(t Token) (Indexable, error)

type Int

type Int struct {
	TokenData
	// contains filtered or unexported fields
}

distinct from Float because it is used for indexing in lists

func AssertInt

func AssertInt(t Token) (*Int, error)

func DictInt

func DictInt(d KeyDict, x interface{}) (*Int, error)

func NewInt

func NewInt(x interface{}, ctx context.Context) (*Int, error)

func NewValueInt

func NewValueInt(v int, ctx context.Context) *Int

func (*Int) Dump

func (t *Int) Dump(indent string) string

func (*Int) Eval

func (t *Int) Eval(scope Scope) (Token, error)

func (*Int) IsSame

func (a *Int) IsSame(other Token) bool

func (*Int) Value

func (t *Int) Value() int

func (*Int) Write

func (t *Int) Write() string

type IntDict

type IntDict struct {
	RawDict
}

IntDict is always the result of an evaluation

func AssertIntDict

func AssertIntDict(t Token) (*IntDict, error)

func DictIntDict

func DictIntDict(d KeyDict, x interface{}) (*IntDict, error)

func NewEmptyIntDict

func NewEmptyIntDict(ctx context.Context) *IntDict

func (*IntDict) Copy

func (t *IntDict) Copy(ctx context.Context) (Token, error)

func (*IntDict) CopyIntDict

func (t *IntDict) CopyIntDict(ctx context.Context) (*IntDict, error)

func (*IntDict) Delete

func (t *IntDict) Delete(x interface{})

func (*IntDict) Eval

func (t *IntDict) Eval(scope Scope) (Token, error)

func (*IntDict) Get

func (t *IntDict) Get(x interface{}) (Token, bool)

func (*IntDict) GetKeyValue

func (t *IntDict) GetKeyValue(x interface{}) (*Int, Token, bool)

func (*IntDict) IsSame

func (a *IntDict) IsSame(other Token) bool

func (*IntDict) Loop

func (t *IntDict) Loop(fn func(key *Int, value Token, last bool) error) error

func (*IntDict) Set

func (t *IntDict) Set(x_ interface{}, value Token)

type KeyDict

type KeyDict interface {
	Dict
	Get(key interface{}) (Token, bool)
	Set(key interface{}, value Token)
	Delete(key interface{})
}

func AssertKeyDict

func AssertKeyDict(t Token) (KeyDict, error)

func DictKeyDict

func DictKeyDict(d KeyDict, x interface{}) (KeyDict, error)

type List

type List struct {
	TokenData
	// contains filtered or unexported fields
}

func AssertList

func AssertList(t Token) (*List, error)

func DictList

func DictList(d KeyDict, x interface{}) (*List, error)

func GolangSliceToList

func GolangSliceToList(x []interface{}, ctx context.Context) (*List, error)

func NewEmptyList

func NewEmptyList(ctx context.Context) *List

func NewNilList

func NewNilList(n int, ctx context.Context) *List

func NewValuesList

func NewValuesList(values interface{}, ctx context.Context) *List

func ToStringList

func ToStringList(t_ Token) (*List, error)

func (*List) Append

func (t *List) Append(v Token)

func (*List) Copy

func (t *List) Copy(ctx context.Context) (Token, error)

func (*List) CopyList

func (t *List) CopyList(ctx context.Context) (*List, error)

func (*List) Dump

func (t *List) Dump(indent string) string

func (*List) Eval

func (t *List) Eval(scope Scope) (Token, error)

func (*List) EvalList

func (t *List) EvalList(scope Scope) (*List, error)

func (*List) Get

func (t *List) Get(x interface{}) (Token, error)

func (*List) GetStrings

func (t *List) GetStrings() ([]string, error)

ignore first null to accomodate enum attrs

func (*List) GetTokens

func (t *List) GetTokens() []Token

func (*List) IsSame

func (a *List) IsSame(other Token) bool

func (*List) Len

func (t *List) Len() int

func (*List) Loop

func (t *List) Loop(fn func(i int, value Token, last bool) error) error

func (*List) LoopValues

func (t *List) LoopValues(fn func(t Token) error) error

loop in which indices are not accessable

type Null

type Null struct {
	TokenData
}

func NewNull

func NewNull(ctx context.Context) *Null

func (*Null) Dump

func (t *Null) Dump(indent string) string

func (*Null) Eval

func (t *Null) Eval(scope Scope) (Token, error)

func (*Null) IsSame

func (a *Null) IsSame(other Token) bool

type Parens

type Parens struct {
	TokenData
	// contains filtered or unexported fields
}

func AssertParens

func AssertParens(t Token) (*Parens, error)

func NewParens

func NewParens(values []Token, alts []Token, ctx context.Context) *Parens

func (*Parens) Alts

func (t *Parens) Alts() []Token

func (*Parens) Dump

func (t *Parens) Dump(indent string) string

func (*Parens) Eval

func (t *Parens) Eval(scope Scope) (Token, error)

func (*Parens) IsSame

func (t *Parens) IsSame(other Token) bool

only relevant for first token

func (*Parens) Len

func (t *Parens) Len() int

func (*Parens) Loop

func (t *Parens) Loop(fn func(i int, value Token, alt Token) error) error

func (*Parens) Values

func (t *Parens) Values() []Token

type Primitive

type Primitive interface {
	Token
	Write() string
}

func AssertPrimitive

func AssertPrimitive(t Token) (Primitive, error)

func DictPrimitive

func DictPrimitive(d KeyDict, x interface{}) (Primitive, error)

type RawDict

type RawDict struct {
	TokenData
	// contains filtered or unexported fields
}

unevaluated dict, when evaluated becomes IntDict or StringDict

func AssertRawDict

func AssertRawDict(t_ Token) (*RawDict, error)

func DictRawDict

func DictRawDict(d KeyDict, x interface{}) (*RawDict, error)

func GolangStringMapToRawDict

func GolangStringMapToRawDict(m map[string]interface{}, ctx context.Context) (*RawDict, error)

func NewEmptyRawDict

func NewEmptyRawDict(ctx context.Context) *RawDict

func NewValuesRawDict

func NewValuesRawDict(keys []Token, values []Token, ctx context.Context) *RawDict

func (*RawDict) Copy

func (t *RawDict) Copy(ctx context.Context) (Token, error)

func (*RawDict) Dump

func (t *RawDict) Dump(indent string) string

func (*RawDict) Eval

func (t *RawDict) Eval(scope Scope) (Token, error)

could be IntDict, so code differs from EvalDict

func (*RawDict) EvalIntDict

func (t *RawDict) EvalIntDict(scope Scope) (*IntDict, error)

func (*RawDict) EvalRawDict

func (t *RawDict) EvalRawDict(scope Scope) (*RawDict, error)

func (*RawDict) EvalRawDictScan

func (t *RawDict) EvalRawDictScan(scope Scope,
	scanFn func(Token, Token) error) (*RawDict, error)

func (*RawDict) EvalStringDict

func (t *RawDict) EvalStringDict(scope Scope) (*StringDict, error)

func (*RawDict) EvalStringDictScan

func (t *RawDict) EvalStringDictScan(scope Scope, scanFn func(*String, Token) error) (*StringDict, error)

func (*RawDict) Get

func (t *RawDict) Get(x interface{}) (Token, bool)

func (*RawDict) GetKeyValue

func (t *RawDict) GetKeyValue(x interface{}) (*String, Token, bool)

func (*RawDict) IsEmpty

func (t *RawDict) IsEmpty() bool

func (*RawDict) IsSame

func (a *RawDict) IsSame(other Token) bool

order is important (which is not the case for KeyDict)

func (*RawDict) Len

func (t *RawDict) Len() int

func (*RawDict) LoopValues

func (t *RawDict) LoopValues(fn func(t Token) error) error

func (*RawDict) Set

func (t *RawDict) Set(key Token, value Token)

func (*RawDict) ToIntDict

func (t *RawDict) ToIntDict() (*IntDict, error)

func (*RawDict) ToStringDict

func (t *RawDict) ToStringDict() (*StringDict, error)

without evaluation

type RawKeyDict

type RawKeyDict struct {
	RawDict
}

type Scope

type Scope interface {
	// caller can differ from scope
	Eval(key string, args []Token, ctx context.Context) (Token, error)
	Permissive() bool
}

type String

type String struct {
	TokenData
	// contains filtered or unexported fields
}

func AssertString

func AssertString(t Token) (*String, error)

func DictString

func DictString(d KeyDict, x interface{}) (*String, error)

func NewDummyContextString

func NewDummyContextString(value string) *String

func NewString

func NewString(value string, ctx context.Context) (*String, error)

func NewValueString

func NewValueString(value string, ctx context.Context) *String

func NewWordString

func NewWordString(value string, ctx context.Context) *String

func (*String) Dump

func (t *String) Dump(indent string) string

func (*String) Eval

func (t *String) Eval(scope Scope) (Token, error)

func (*String) InnerContext

func (t *String) InnerContext() context.Context

func (*String) IsSame

func (a *String) IsSame(other Token) bool

func (*String) Len

func (t *String) Len() int

func (*String) Value

func (t *String) Value() string

func (*String) WasWord

func (t *String) WasWord() bool

func (*String) Write

func (t *String) Write() string

type StringDict

type StringDict struct {
	RawDict
}

func AssertStringDict

func AssertStringDict(t Token) (*StringDict, error)

func DictStringDict

func DictStringDict(d KeyDict, x interface{}) (*StringDict, error)

func GolangStringMapToStringDict

func GolangStringMapToStringDict(m map[string]interface{}, ctx context.Context) (*StringDict, error)

func NewEmptyStringDict

func NewEmptyStringDict(ctx context.Context) *StringDict

func ToStringDict

func ToStringDict(t Token) (*StringDict, error)

func (*StringDict) AssertOnlyValidKeys

func (t *StringDict) AssertOnlyValidKeys(validKeys []string) error

func (*StringDict) Copy

func (t *StringDict) Copy(ctx context.Context) (Token, error)

func (*StringDict) CopyStringDict

func (t *StringDict) CopyStringDict(ctx context.Context) (*StringDict, error)

func (*StringDict) Delete

func (t *StringDict) Delete(x interface{})

try to call this as little as possible

func (*StringDict) Eval

func (t *StringDict) Eval(scope Scope) (Token, error)

func (*StringDict) Get

func (t *StringDict) Get(x interface{}) (Token, bool)

func (*StringDict) GetKeyValue

func (t *StringDict) GetKeyValue(x interface{}) (*String, Token, bool)

func (*StringDict) IsSame

func (a *StringDict) IsSame(other Token) bool

func (*StringDict) Loop

func (t *StringDict) Loop(fn func(key *String, value Token, last bool) error) error

func (*StringDict) Set

func (t *StringDict) Set(x_ interface{}, value Token)

this is a raw append method, duplication isnt checked, last entries are all that matters anyway

func (*StringDict) ToRaw

func (t *StringDict) ToRaw() *RawDict

type Tag

type Tag struct {
	TokenData
	// contains filtered or unexported fields
}

for text tag 'attr' and 'children' are nil, and 'text' is set for non-text tag 'text' isnt set

func NewDirectiveTag

func NewDirectiveTag(name string, attr *RawDict, children []*Tag, ctx context.Context) *Tag

func NewScriptTag

func NewScriptTag(name string, attr *RawDict, text string, textCtx, ctx context.Context) *Tag

func NewTag

func NewTag(name string, attr *RawDict, children []*Tag, ctx context.Context) *Tag

func NewTextTag

func NewTextTag(text string, ctx context.Context) *Tag

func (*Tag) AppendChild

func (t *Tag) AppendChild(c *Tag) error

func (*Tag) AssertEmpty

func (t *Tag) AssertEmpty() error

func (*Tag) AssertNoAttributes

func (t *Tag) AssertNoAttributes() error

func (*Tag) Attributes

func (t *Tag) Attributes(posNames []string) (*StringDict, error)

func (*Tag) Children

func (t *Tag) Children() []*Tag

func (*Tag) Dump

func (t *Tag) Dump(indent string) string

func (*Tag) Eval

func (t *Tag) Eval(scope Scope) (Token, error)

func (*Tag) IsDirective

func (t *Tag) IsDirective() bool

func (*Tag) IsEmpty

func (t *Tag) IsEmpty() bool

func (*Tag) IsSame

func (t *Tag) IsSame(other Token) bool

func (*Tag) IsScript

func (t *Tag) IsScript() bool

func (*Tag) IsText

func (t *Tag) IsText() bool

func (*Tag) Name

func (t *Tag) Name() string

func (*Tag) RawAttributes

func (t *Tag) RawAttributes() *RawDict

func (*Tag) Text

func (t *Tag) Text() string

func (*Tag) TextContext

func (t *Tag) TextContext() context.Context

type Token

type Token interface {
	Dump(indent string) string // to inspect the syntax-tree
	Eval(scope Scope) (Token, error)
	IsSame(other Token) bool
	Context() context.Context
}

func GolangToToken

func GolangToToken(x_ interface{}, ctx context.Context) (Token, error)

type TokenData

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

func (*TokenData) Context

func (t *TokenData) Context() context.Context

Jump to

Keyboard shortcuts

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