raw

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNotSymbol

func AssertNotSymbol(t Token) error

func AssertNotWord

func AssertNotWord(t Token) error

func AssertOperable

func AssertOperable(t Token) error

func ChangeOperator

func ChangeOperator(t Token, newName string)

func ChangeSymbol

func ChangeSymbol(t Token, newValue string, newIsKeyWord bool)

func ContainsSymbol

func ContainsSymbol(ts []Token, s string) bool

func ContainsSymbolThatEndsWith

func ContainsSymbolThatEndsWith(ts []Token, s string) bool

func FindFirstBracesGroup added in v0.4.0

func FindFirstBracesGroup(ts []Token, istart int) int

func FindFirstParensGroup

func FindFirstParensGroup(ts []Token, istart int) int

func FindGroupStop

func FindGroupStop(ts []Token, istart int, tstart Token) ([2]int, bool)

func IsAngledGroup

func IsAngledGroup(t Token) bool

func IsAnyBinaryOperator

func IsAnyBinaryOperator(t Token) bool

func IsAnyGroup

func IsAnyGroup(t Token) bool

func IsAnyNonAngledGroupStart

func IsAnyNonAngledGroupStart(t Token) bool

func IsAnyNonAngledGroupStop

func IsAnyNonAngledGroupStop(t Token) bool

func IsAnyNonWordSymbol

func IsAnyNonWordSymbol(t Token) bool

func IsAnyOperator

func IsAnyOperator(t Token) bool

func IsAnySingularOperator

func IsAnySingularOperator(t Token) bool

func IsAnySymbol

func IsAnySymbol(t Token) bool

func IsAnyTernaryOperator

func IsAnyTernaryOperator(t Token) bool

func IsAnyUnaryOperator

func IsAnyUnaryOperator(t Token) bool

func IsAnyWord

func IsAnyWord(t Token) bool

func IsBinaryOperator

func IsBinaryOperator(t Token, name string) bool

func IsBracesGroup

func IsBracesGroup(t Token) bool

func IsBracketsGroup

func IsBracketsGroup(t Token) bool

func IsDummySymbol

func IsDummySymbol(t Token) bool

func IsGroup

func IsGroup(t Token) bool

func IsIndent added in v0.3.0

func IsIndent(t Token) bool

func IsLiteral

func IsLiteral(t Token) bool

func IsLiteralBool

func IsLiteralBool(t Token) bool

func IsLiteralColor

func IsLiteralColor(t Token) bool

func IsLiteralFloat

func IsLiteralFloat(t Token) bool

func IsLiteralInt

func IsLiteralInt(t Token) bool

func IsLiteralNull

func IsLiteralNull(t Token) bool

func IsLiteralString

func IsLiteralString(t Token) bool

func IsNL added in v0.3.0

func IsNL(t Token) bool

func IsOperable

func IsOperable(t Token) bool

func IsOperator

func IsOperator(t Token, name string) bool

func IsParensGroup

func IsParensGroup(t Token) bool

func IsSingularOperator

func IsSingularOperator(t Token, name string) bool

func IsSpecialNumber

func IsSpecialNumber(t Token) bool

func IsSymbol

func IsSymbol(t Token, value string) bool

func IsSymbolThatEndsWith

func IsSymbolThatEndsWith(t Token, value string) bool

func IsTemplateGroup

func IsTemplateGroup(t Token) bool

func IsTernaryOperator

func IsTernaryOperator(t Token, name string) bool

func IsTmpGroup

func IsTmpGroup(t Token) bool

func IsUnaryOperator

func IsUnaryOperator(t Token, name string) bool

func IsWhitespace added in v0.3.0

func IsWhitespace(t Token) bool

func IsWord

func IsWord(t Token, s string) bool

func MergeContexts

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

func ShortHash

func ShortHash(content string) string

func SplitByFirstSymbol

func SplitByFirstSymbol(ts []Token, s string) ([]Token, []Token)

first part includes the symbol

func SplitBySymbol added in v0.4.0

func SplitBySymbol(ts []Token, s string) [][]Token

Types

type ContentType

type ContentType int
const (
	EMPTY ContentType = iota
	SINGLE
	COMMA
	SEMICOLON
	TMPCONTENT
)

type Group

type Group struct {
	Fields [][]Token
	TokenData
	// contains filtered or unexported fields
}

func AssertAngledGroup

func AssertAngledGroup(t Token) (*Group, error)

func AssertBracesGroup

