Documentation ¶
Overview ¶
Package format implements pretty printers for TTCN-3 source code.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fprint ¶
Fprint formats src in canonical TTCN-3 style and writes the result to w or returns an (I/O or syntax) error. src is expected to be syntactically correct TTCN-3 source text.
Example ¶
package main import ( "os" "github.com/nokia/ntt/ttcn3/format" ) func main() { input := "p := {\n x:=1, // Comment\ny := 234 // Comment 2\n}" if err := format.Fprint(os.Stdout, input); err != nil { panic(err) } }
Output: p := { x := 1, // Comment y := 234 // Comment 2 }
Types ¶
type CanonicalPrinter ¶
type CanonicalPrinter struct { // UseSpaces controls whether to use spaces instead of tabs for indenting. UseSpaces bool // TabWidth is the width of a tab character (equivalent to the number // of spaces, default is 8). TabWidth int // Indent is the level of indentation at which to start. Indent int // contains filtered or unexported fields }
CanonicalPrinter is a simple formatter that only fixes indentation and various whitespace issues.
Example ¶
package main import ( "os" "github.com/nokia/ntt/ttcn3/format" ) func main() { input := "p := {\n x:=1, // Comment\ny := 234 // Comment 2\n}" p := format.NewCanonicalPrinter(os.Stdout) p.Indent = 1 p.UseSpaces = true p.TabWidth = 2 p.Fprint(input) }
Output: p := { x := 1, // Comment y := 234 // Comment 2 }
func NewCanonicalPrinter ¶
func NewCanonicalPrinter(w io.Writer) *CanonicalPrinter
NewCanonicalPrinter returns a new printer that formats source code.
func (*CanonicalPrinter) Fprint ¶
func (p *CanonicalPrinter) Fprint(v interface{}) error
Click to show internal directories.
Click to hide internal directories.