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,
|
2020-05-12 21:16:36 +00:00
|
|
|
Var: &ast.ExprVariable{},
|
2020-03-12 22:20:48 +00:00
|
|
|
},
|
|
|
|
&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",
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
//}
|
|
|
|
}
|