func AssertBracesGroup(t Token) (*Group, error)

func AssertBracketsGroup

func AssertBracketsGroup(t Token) (*Group, error)

func AssertGroup

func AssertGroup(t Token) (*Group, error)

func AssertParensGroup

func AssertParensGroup(t Token) (*Group, error)

func NewEmptyBracesGroup

func NewEmptyBracesGroup(ctx context.Context) *Group

eg. empty function body for abstract functions

func NewGroupFromTokens

func NewGroupFromTokens(raw []Token) (*Group, error)

func NewTemplateGroup

func NewTemplateGroup(ctx context.Context) *Group

func NewTmpGroup

func NewTmpGroup(raw []Token) *Group

func (*Group) Dump

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

func (*Group) ExpandOnce added in v0.4.0

func (t *Group) ExpandOnce() []Token

func (*Group) FlattenCommas

func (t *Group) FlattenCommas() ([]Token, error)

func (*Group) IsAngled

func (t *Group) IsAngled() bool

func (*Group) IsBraces

func (t *Group) IsBraces() bool

func (*Group) IsBrackets

func (t *Group) IsBrackets() bool

func (*Group) IsComma

func (t *Group) IsComma() bool

func (*Group) IsEmpty

func (t *Group) IsEmpty() bool

func (*Group) IsParens

func (t *Group) IsParens() bool

func (*Group) IsSemiColon

func (t *Group) IsSemiColon() bool

func (*Group) IsSingle

func (t *Group) IsSingle() bool

func (*Group) IsTemplate

func (t *Group) IsTemplate() bool

func (*Group) IsTmp

func (t *Group) IsTmp() bool

type GroupType

type GroupType int
const (
	PARENS GroupType = iota
	BRACKETS
	BRACES
	ANGLED
	TMP
	TEMPLATE
)

type Indent added in v0.3.0

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

func AssertIndent added in v0.3.0

func AssertIndent(t_ Token) (*Indent, error)

func NewIndent added in v0.3.0

func NewIndent(n int, ctx context.Context) *Indent

func (*Indent) Dump added in v0.3.0

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

func (*Indent) N added in v0.3.0

func (t *Indent) N() int

type LiteralBool

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

func AssertLiteralBool

func AssertLiteralBool(t Token) (*LiteralBool, error)

func NewLiteralBool

func NewLiteralBool(x interface{}, ctx context.Context) (*LiteralBool, error)

func NewValueLiteralBool

func NewValueLiteralBool(b bool, ctx context.Context) *LiteralBool

func (*LiteralBool) Dump

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

func (*LiteralBool) Value

func (t *LiteralBool) Value() bool

type LiteralColor

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

func AssertLiteralColor

func AssertLiteralColor(t Token) (*LiteralColor, error)

func NewLiteralColor

func NewLiteralColor(s string, ctx context.Context) (*LiteralColor, error)

func (*LiteralColor) Dump

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

func (*LiteralColor) Values

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

type LiteralFloat

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

func AssertLiteralFloat

func AssertLiteralFloat(t Token, unit string) (*LiteralFloat, error)

unit can be '*' wild card

func NewLiteralFloat

func NewLiteralFloat(s string, ctx context.Context) (*LiteralFloat, error)

func NewValueLiteralFloat

func NewValueLiteralFloat(value float64, ctx context.Context) (*LiteralFloat, error)

func NewValueUnitLiteralFloat

func NewValueUnitLiteralFloat(value float64, unit string, ctx context.Context) (*LiteralFloat, error)

func (*LiteralFloat) Dump

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

func (*LiteralFloat) Unit

func (t *LiteralFloat) Unit() string

func (*LiteralFloat) Value

func (t *LiteralFloat) Value() float64

type LiteralInt

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

distinct from Float because it is used for indexing in lists

func AssertLiteralInt

func AssertLiteralInt(t Token) (*LiteralInt, error)

func NewHexLiteralInt

func NewHexLiteralInt(x string, ctx context.Context) (*LiteralInt, error)

func NewLiteralInt

func NewLiteralInt(x interface{}, ctx context.Context) (*LiteralInt, error)

func NewValueLiteralInt

func NewValueLiteralInt(v int, ctx context.Context) *LiteralInt

func (*LiteralInt) Dump

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

func (*LiteralInt) Value

func (t *LiteralInt) Value() int

type LiteralNull

type LiteralNull struct {
	TokenData
}

func NewLiteralNull

func NewLiteralNull(ctx context.Context) *LiteralNull

