remove SimpleNode

This commit is contained in:
vadim
2017-12-27 19:55:58 +02:00
parent e83ab79344
commit 32a285b437
159 changed files with 1195 additions and 622 deletions

View File

@@ -2,28 +2,28 @@ package scalar
import (
"fmt"
"github.com/z7zmey/php-parser/token"
"github.com/z7zmey/php-parser/node"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Dnumber) Name() string {
return "Dnumber"
}
type Dnumber struct {
node.SimpleNode
name string
token token.Token
}
func NewDnumber(token token.Token) node.Node {
return Dnumber{
node.SimpleNode{Name: "Dnumber", Attributes: make(map[string]string)},
"Dnumber",
token,
}
}
func (n Dnumber) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
for _, nn := range n.Children {
nn.Print(out, indent+" ")
}
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -2,23 +2,26 @@ package scalar
import (
"fmt"
"github.com/z7zmey/php-parser/token"
"github.com/z7zmey/php-parser/node"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
type Encapsed struct {
node.SimpleNode
startToken token.Token
endToken token.Token
parts []node.Node
func(n Encapsed) Name() string {
return "Encapsed"
}
type Encapsed struct {
name string
startToken token.Token
endToken token.Token
parts []node.Node
}
func NewEncapsed(startToken token.Token, parts []node.Node, endToken token.Token) node.Node {
return Encapsed{
node.SimpleNode{Name: "Encapsed", Attributes: make(map[string]string)},
"Encapsed",
startToken,
endToken,
parts,
@@ -26,9 +29,12 @@ func NewEncapsed(startToken token.Token, parts []node.Node, endToken token.Token
}
func (n Encapsed) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d]", indent, n.Name, n.startToken.StartLine, n.endToken.EndLine)
fmt.Fprintf(out, "\n%vparts:", indent+" ",)
for _, nn := range n.parts {
nn.Print(out, indent+" ")
fmt.Fprintf(out, "\n%v%v [%d %d]", indent, n.name, n.startToken.StartLine, n.endToken.EndLine)
if n.parts != nil {
fmt.Fprintf(out, "\n%vparts:", indent+" ")
for _, nn := range n.parts {
nn.Print(out, indent+" ")
}
}
}

View File

@@ -2,27 +2,28 @@ package scalar
import (
"fmt"
"github.com/z7zmey/php-parser/token"
"github.com/z7zmey/php-parser/node"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n EncapsedStringPart) Name() string {
return "EncapsedStringPart"
}
type EncapsedStringPart struct {
node.SimpleNode
name string
token token.Token
}
func NewEncapsedStringPart(t token.Token) node.Node {
return EncapsedStringPart{
node.SimpleNode{Name: "EncapsedStringPart", Attributes: make(map[string]string)},
"EncapsedStringPart",
t,
}
}
func (n EncapsedStringPart) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
for _, nn := range n.Children {
nn.Print(out, indent+" ")
}
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -2,28 +2,28 @@ package scalar
import (
"fmt"
"github.com/z7zmey/php-parser/token"
"github.com/z7zmey/php-parser/node"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n Lnumber) Name() string {
return "Lnumber"
}
type Lnumber struct {
node.SimpleNode
name string
token token.Token
}
func NewLnumber(token token.Token) node.Node {
return Lnumber{
node.SimpleNode{Name: "Lnumber", Attributes: make(map[string]string)},
"Lnumber",
token,
}
}
func (n Lnumber) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
for _, nn := range n.Children {
nn.Print(out, indent+" ")
}
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -2,28 +2,28 @@ package scalar
import (
"fmt"
"github.com/z7zmey/php-parser/token"
"github.com/z7zmey/php-parser/node"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n MagicConstant) Name() string {
return "MagicConstant"
}
type MagicConstant struct {
node.SimpleNode
name string
token token.Token
}
func NewMagicConstant(token token.Token) node.Node {
return String{
node.SimpleNode{Name: "MagicConstant", Attributes: make(map[string]string)},
return MagicConstant{
"MagicConstant",
token,
}
}
func (n MagicConstant) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
for _, nn := range n.Children {
nn.Print(out, indent+" ")
}
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}

View File

@@ -2,28 +2,28 @@ package scalar
import (
"fmt"
"github.com/z7zmey/php-parser/token"
"github.com/z7zmey/php-parser/node"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
func(n String) Name() string {
return "String"
}
type String struct {
node.SimpleNode
name string
token token.Token
}
func NewString(token token.Token) node.Node {
return String{
node.SimpleNode{Name: "String", Attributes: make(map[string]string)},
"String",
token,
}
}
func (n String) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
for _, nn := range n.Children {
nn.Print(out, indent+" ")
}
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.name, n.token.StartLine, n.token.EndLine, n.token.Value)
}