printer

package
Version: v0.0.0-...-2520efd Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NIL  = "nil"
	NULL = "nullptr"
	IOTA = "iota"
)
View Source
const (
	UP   = +1
	DOWN = -1

	METHOD FieldType = iota
	FIELD
	RECEIVER
	PARAM
	RESULT

	CODE BlockType = iota
	CONST
	VAR
	TYPE
	STRUCT
	INTERFACE

	CHAN_BIDI = "chan"
	CHAN_SEND = "chan<-"
	CHAN_RECV = "<-chan"

	NONE    = ""
	NL      = "\n"
	SEMI    = ";\n"
	COLON   = ":\n"
	COMMA   = ", "
	COMMANL = ",\n"

	GENCONTEXT ContextType = iota
	FUNCONTEXT
	SWITCHCONTEXT
	TYPESWITCHCONTEXT
)

Variables

This section is empty.

Functions

func FormatMake

func FormatMake(args string) string

func GuessType

func GuessType(value string) (string, string)

Guess type and return type and new value

func IfTrue

func IfTrue(val string, cond bool) (ret string)

IfTrue returns the input value if the condition is true, an empty string otherwise

func IsMultiValue

func IsMultiValue(expr string) bool

func IsPublic

func IsPublic(name string) bool

Is this name public

func Nil

func Nil(v string) string

Types

type BlockType

type BlockType int

BlockType describes the type of block (code block, const definition block, etc.)

type CContext

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

CContext is the context for a (function) block

func (*CContext) Selector

func (ctx *CContext) Selector(s string) string

type CPrinter

type CPrinter struct {
	Printer
	// contains filtered or unexported fields
}

C implement the Printer interface for C programs

func (*CPrinter) Chop

func (p *CPrinter) Chop(line string) string

func (*CPrinter) FormatArray

func (p *CPrinter) FormatArray(len, elt string) string

func (*CPrinter) FormatArrayIndex

func (p *CPrinter) FormatArrayIndex(array, index string) string

func (*CPrinter) FormatBinary

func (p *CPrinter) FormatBinary(lhs, op, rhs string) string

func (*CPrinter) FormatCall

func (p *CPrinter) FormatCall(fun, args string, isFuncLit bool) string

func (*CPrinter) FormatChan

func (p *CPrinter) FormatChan(chdir, mtype string) string

func (*CPrinter) FormatCompositeLit

func (p *CPrinter) FormatCompositeLit(typedef, elt string) string

func (*CPrinter) FormatEllipsis

func (p *CPrinter) FormatEllipsis(expr string) string

func (*CPrinter) FormatFuncLit

func (p *CPrinter) FormatFuncLit(ftype, body string) string

func (*CPrinter) FormatFuncType

func (p *CPrinter) FormatFuncType(params, results string, withFunc bool) string

func (*CPrinter) FormatIdent

func (p *CPrinter) FormatIdent(id string) (ret string)

func (*CPrinter) FormatInterface

func (p *CPrinter) FormatInterface(methods string) string

func (*CPrinter) FormatKeyValue

func (p *CPrinter) FormatKeyValue(key, value string) string

func (*CPrinter) FormatLiteral

func (p *CPrinter) FormatLiteral(lit string) string

func (*CPrinter) FormatMap

func (p *CPrinter) FormatMap(key, elt string) string

func (*CPrinter) FormatPair

func (p *CPrinter) FormatPair(v Pair, t FieldType) (ret string)

func (*CPrinter) FormatParen

func (p *CPrinter) FormatParen(expr string) string

func (*CPrinter) FormatSelector

func (p *CPrinter) FormatSelector(pname, sel string, isObject bool) string

func (*CPrinter) FormatSlice

func (p *CPrinter) FormatSlice(slice, low, high, max string) string

func (*CPrinter) FormatStar

func (p *CPrinter) FormatStar(expr string) string

func (*CPrinter) FormatStruct

func (p *CPrinter) FormatStruct(fields string) string

func (*CPrinter) FormatTypeAssert

func (p *CPrinter) FormatTypeAssert(orig, assert string) string

func (*CPrinter) FormatUnary

func (p *CPrinter) FormatUnary(op, operand string) string

func (*CPrinter) IsSameLine

func (p *CPrinter) IsSameLine() bool

func (*CPrinter) PopContext

func (p *CPrinter) PopContext()

func (*CPrinter) Print

func (p *CPrinter) Print(values ...string)

func (*CPrinter) PrintAssignment

func (p *CPrinter) PrintAssignment(lhs, op, rhs string, ltuple, rtuple bool)

func (*CPrinter) PrintBlockEnd

func (p *CPrinter) PrintBlockEnd(b BlockType)

func (*CPrinter) PrintBlockStart

func (p *CPrinter) PrintBlockStart(b BlockType, empty bool)

func (*CPrinter) PrintCase

func (p *CPrinter) PrintCase(expr string)

func (*CPrinter) PrintElse

func (p *CPrinter) PrintElse()

func (*CPrinter) PrintEmpty

func (p *CPrinter) PrintEmpty()

func (*CPrinter) PrintEndCase

func (p *CPrinter) PrintEndCase()

func (*CPrinter) PrintFor

func (p *CPrinter) PrintFor(init, cond, post string)

func (*CPrinter) PrintFunc

func (p *CPrinter) PrintFunc(receiver, name, params, results string)

func (*CPrinter) PrintIf

func (p *CPrinter) PrintIf(init, cond string)

func (*CPrinter) PrintImport

func (p *CPrinter) PrintImport(name, path string)

func (*CPrinter) PrintLevel

func (p *CPrinter) PrintLevel(term string, values ...string)

func (*CPrinter) PrintLevelIn

