label node
This commit is contained in:
parent
c25748d7db
commit
92688ac8d2
25
node/stmt/label.go
Normal file
25
node/stmt/label.go
Normal file
@ -0,0 +1,25 @@
|
||||
package stmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Label struct {
|
||||
node.SimpleNode
|
||||
token token.Token
|
||||
}
|
||||
|
||||
func NewLabel(token token.Token) node.Node {
|
||||
return Label{
|
||||
node.SimpleNode{Name: "Label", Attributes: make(map[string]string)},
|
||||
token,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Label) 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)
|
||||
}
|
@ -2939,7 +2939,7 @@ yydefault:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line parser/parser.y:403
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("Label").Attribute("name", yyDollar[1].token.String())
|
||||
yyVAL.node = stmt.NewLabel(yyDollar[1].token)
|
||||
}
|
||||
case 153:
|
||||
yyDollar = yyS[yypt-0 : yypt+1]
|
||||
|
@ -400,7 +400,7 @@ statement:
|
||||
}
|
||||
| T_THROW expr ';' { $$ = node.NewSimpleNode("Throw").Append($2) }
|
||||
| T_GOTO T_STRING ';' { $$ = stmt.NewGoto($1, $2) }
|
||||
| T_STRING ':' { $$ = node.NewSimpleNode("Label").Attribute("name", $1.String()) }
|
||||
| T_STRING ':' { $$ = stmt.NewLabel($1) }
|
||||
|
||||
catch_list:
|
||||
/* empty */ { $$ = []node.Node{} }
|
||||
|
Loading…
Reference in New Issue
Block a user