func (*LiteralNull) Dump

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

type LiteralString

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

func AssertLiteralString

func AssertLiteralString(t Token) (*LiteralString, error)

func NewLiteralString

func NewLiteralString(value string, ctx context.Context) (*LiteralString, error)

func NewValueLiteralString

func NewValueLiteralString(value string, ctx context.Context) *LiteralString

func NewWordLiteralString

func NewWordLiteralString(value string, ctx context.Context) *LiteralString

used by ui

func (*LiteralString) Dump

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

func (*LiteralString) InnerContext

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

func (*LiteralString) Value

func (t *LiteralString) Value() string

func (*LiteralString) WasWord

func (t *LiteralString) WasWord() bool

type NL added in v0.3.0

type NL struct {
	TokenData
}

func NewNL added in v0.3.0

func NewNL(ctx context.Context) *NL

func (*NL) Dump added in v0.3.0

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

type Operator

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

func AssertAnyBinaryOperator

func AssertAnyBinaryOperator(t Token) (*Operator, error)

func AssertAnyOperator

func AssertAnyOperator(t Token) (*Operator, error)

func AssertAnySingularOperator

func AssertAnySingularOperator(t Token) (*Operator, error)

func AssertAnyTernaryOperator

func AssertAnyTernaryOperator(t Token) (*Operator, error)

func AssertAnyUnaryOperator

func AssertAnyUnaryOperator(t Token) (*Operator, error)

func AssertBinaryOperator

func AssertBinaryOperator(t Token, name string) (*Operator, error)

func AssertSingularOperator

func AssertSingularOperator(t Token, name string) (*Operator, error)

func AssertTernaryOperator

func AssertTernaryOperator(t Token, name string) (*Operator, error)

func AssertUnaryOperator

func AssertUnaryOperator(t Token, name string) (*Operator, error)

func NewBinaryOperator

func NewBinaryOperator(name string, a Token, b Token, ctx context.Context) *Operator

func NewSingularOperator

func NewSingularOperator(name string, ctx context.Context) *Operator

func NewTernaryOperator

func NewTernaryOperator(name string, a Token, b Token, c Token, ctx context.Context) *Operator

func NewUnaryOperator

func NewUnaryOperator(name string, a Token, ctx context.Context) *Operator

func (*Operator) Args

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

func (*Operator) Dump

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

func (*Operator) Name

func (t *Operator) Name() string

type SpecialNumber

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

func AssertSpecialNumber

func AssertSpecialNumber(t Token) (*SpecialNumber, error)

func NewSpecialNumber

func NewSpecialNumber(value string, ctx context.Context) *SpecialNumber

func (*SpecialNumber) Dump

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

func (*SpecialNumber) Value

func (t *SpecialNumber) Value() string

type Symbol

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

this is a temporary token, and shouldnt be available outside the parser package

func AssertAnySymbol

func AssertAnySymbol(t Token) (*Symbol, error)

func AssertSymbol

func AssertSymbol(t Token, value string) (*Symbol, error)

func NewDummySymbol

func NewDummySymbol(value string, ctx context.Context) *Symbol

func NewSymbol

func NewSymbol(value string, isKeyWord bool, ctx context.Context) *Symbol

func (*Symbol) Dump

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

func (*Symbol) IsSame

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

func (*Symbol) Value

func (t *Symbol) Value() string

type Token

type Token interface {
	Dump(indent string) string // to inspect the syntax-tree
	Context() context.Context
}

func Concat

func Concat(args ...interface{}) []Token

func ExpandAngledGroups

func ExpandAngledGroups(ts []Token) []Token

func ExpandParensGroup

func ExpandParensGroup(t Token) []Token

func ExpandTmpGroups

func ExpandTmpGroups(ts []Token) []Token

func RemoveWhitespace added in v0.3.0

func RemoveWhitespace(ts []Token) []Token

func SuggestAngledGroup

func SuggestAngledGroup(ts []Token, istart int, tstart Token) ([]Token, int, bool)

returns inner, and istop, and success

type TokenData

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

func (*TokenData) Context

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

type Word

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

use Symbol for KeyWords!

func AssertWord

func AssertWord(t Token) (*Word, error)

func NewValueWord

func NewValueWord(value string, ctx context.Context) *Word

func NewWord

func NewWord(value string, ctx context.Context) (*Word, error)

func (*Word) Dump

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

func (*Word) Value

func (t *Word) Value() string

Jump to

Keyboard shortcuts

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