func (p *CPrinter) PrintLevelIn(term string, values ...string)

func (*CPrinter) PrintPackage

func (p *CPrinter) PrintPackage(name string)

func (*CPrinter) PrintRange

func (p *CPrinter) PrintRange(key, value, expr string)

func (*CPrinter) PrintReturn

func (p *CPrinter) PrintReturn(expr string, tuple bool)

func (*CPrinter) PrintSend

func (p *CPrinter) PrintSend(ch, value string)

func (*CPrinter) PrintStmt

func (p *CPrinter) PrintStmt(stmt, expr string)

func (*CPrinter) PrintSwitch

func (p *CPrinter) PrintSwitch(init, expr string)

func (*CPrinter) PrintType

func (p *CPrinter) PrintType(name, typedef string)

func (*CPrinter) PrintValue

func (p *CPrinter) PrintValue(vtype, typedef, names, values string, ntuple, vtuple bool)

func (*CPrinter) PushContext

func (p *CPrinter) PushContext(c ContextType)

func (*CPrinter) Reset

func (p *CPrinter) Reset()

func (*CPrinter) SameLine

func (p *CPrinter) SameLine()

func (*CPrinter) SetWriter

func (p *CPrinter) SetWriter(w io.Writer)

func (*CPrinter) UpdateLevel

func (p *CPrinter) UpdateLevel(delta int)

type ContextType

type ContextType int

ContextType describes the type of the current context (gen, function, switch)

func (ContextType) String

func (c ContextType) String() string

type DebugPrinter

type DebugPrinter struct {
	P Printer
}

DebugPrinter wraps a Printer with debug messages

func (*DebugPrinter) Chop

func (d *DebugPrinter) Chop(line string) string

func (*DebugPrinter) FormatArray

func (d *DebugPrinter) FormatArray(len, elt string) string

func (*DebugPrinter) FormatArrayIndex

func (d *DebugPrinter) FormatArrayIndex(array, index string) string

func (*DebugPrinter) FormatBinary

func (d *DebugPrinter) FormatBinary(lhs, op, rhs string) string

func (*DebugPrinter) FormatCall

func (d *DebugPrinter) FormatCall(fun, args string, isFuncLit bool) string

func (*DebugPrinter) FormatChan

func (d *DebugPrinter) FormatChan(chdir, mtype string) string

func (*DebugPrinter) FormatCompositeLit

func (d *DebugPrinter) FormatCompositeLit(typedef, elt string) string

func (*DebugPrinter) FormatEllipsis

func (d *DebugPrinter) FormatEllipsis(expr string) string

func (*DebugPrinter) FormatFuncLit

func (d *DebugPrinter) FormatFuncLit(ftype, body string) string

func (*DebugPrinter) FormatFuncType

func (d *DebugPrinter) FormatFuncType(params, results string, withFunc bool) string

func (*DebugPrinter) FormatIdent

func (d *DebugPrinter) FormatIdent(id string) string

func (*DebugPrinter) FormatInterface

func (d *DebugPrinter) FormatInterface(methods string) string

func (*DebugPrinter) FormatKeyValue

func (d *DebugPrinter) FormatKeyValue(key, value string) string

func (*DebugPrinter) FormatLiteral

func (d *DebugPrinter) FormatLiteral(lit string) string

func (*DebugPrinter) FormatMap

func (d *DebugPrinter) FormatMap(key, elt string) string

func (*DebugPrinter) FormatPair

func (d *DebugPrinter) FormatPair(v Pair, t FieldType) string

func (*DebugPrinter) FormatParen

func (d *DebugPrinter) FormatParen(expr string) string

func (*DebugPrinter) FormatSelector

func (d *DebugPrinter) FormatSelector(pname, sel string, isObject bool) string

func (*DebugPrinter) FormatSlice

func (d *DebugPrinter) FormatSlice(slice, low, high, max string) string

func (*DebugPrinter) FormatStar

func (d *DebugPrinter) FormatStar(expr string) string

func (*DebugPrinter) FormatStruct

func (d *DebugPrinter) FormatStruct(fields string) string

func (*DebugPrinter) FormatTypeAssert

func (d *DebugPrinter) FormatTypeAssert(orig, assert string) string

func (*DebugPrinter) FormatUnary

func (d *DebugPrinter) FormatUnary(op, operand string) string

func (*DebugPrinter) IsSameLine

func (d *DebugPrinter) IsSameLine() bool

func (*DebugPrinter) PopContext

func (d *DebugPrinter) PopContext()

func (*DebugPrinter) Print

func (d *DebugPrinter) Print(values ...string)

func (*DebugPrinter) PrintAssignment

func (d *DebugPrinter) PrintAssignment(lhs, op, rhs string, ltuple, rtuple bool)

func (*DebugPrinter) PrintBlockEnd

func (d *DebugPrinter) PrintBlockEnd(b BlockType)

func (*DebugPrinter) PrintBlockStart

func (d *DebugPrinter) PrintBlockStart(b BlockType, empty bool)

func (*DebugPrinter) PrintCase

func (d *DebugPrinter) PrintCase(expr string)

func (*DebugPrinter) PrintElse

func (d *DebugPrinter) PrintElse()

func (*DebugPrinter) PrintEmpty

func (d *DebugPrinter) PrintEmpty()

func (*DebugPrinter) PrintEndCase

func (d *DebugPrinter) PrintEndCase()

func (*DebugPrinter) PrintFor

func (d *DebugPrinter) PrintFor(init, cond, post string)

func (*DebugPrinter) PrintFunc

func (d *DebugPrinter) PrintFunc(receiver, name, params, results string)

func (*DebugPrinter) PrintIf

func (d *DebugPrinter) PrintIf(init, cond string)

