github.com/hirochachacha/plua@v0.0.0-20170217012138-c82f520cc725/compiler/ast/printer/printer.go (about)

     1  package printer
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/hirochachacha/plua/compiler/ast"
     7  )
     8  
     9  func FprintTree(w io.Writer, node ast.Node) error {
    10  	p := treeprinter{w: w}
    11  	p.printNode(node, "", 0)
    12  	return p.err
    13  }
    14  
    15  func Fprint(w io.Writer, node ast.Node) error {
    16  	p := newPrinter(w)
    17  	p.printNode(node)
    18  	if p.err != nil {
    19  		return p.err
    20  	}
    21  	if err := p.w.Flush(); err != nil {
    22  		return err
    23  	}
    24  	return nil
    25  }