[refactoring] dumper: print node position and tokens

This commit is contained in:
Vadym Slizov
2020-07-04 20:59:26 +03:00
parent 7fc23cc1de
commit 8417e7d6d2
5 changed files with 763 additions and 156 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,11 +4,29 @@ import (
"github.com/z7zmey/php-parser/pkg/ast"
"github.com/z7zmey/php-parser/pkg/ast/traverser"
"github.com/z7zmey/php-parser/pkg/ast/visitor"
"github.com/z7zmey/php-parser/pkg/position"
"github.com/z7zmey/php-parser/pkg/token"
"os"
)
func ExampleDump() {
stxTree := &ast.Root{
Node: ast.Node{
Tokens: token.Collection{
token.Start: []token.Token{
{
ID: token.T_WHITESPACE,
Value: []byte(" "),
},
},
},
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 0,
EndPos: 1,
},
},
Stmts: []ast.Vertex{
&ast.Identifier{},
&ast.Parameter{
@@ -25,6 +43,22 @@ func ExampleDump() {
//output:
//&ast.Root{
// Node: ast.Node{
// Tokens: token.Collection{
// token.Start: []token.Token{
// {
// ID: token.T_WHITESPACE,
// Value: []byte(" "),
// },
// },
// },
// Position: &position.Position{
// StartLine: 1,
// EndLine: 1,
// StartPos: 0,
// EndPos: 1,
// },
// },
// Stmts: []ast.Vertex{
// &ast.Identifier{
// Value: "",