func (*DebugPrinter) PrintImport

func (d *DebugPrinter) PrintImport(name, path string)

func (*DebugPrinter) PrintLevel

func (d *DebugPrinter) PrintLevel(term string, values ...string)

func (*DebugPrinter) PrintPackage

func (d *DebugPrinter) PrintPackage(name string)

func (*DebugPrinter) PrintRange

func (d *DebugPrinter) PrintRange(key, value, expr string)

func (*DebugPrinter) PrintReturn

func (d *DebugPrinter) PrintReturn(expr string, tuple bool)

func (*DebugPrinter) PrintSend

func (d *DebugPrinter) PrintSend(ch, value string)

func (*DebugPrinter) PrintStmt

func (d *DebugPrinter) PrintStmt(stmt, expr string)

func (*DebugPrinter) PrintSwitch

func (d *DebugPrinter) PrintSwitch(init, expr string)

func (*DebugPrinter) PrintType

func (d *DebugPrinter) PrintType(name, typedef string)

func (*DebugPrinter) PrintValue

func (d *DebugPrinter) PrintValue(vtype, typedef, names, values string, ntuple, vtuple bool)

func (*DebugPrinter) PushContext

func (d *DebugPrinter) PushContext(c ContextType)

func (*DebugPrinter) Reset

func (d *DebugPrinter) Reset()

func (*DebugPrinter) SameLine

func (d *DebugPrinter) SameLine()

func (*DebugPrinter) SetWriter

func (d *DebugPrinter) SetWriter(w io.Writer)

func (*DebugPrinter) UpdateLevel

func (d *DebugPrinter) UpdateLevel(delta int)

type FieldType

type FieldType int

FieldType describes the type of field in a list (struct field, param field, result field, etc.)

type GoPrinter

type GoPrinter struct {
	Printer
	// contains filtered or unexported fields
}

GoPrinter implement the Printer interface for Go programs

func (*GoPrinter) Chop

func (p *GoPrinter) Chop(line string) string

func (*GoPrinter) FormatArray

func (p *GoPrinter) FormatArray(len, elt string) string

func (*GoPrinter) FormatArrayIndex

func (p *GoPrinter) FormatArrayIndex(array, index string) string

func (*GoPrinter) FormatBinary

func (p *GoPrinter) FormatBinary(lhs, op, rhs string) string

func (*GoPrinter) FormatCall

func (p *GoPrinter) FormatCall(fun, args string, isFuncLit bool) string

func (*GoPrinter) FormatChan

func (p *GoPrinter) FormatChan(chdir, mtype string) string

func (*GoPrinter) FormatCompositeLit

func (p *GoPrinter) FormatCompositeLit(typedef, elt string) string

func (*GoPrinter) FormatEllipsis

func (p *GoPrinter) FormatEllipsis(expr string) string

func (*GoPrinter) FormatFuncLit

func (p *GoPrinter) FormatFuncLit(ftype, body string) string

func (*GoPrinter) FormatFuncType

func (p *GoPrinter) FormatFuncType(params, results string, withFunc bool) string

func (*GoPrinter) FormatIdent

func (p *GoPrinter) FormatIdent(id string) string

func (*GoPrinter) FormatInterface

func (p *GoPrinter) FormatInterface(methods string) string

func (*GoPrinter) FormatKeyValue

func (p *GoPrinter) FormatKeyValue(key, value string) string

func (*GoPrinter) FormatLiteral

func (p *GoPrinter) FormatLiteral(lit string) string

func (*GoPrinter) FormatMap

func (p *GoPrinter) FormatMap(key, elt string) string

func (*GoPrinter) FormatPair

func (p *GoPrinter) FormatPair(v Pair, t FieldType) string

func (*GoPrinter) FormatParen

func (p *GoPrinter) FormatParen(expr string) string

func (*GoPrinter) FormatSelector

func (p *GoPrinter) FormatSelector(pname, sel string, isObject bool) string

func (*GoPrinter) FormatSlice

func (p *GoPrinter) FormatSlice(slice, low, high, max string) string

func (*GoPrinter) FormatStar

func (p *GoPrinter) FormatStar(expr string) string

func (*GoPrinter) FormatStruct

func (p *GoPrinter) FormatStruct(fields string) string

func (*GoPrinter) FormatTypeAssert

func (p *GoPrinter) FormatTypeAssert(orig, assert string) string

func (*GoPrinter) FormatUnary

func (p *GoPrinter) FormatUnary(op, operand string) string

func (*GoPrinter) IsSameLine

func (p *GoPrinter) IsSameLine() bool

func (*GoPrinter) PopContext

func (p *GoPrinter) PopContext()

func (*GoPrinter) Print

func (p *GoPrinter) Print(values ...string)

func (*GoPrinter) PrintAssignment

func (p *GoPrinter) PrintAssignment(lhs, op, rhs string, ltuple, rtuple bool)

func (*GoPrinter) PrintBlockEnd

func (p *GoPrinter) PrintBlockEnd(b BlockType)

func (*GoPrinter) PrintBlockStart

func (p *GoPrinter) PrintBlockStart(b BlockType, empty bool)

func (*GoPrinter) PrintCase

func (p *GoPrinter) PrintCase(expr string)

func (*GoPrinter) PrintElse

func (p *GoPrinter) PrintElse()

func (*GoPrinter) PrintEmpty

func (p *GoPrinter) PrintEmpty()

func (*GoPrinter) PrintEndCase

func (p *GoPrinter) PrintEndCase()

func (*GoPrinter) PrintFor

func (p *GoPrinter) PrintFor(init, cond, post string)

func (*GoPrinter) PrintFunc

func (p *GoPrinter) PrintFunc(receiver, name, params, results string)

func (*GoPrinter) PrintIf

