tokens

package
v0.0.0-...-fb0011f Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool leafToken

func (*Bool) GenerateAST

func (tok *Bool) GenerateAST(g *jen.Group)
if {{.}} {
	err = w.WriteByte('1')
} else {
	err = w.WriteByte('0')
}
if err {
	return
}

type CodeToken

type CodeToken interface {
	GenerateAST(g *jen.Group)
}

func MergeConsts

func MergeConsts(tokens []CodeToken) (toRet []CodeToken)

We can only merge consts in containers

type Const

type Const leafToken

func (*Const) GenerateAST

func (c *Const) GenerateAST(g *jen.Group)
if err = w.WriteByte('{{.}}'); err != nil {
	return
}

type Container

type Container interface {
	SetContents([]CodeToken)
	Contents() []CodeToken
}

type Int

type Int leafToken

func (*Int) GenerateAST

func (tok *Int) GenerateAST(g *jen.Group)
if _, err = w.WriteString(strconv.FormatInt(int64({{.}}), 10)); err != nil {
	return
}

type List

type List struct {
	Selector string
	Children []CodeToken
}

func (*List) Contents

func (tok *List) Contents() []CodeToken

func (*List) GenerateAST

func (tok *List) GenerateAST(g *jen.Group)

func (*List) SetContents

func (tok *List) SetContents(children []CodeToken)

type Map

type Map struct {
	Selector string
	Cast     *types.TypeName
	Children []CodeToken
}

func (*Map) Contents

func (tok *Map) Contents() []CodeToken

func (*Map) GenerateAST

func (tok *Map) GenerateAST(g *jen.Group)

mapKeys = nil

for k, _ := range {{.Selector}} {
	mapKeys = append(mapKeys, {{ if (.Import) ne "" }}string(k){{ else }}k{{ end }})
}

sort.Sort(mapKeys) for _, idx := range mapKeys { {{- if (.Import) ne "" }}

k := {{ .Import }}.{{ .Type }}(idx)

{{- else }}

k := idx

{{- end }}

func (*Map) SetContents

func (tok *Map) SetContents(children []CodeToken)

type MapSort

type MapSort struct{}

func (*MapSort) GenerateAST

func (tok *MapSort) GenerateAST(g *jen.Group)

type Native

type Native leafToken

func (*Native) GenerateAST

func (tok *Native) GenerateAST(g *jen.Group)
if err = {{.}}.WriteTo(w); err != nil {
	return
}

type OmitEmpty

type OmitEmpty struct {
	Selector    string
	EmptyMethod string
	Children    []CodeToken
}

func (*OmitEmpty) Contents

func (tok *OmitEmpty) Contents() []CodeToken

func (*OmitEmpty) GenerateAST

func (tok *OmitEmpty) GenerateAST(g *jen.Group)

func (*OmitEmpty) SetContents

func (tok *OmitEmpty) SetContents(children []CodeToken)

type String

type String leafToken

func (*String) GenerateAST

func (tok *String) GenerateAST(g *jen.Group)
if _, err = w.WriteString(strconv.Itoa(len({{.}}))); err != nil {
	return
}
if err = w.WriteByte(':'); err != nil {
	return
}
if _, err = w.WriteString({{.}}); err != nil {
	return
}

Jump to

Keyboard shortcuts

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