Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( PhpState printerState = iota HtmlState )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PrettyPrinter ¶
type PrettyPrinter struct {
// contains filtered or unexported fields
}
func NewPrettyPrinter ¶
func NewPrettyPrinter(w io.Writer, indentStr string) *PrettyPrinter
NewPrettyPrinter - Constructor for PrettyPrinter
func (*PrettyPrinter) Print ¶
func (p *PrettyPrinter) Print(n node.Node)
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Example ¶
package main import ( "os" "github.com/VKCOM/noverify/src/php/parser/node/name" "github.com/VKCOM/noverify/src/php/parser/node/stmt" "github.com/VKCOM/noverify/src/php/parser/php7" "github.com/VKCOM/noverify/src/php/parser/printer" ) func main() { src := `<?php namespace Foo; abstract class Bar extends Baz { public function greet() { echo "Hello"; // some comment } } ` // parse php7parser := php7.NewParser([]byte(src)) php7parser.WithFreeFloating() php7parser.Parse() rootNode := php7parser.GetRootNode() // change namespace parts := &rootNode.Stmts[0].(*stmt.Namespace).NamespaceName.(*name.Name).Parts *parts = append(*parts, &name.NamePart{Value: "Quuz"}) // print p := printer.NewPrinter(os.Stdout) p.Print(rootNode) }
Output: <?php namespace Foo\Quuz; abstract class Bar extends Baz { public function greet() { echo "Hello"; // some comment } }
Click to show internal directories.
Click to hide internal directories.