func (p *GoPrinter) PrintIf(init, cond string)

func (*GoPrinter) PrintImport

func (p *GoPrinter) PrintImport(name, path string)

func (*GoPrinter) PrintLevel

func (p *GoPrinter) PrintLevel(term string, values ...string)

func (*GoPrinter) PrintPackage

func (p *GoPrinter) PrintPackage(name string)

func (*GoPrinter) PrintRange

func (p *GoPrinter) PrintRange(key, value, expr string)

func (*GoPrinter) PrintReturn

func (p *GoPrinter) PrintReturn(expr string, tuple bool)

func (*GoPrinter) PrintSend

func (p *GoPrinter) PrintSend(ch, value string)

func (*GoPrinter) PrintStmt

func (p *GoPrinter) PrintStmt(stmt, expr string)

func (*GoPrinter) PrintSwitch

func (p *GoPrinter) PrintSwitch(init, expr string)

func (*GoPrinter) PrintType

func (p *GoPrinter) PrintType(name, typedef string)

func (*GoPrinter) PrintValue

func (p *GoPrinter) PrintValue(vtype, typedef, names, values string, ntuple, vtuple bool)

func (*GoPrinter) PushContext

func (p *GoPrinter) PushContext(c ContextType)

func (*GoPrinter) Reset

func (p *GoPrinter) Reset()

func (*GoPrinter) SameLine

func (p *GoPrinter) SameLine()

func (*GoPrinter) SetWriter

func (p *GoPrinter) SetWriter(w io.Writer)

func (*GoPrinter) UpdateLevel

func (p *GoPrinter) UpdateLevel(delta int)

type JavaPrinter

type JavaPrinter struct {
	Printer
	// contains filtered or unexported fields
}

JavaPrinter implement the Printer interface for Java programs

func (*JavaPrinter) Chop

func (p *JavaPrinter) Chop(line string) string

func (*JavaPrinter) FormatArray

func (p *JavaPrinter) FormatArray(len, elt string) string

func (*JavaPrinter) FormatArrayIndex

func (p *JavaPrinter) FormatArrayIndex(array, index string) string

func (*JavaPrinter) FormatBinary

func (p *JavaPrinter) FormatBinary(lhs, op, rhs string) string

func (*JavaPrinter) FormatCall

func (p *JavaPrinter) FormatCall(fun, args string, isFuncLit bool) string

func (*JavaPrinter) FormatChan

func (p *JavaPrinter) FormatChan(chdir, mtype string) string

func (*JavaPrinter) FormatCompositeLit

func (p *JavaPrinter) FormatCompositeLit(typedef, elt string) string

func (*JavaPrinter) FormatEllipsis

func (p *JavaPrinter) FormatEllipsis(expr string) string

func (*JavaPrinter) FormatFuncLit

func (p *JavaPrinter) FormatFuncLit(ftype, body string) string

func (*JavaPrinter) FormatFuncType

func (p *JavaPrinter) FormatFuncType(params, results string, withFunc bool) string

func (*JavaPrinter) FormatIdent

func (p *JavaPrinter) FormatIdent(id string) string

func (*JavaPrinter) FormatInterface

func (p *JavaPrinter) FormatInterface(methods string) string

func (*JavaPrinter) FormatKeyValue

func (p *JavaPrinter) FormatKeyValue(key, value string) string

func (*JavaPrinter) FormatLiteral

func (p *JavaPrinter) FormatLiteral(lit string) string

func (*JavaPrinter) FormatMap

func (p *JavaPrinter) FormatMap(key, elt string) string

func (*JavaPrinter) FormatPair

func (p *JavaPrinter) FormatPair(v Pair, t FieldType) string

func (*JavaPrinter) FormatParen

func (p *JavaPrinter) FormatParen(expr string) string

func (*JavaPrinter) FormatSelector

func (p *JavaPrinter) FormatSelector(pname, sel string, isObject bool) string

func (*JavaPrinter) FormatSlice

func (p *JavaPrinter) FormatSlice(slice, low, high, max string) string

func (*JavaPrinter) FormatStar

func (p *JavaPrinter) FormatStar(expr string) string

func (*JavaPrinter) FormatStruct

func (p *JavaPrinter) FormatStruct(fields string) string

func (*JavaPrinter) FormatTypeAssert

func (p *JavaPrinter) FormatTypeAssert(orig, assert string) string

func (*JavaPrinter) FormatUnary

func (p *JavaPrinter) FormatUnary(op, operand string) string

func (*JavaPrinter) IsSameLine

func (p *JavaPrinter) IsSameLine() bool

func (*JavaPrinter) PopContext

func (p *JavaPrinter) PopContext()

func (*JavaPrinter) Print

func (p *JavaPrinter) Print(values ...string)

func (*JavaPrinter) PrintAssignment

func (p *JavaPrinter) PrintAssignment(lhs, op, rhs string, ltuple, rtuple bool)

func (*JavaPrinter) PrintBlockEnd

func (p *JavaPrinter) PrintBlockEnd(b BlockType)

func (*JavaPrinter) PrintBlockStart

func (p *JavaPrinter) PrintBlockStart(b BlockType, empty bool)

func (*JavaPrinter) PrintCase

func (p *JavaPrinter) PrintCase(expr string)

func (*JavaPrinter) PrintElse

func (p *JavaPrinter) PrintElse()

func (*JavaPrinter) PrintEmpty

func (p *JavaPrinter) PrintEmpty()

func (*JavaPrinter) PrintEndCase

func (p *JavaPrinter) PrintEndCase()

func (*JavaPrinter) PrintFor

func (p *JavaPrinter) PrintFor(init, cond, post string)

func (*JavaPrinter) PrintFunc

