php-parser/pkg/ast/visitor/dump_test.go

44 lines
724 B
Go
Raw Normal View History

2020-03-12 22:20:48 +00:00
package visitor_test
import (
"github.com/z7zmey/php-parser/pkg/ast"
"github.com/z7zmey/php-parser/pkg/ast/traverser"
"github.com/z7zmey/php-parser/pkg/ast/visitor"
"os"
)
func ExampleDump() {
stxTree := &ast.Root{
Stmts: []ast.Vertex{
&ast.Identifier{},
&ast.Parameter{
Variadic: true,
Var: &ast.ExprVariable{
},
},
&ast.StmtInlineHtml{
Value: "foo",
},
},
}
traverser.NewDFS(visitor.NewDump(os.Stdout)).Traverse(stxTree)
//output:
//&ast.Root{
// Stmts: []ast.Vertex{
// &ast.Identifier{
// Value: "",
// },
// &ast.Parameter{
// Variadic: true,
// Var: &ast.ExprVariable{
// },
// },
// &ast.StmtInlineHtml{
// Value: "foo",
// },
// },
//}
}