func (p *JavaPrinter) PrintFunc(receiver, name, params, results string)

func (*JavaPrinter) PrintIf

func (p *JavaPrinter) PrintIf(init, cond string)

func (*JavaPrinter) PrintImport

func (p *JavaPrinter) PrintImport(name, path string)

func (*JavaPrinter) PrintLevel

func (p *JavaPrinter) PrintLevel(term string, values ...string)

func (*JavaPrinter) PrintPackage

func (p *JavaPrinter) PrintPackage(name string)

func (*JavaPrinter) PrintRange

func (p *JavaPrinter) PrintRange(key, value, expr string)

func (*JavaPrinter) PrintReturn

func (p *JavaPrinter) PrintReturn(expr string, tuple bool)

func (*JavaPrinter) PrintSend

func (p *JavaPrinter) PrintSend(ch, value string)

func (*JavaPrinter) PrintStmt

func (p *JavaPrinter) PrintStmt(stmt, expr string)

func (*JavaPrinter) PrintSwitch

func (p *JavaPrinter) PrintSwitch(init, expr string)

func (*JavaPrinter) PrintType

func (p *JavaPrinter) PrintType(name, typedef string)

func (*JavaPrinter) PrintValue

func (p *JavaPrinter) PrintValue(vtype, typedef, names, values string, ntuple, vtuple bool)

func (*JavaPrinter) PushContext

func (p *JavaPrinter) PushContext(c ContextType)

func (*JavaPrinter) Reset

func (p *JavaPrinter) Reset()

func (*JavaPrinter) SameLine

func (p *JavaPrinter) SameLine()

func (*JavaPrinter) SetWriter

func (p *JavaPrinter) SetWriter(w io.Writer)

func (*JavaPrinter) UpdateLevel

func (p *JavaPrinter) UpdateLevel(delta int)

type Jcontext

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

Jcontext is the context for a (function) block

func (*Jcontext) Selector

func (ctx *Jcontext) Selector(s string) string

type Pair

type Pair [2]string

Pair contains a pair of values (name/value, name/type, etc.)

func (Pair) Name

func (p Pair) Name() string

Returns the "name" part of a pair

func (Pair) String

func (p Pair) String() string

Default format for a Pair ("name" SP "value")

func (Pair) Value

func (p Pair) Value() string

Returns the "value" part of a pair

type PairList

type PairList []Pair

PairList is a list/slice of pair

type Printer

type Printer interface {
	Reset()

	SetWriter(w io.Writer)
	UpdateLevel(delta int)
	SameLine()
	IsSameLine() bool
	Print(values ...string)
	PrintLevel(term string, values ...string)
	Chop(line string) string

	PushContext(c ContextType)
	PopContext()

	// print start block "{"
	PrintBlockStart(b BlockType, empty bool)

	// print end block "}"
	PrintBlockEnd(b BlockType)

	// print the package name
	PrintPackage(name string)

	// print a single import
	PrintImport(name, path string)

	// print a type definition
	PrintType(name, typedef string)

	// print a const/var definition
	PrintValue(vtype, typedef, names, values string, ntuple, vtuple bool)

	// print a 'special' statement (goto, break, continue, ...)
	PrintStmt(stmt, expr string)

	// print return statemement
	PrintReturn(expr string, tuple bool)

	// print a function definition
	PrintFunc(receiver, name, params, results string)

	// print a "for" opening statement
	PrintFor(init, cond, post string)

	// print a "range" opening statement
	PrintRange(key, value, expr string)

	// print a "switch" opening statement
	PrintSwitch(init, expr string)

	// print a "case" opening statement
	PrintCase(expr string)

	// print a "case" closing statement (break, if needed)
	PrintEndCase()

	// print an "if" opening statement
	PrintIf(init, cond string)

	// print the "else" statement
	PrintElse()

	// print an empty statement
	PrintEmpty()

	// print an assignment statement
	PrintAssignment(lhs, op, rhs string, ltuple, rtuple bool)

	// print a channel send statement
	PrintSend(ch, value string)

	FormatIdent(id string) string

	FormatLiteral(lit string) string

	FormatCompositeLit(typedef, elt string) string

	FormatStar(expr string) string

	FormatEllipsis(expr string) string

	FormatParen(expr string) string

	FormatUnary(op, operand string) string

	FormatBinary(lhs, op, rhs string) string

	FormatPair(p Pair, t FieldType) string

	FormatArray(len, elt string) string

	FormatArrayIndex(array, index string) string

	FormatSlice(slice, low, high, max string) string

	FormatMap(key, elt string) string

	FormatKeyValue(key, value string) string

	FormatStruct(fields string) string

	FormatInterface(methods string) string

	FormatChan(chdir, mtype string) string

	FormatCall(fun, args string, isFuncLit bool) string

	FormatFuncType(params, results string, withFunc bool) string

	FormatFuncLit(ftype, body string) string

	FormatSelector(pname, sel string, isObject bool) string

	FormatTypeAssert(orig, assert string) string
}

Printer is the interface to be implemented to print a program

type PythonPrinter

type PythonPrinter struct {
	Printer
	// contains filtered or unexported fields
}

PythonPrinter implement the Printer interface for Python programs

func (*PythonPrinter) Chop

func (p *PythonPrinter) Chop(line string) string

func (*PythonPrinter) FormatArray

func (p *PythonPrinter) FormatArray(len, elt string) string

func (*PythonPrinter) FormatArrayIndex

func (p *PythonPrinter) FormatArrayIndex(array, index string) string

func (*PythonPrinter) FormatBinary

func (p *PythonPrinter) FormatBinary(lhs, op, rhs string) string

func (*PythonPrinter) FormatCall

func (p *PythonPrinter) FormatCall(fun, args string, isFuncLit bool) string

func (*PythonPrinter) FormatChan

func (p *PythonPrinter) FormatChan(chdir, mtype string) string

func (*PythonPrinter) FormatCompositeLit

func (p *PythonPrinter) FormatCompositeLit(typedef, elt string) string

func (*PythonPrinter) FormatEllipsis

func (p *PythonPrinter) FormatEllipsis(expr string) string

func (*PythonPrinter) FormatFuncLit

func (p *PythonPrinter) FormatFuncLit(ftype, body string) string

func (*PythonPrinter) FormatFuncType

func (p *PythonPrinter) FormatFuncType(params, results string, withFunc bool) string

func (*PythonPrinter) FormatIdent

func (p *PythonPrinter) FormatIdent(id string) string

func (*PythonPrinter) FormatInterface

func (p *PythonPrinter) FormatInterface(methods string) string

func (*PythonPrinter) FormatKeyValue

func (p *PythonPrinter) FormatKeyValue(key, value string) string

func (*PythonPrinter) FormatLiteral

func (p *PythonPrinter) FormatLiteral(lit string) string

func (*PythonPrinter) FormatMap

func (p *PythonPrinter) FormatMap(key, elt string) string

func (*PythonPrinter) FormatPair

func (p *PythonPrinter) FormatPair(v Pair, t FieldType) string

func (*PythonPrinter) FormatParen

func (p *PythonPrinter) FormatParen(expr string) string

func (*PythonPrinter) FormatSelector

func (p *PythonPrinter) FormatSelector(pname, sel string, isObject bool) string

func (*PythonPrinter) FormatSlice

func (p *PythonPrinter) FormatSlice(slice, low, high, max string) string

func (*PythonPrinter) FormatStar

func (p *PythonPrinter) FormatStar(expr string) string

func (*PythonPrinter) FormatStruct

func (p *PythonPrinter) FormatStruct(fields string) string

func (*PythonPrinter) FormatTypeAssert

func (p *PythonPrinter) FormatTypeAssert(orig, assert string) string

func (*PythonPrinter) FormatUnary

func (p *PythonPrinter) FormatUnary(op, operand string) string

func (*PythonPrinter) IsSameLine

func (p *PythonPrinter) IsSameLine() bool

func (*PythonPrinter) PopContext

func (p *PythonPrinter) PopContext()

func (*PythonPrinter) Print

func (p *PythonPrinter) Print(values ...string)

func (*PythonPrinter) PrintAssignment

func (p *PythonPrinter) PrintAssignment(lhs, op, rhs string, ltuple, rtuple bool)

func (*PythonPrinter) PrintBlockEnd

func (p *PythonPrinter) PrintBlockEnd(b BlockType)

func (*PythonPrinter) PrintBlockStart

func (p *PythonPrinter) PrintBlockStart(b BlockType, empty bool)

func (*PythonPrinter) PrintCase

func (p *PythonPrinter) PrintCase(expr string)

func (*PythonPrinter) PrintElse

func (p *PythonPrinter) PrintElse()

func (*PythonPrinter) PrintEmpty

func (p *PythonPrinter) PrintEmpty()

func (*PythonPrinter) PrintEndCase

func (p *PythonPrinter) PrintEndCase()

func (*PythonPrinter) PrintFor

func (p *PythonPrinter) PrintFor(init, cond, post string)

func (*PythonPrinter) PrintFunc

func (p *PythonPrinter) PrintFunc(receiver, name, params, results string)

func (*PythonPrinter) PrintIf

func (p *PythonPrinter) PrintIf(init, cond string)

func (*PythonPrinter) PrintImport

func (p *PythonPrinter) PrintImport(name, path string)

func (*PythonPrinter) PrintLevel

func (p *PythonPrinter) PrintLevel(term string, values ...string)

func (*PythonPrinter) PrintPackage

func (p *PythonPrinter) PrintPackage(name string)

func (*PythonPrinter) PrintRange

func (p *PythonPrinter) PrintRange(key, value, expr string)

func (*PythonPrinter) PrintReturn

func (p *PythonPrinter) PrintReturn(expr string, tuple bool)

func (*PythonPrinter) PrintSend

func (p *PythonPrinter) PrintSend(ch, value string)

func (*PythonPrinter) PrintStmt

func (p *PythonPrinter) PrintStmt(stmt, expr string)

func (*PythonPrinter) PrintSwitch

func (p *PythonPrinter) PrintSwitch(init, expr string)

func (*PythonPrinter) PrintType

func (p *PythonPrinter) PrintType(name, typedef string)

func (*PythonPrinter) PrintValue

func (p *PythonPrinter) PrintValue(vtype, typedef, names, values string, ntuple, vtuple bool)

func (*PythonPrinter) PushContext

func (p *PythonPrinter) PushContext(c ContextType)

func (*PythonPrinter) Reset

func (p *PythonPrinter) Reset()

func (*PythonPrinter) SameLine

func (p *PythonPrinter) SameLine()

func (*PythonPrinter) SetWriter

func (p *PythonPrinter) SetWriter(w io.Writer)

func (*PythonPrinter) UpdateLevel

func (p *PythonPrinter) UpdateLevel(delta int)

type RustPrinter

type RustPrinter struct {
	Printer
	// contains filtered or unexported fields
}

RustPrinter implement the Printer interface for Rust programs

func (*RustPrinter) Chop

func (p *RustPrinter) Chop(line string) string

func (*RustPrinter) FormatArray

func (p *RustPrinter) FormatArray(len, elt string) string

func (*RustPrinter) FormatArrayIndex

func (p *RustPrinter) FormatArrayIndex(array, index string) string

func (*RustPrinter) FormatBinary

func (p *RustPrinter) FormatBinary(lhs, op, rhs string) string

func (*RustPrinter) FormatCall

func (p *RustPrinter) FormatCall(fun, args string, isFuncLit bool) string

func (*RustPrinter) FormatChan

func (p *RustPrinter) FormatChan(chdir, mtype string) string

func (*RustPrinter) FormatCompositeLit

func (p *RustPrinter) FormatCompositeLit(typedef, elt string) string

func (*RustPrinter) FormatEllipsis

func (p *RustPrinter) FormatEllipsis(expr string) string

func (*RustPrinter) FormatFuncLit

func (p *RustPrinter) FormatFuncLit(ftype, body string) string

func (*RustPrinter) FormatFuncType

func (p *RustPrinter) FormatFuncType(params, results string, withFunc bool) string

func (*RustPrinter) FormatIdent

func (p *RustPrinter) FormatIdent(id string) string

func (*RustPrinter) FormatInterface

func (p *RustPrinter) FormatInterface(methods string) string

func (*RustPrinter) FormatKeyValue

func (p *RustPrinter) FormatKeyValue(key, value string) string

func (*RustPrinter) FormatLiteral

func (p *RustPrinter) FormatLiteral(lit string) string

func (*RustPrinter) FormatMap

func (p *RustPrinter) FormatMap(key, elt string) string

func (*RustPrinter) FormatPair

func (p *RustPrinter) FormatPair(v Pair, t FieldType) string

func (*RustPrinter) FormatParen

func (p *RustPrinter) FormatParen(expr string) string

func (*RustPrinter) FormatSelector

func (p *RustPrinter) FormatSelector(pname, sel string, isObject bool) string

func (*RustPrinter) FormatSlice

func (p *RustPrinter) FormatSlice(slice, low, high, max string) string

func (*RustPrinter) FormatStar

func (p *RustPrinter) FormatStar(expr string) string

func (*RustPrinter) FormatStruct

func (p *RustPrinter) FormatStruct(fields string) string

func (*RustPrinter) FormatTypeAssert

func (p *RustPrinter) FormatTypeAssert(orig, assert string) string

func (*RustPrinter) FormatUnary

func (p *RustPrinter) FormatUnary(op, operand string) string

func (*RustPrinter) IsSameLine

func (p *RustPrinter) IsSameLine() bool

func (*RustPrinter) PopContext

func (p *RustPrinter) PopContext()

func (*RustPrinter) Print

func (p *RustPrinter) Print(values ...string)

func (*RustPrinter) PrintAssignment

func (p *RustPrinter) PrintAssignment(lhs, op, rhs string, ltuple, rtuple bool)

func (*RustPrinter) PrintBlockEnd

func (p *RustPrinter) PrintBlockEnd(b BlockType)

func (*RustPrinter) PrintBlockStart

func (p *RustPrinter) PrintBlockStart(b BlockType, empty bool)

func (*RustPrinter) PrintCase

func (p *RustPrinter) PrintCase(expr string)

func (*RustPrinter) PrintElse

func (p *RustPrinter) PrintElse()

func (*RustPrinter) PrintEmpty

func (p *RustPrinter) PrintEmpty()

func (*RustPrinter) PrintEndCase

func (p *RustPrinter) PrintEndCase()

func (*RustPrinter) PrintFor

func (p *RustPrinter) PrintFor(init, cond, post string)

func (*RustPrinter) PrintFunc

func (p *RustPrinter) PrintFunc(receiver, name, params, results string)

func (*RustPrinter) PrintIf

func (p *RustPrinter) PrintIf(init, cond string)

func (*RustPrinter) PrintImport

func (p *RustPrinter) PrintImport(name, path string)

func (*RustPrinter) PrintLevel

func (p *RustPrinter) PrintLevel(term string, values ...string)

func (*RustPrinter) PrintPackage

func (p *RustPrinter) PrintPackage(name string)

func (*RustPrinter) PrintRange

func (p *RustPrinter) PrintRange(key, value, expr string)

func (*RustPrinter) PrintReturn

func (p *RustPrinter) PrintReturn(expr string, tuple bool)

func (*RustPrinter) PrintSend

func (p *RustPrinter) PrintSend(ch, value string)

func (*RustPrinter) PrintStmt

func (p *RustPrinter) PrintStmt(stmt, expr string)

func (*RustPrinter) PrintSwitch

func (p *RustPrinter) PrintSwitch(init, expr string)

func (*RustPrinter) PrintType

func (p *RustPrinter) PrintType(name, typedef string)

func (*RustPrinter) PrintValue

func (p *RustPrinter) PrintValue(vtype, typedef, names, values string, ntuple, vtuple bool)

func (*RustPrinter) PrintfLevel

func (p *RustPrinter) PrintfLevel(term string, format string, values ...interface{})

func (*RustPrinter) PushContext

func (p *RustPrinter) PushContext(c ContextType)

func (*RustPrinter) Reset

func (p *RustPrinter) Reset()

func (*RustPrinter) SameLine

func (p *RustPrinter) SameLine()

func (*RustPrinter) SetWriter

func (p *RustPrinter) SetWriter(w io.Writer)

func (*RustPrinter) UpdateLevel

func (p *RustPrinter) UpdateLevel(delta int)

type SwiftPrinter

type SwiftPrinter struct {
	Printer
	// contains filtered or unexported fields
}

SwiftPrinter implement the Printer interface for Swift programs

func (*SwiftPrinter) Chop

func (p *SwiftPrinter) Chop(line string) string

func (*SwiftPrinter) FormatArray

func (p *SwiftPrinter) FormatArray(l, elt string) string

func (*SwiftPrinter) FormatArrayIndex

func (p *SwiftPrinter) FormatArrayIndex(array, index string) string

func (*SwiftPrinter) FormatBinary

func (p *SwiftPrinter) FormatBinary(lhs, op, rhs string) string

func (*SwiftPrinter) FormatCall

func (p *SwiftPrinter) FormatCall(fun, args string, isFuncLit bool) string

func (*SwiftPrinter) FormatChan

func (p *SwiftPrinter) FormatChan(chdir, mtype string) string

func (*SwiftPrinter) FormatCompositeLit

func (p *SwiftPrinter) FormatCompositeLit(typedef, elt string) string

func (*SwiftPrinter) FormatEllipsis

func (p *SwiftPrinter) FormatEllipsis(expr string) string

func (*SwiftPrinter) FormatFuncLit

func (p *SwiftPrinter) FormatFuncLit(ftype, body string) string

func (*SwiftPrinter) FormatFuncType

func (p *SwiftPrinter) FormatFuncType(params, results string, withFunc bool) string

func (*SwiftPrinter) FormatIdent

func (p *SwiftPrinter) FormatIdent(id string) (ret string)

func (*SwiftPrinter) FormatInterface

func (p *SwiftPrinter) FormatInterface(methods string) string

func (*SwiftPrinter) FormatKeyValue

func (p *SwiftPrinter) FormatKeyValue(key, value string) string

func (*SwiftPrinter) FormatLiteral

func (p *SwiftPrinter) FormatLiteral(lit string) string

func (*SwiftPrinter) FormatMap

func (p *SwiftPrinter) FormatMap(key, elt string) string

func (*SwiftPrinter) FormatPair

func (p *SwiftPrinter) FormatPair(v Pair, t FieldType) string

func (*SwiftPrinter) FormatParen

func (p *SwiftPrinter) FormatParen(expr string) string

func (*SwiftPrinter) FormatSelector

func (p *SwiftPrinter) FormatSelector(pname, sel string, isObject bool) string

func (*SwiftPrinter) FormatSlice

func (p *SwiftPrinter) FormatSlice(slice, low, high, max string) string

func (*SwiftPrinter) FormatStar

func (p *SwiftPrinter) FormatStar(expr string) string

func (*SwiftPrinter) FormatStruct

func (p *SwiftPrinter) FormatStruct(fields string) string

func (*SwiftPrinter) FormatTypeAssert

func (p *SwiftPrinter) FormatTypeAssert(orig, assert string) string

func (*SwiftPrinter) FormatUnary

func (p *SwiftPrinter) FormatUnary(op, operand string) string

func (*SwiftPrinter) IsSameLine

func (p *SwiftPrinter) IsSameLine() bool

func (*SwiftPrinter) PopContext

func (p *SwiftPrinter) PopContext()

func (*SwiftPrinter) Print

func (p *SwiftPrinter) Print(values ...string)

func (*SwiftPrinter) PrintAssignment

func (p *SwiftPrinter) PrintAssignment(lhs, op, rhs string, ltuple, rtuple bool)

func (*SwiftPrinter) PrintBlockEnd

func (p *SwiftPrinter) PrintBlockEnd(b BlockType)

func (*SwiftPrinter) PrintBlockStart

func (p *SwiftPrinter) PrintBlockStart(b BlockType, empty bool)

func (*SwiftPrinter) PrintCase

func (p *SwiftPrinter) PrintCase(expr string)

func (*SwiftPrinter) PrintElse

func (p *SwiftPrinter) PrintElse()

func (*SwiftPrinter) PrintEmpty

func (p *SwiftPrinter) PrintEmpty()

func (*SwiftPrinter) PrintEndCase

func (p *SwiftPrinter) PrintEndCase()

func (*SwiftPrinter) PrintFor

func (p *SwiftPrinter) PrintFor(init, cond, post string)

func (*SwiftPrinter) PrintFunc

func (p *SwiftPrinter) PrintFunc(receiver, name, params, results string)

func (*SwiftPrinter) PrintIf

func (p *SwiftPrinter) PrintIf(init, cond string)

func (*SwiftPrinter) PrintImport

func (p *SwiftPrinter) PrintImport(name, path string)

func (*SwiftPrinter) PrintLevel

func (p *SwiftPrinter) PrintLevel(term string, values ...string)

func (*SwiftPrinter) PrintPackage

func (p *SwiftPrinter) PrintPackage(name string)

func (*SwiftPrinter) PrintRange

func (p *SwiftPrinter) PrintRange(key, value, expr string)

func (*SwiftPrinter) PrintReturn

func (p *SwiftPrinter) PrintReturn(expr string, tuple bool)

func (*SwiftPrinter) PrintSend

func (p *SwiftPrinter) PrintSend(ch, value string)

func (*SwiftPrinter) PrintStmt

func (p *SwiftPrinter) PrintStmt(stmt, expr string)

func (*SwiftPrinter) PrintSwitch

func (p *SwiftPrinter) PrintSwitch(init, expr string)

func (*SwiftPrinter) PrintType

func (p *SwiftPrinter) PrintType(name, typedef string)

func (*SwiftPrinter) PrintValue

func (p *SwiftPrinter) PrintValue(vtype, typedef, names, values string, ntuple, vtuple bool)

func (*SwiftPrinter) PushContext

func (p *SwiftPrinter) PushContext(c ContextType)

func (*SwiftPrinter) Reset

func (p *SwiftPrinter) Reset()

func (*SwiftPrinter) SameLine

func (p *SwiftPrinter) SameLine()

func (*SwiftPrinter) SetWriter

func (p *SwiftPrinter) SetWriter(w io.Writer)

func (*SwiftPrinter) UpdateLevel

func (p *SwiftPrinter) UpdateLevel(delta int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL