goto node
This commit is contained in:
parent
9e73d2b162
commit
d266fce399
27
node/stmt/goto.go
Normal file
27
node/stmt/goto.go
Normal file
@ -0,0 +1,27 @@
|
||||
package stmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/z7zmey/php-parser/node"
|
||||
"github.com/z7zmey/php-parser/token"
|
||||
)
|
||||
|
||||
type Goto struct {
|
||||
node.SimpleNode
|
||||
token token.Token
|
||||
name token.Token
|
||||
}
|
||||
|
||||
func NewGoto(token token.Token, name token.Token) node.Node {
|
||||
return Goto{
|
||||
node.SimpleNode{Name: "Goto", Attributes: make(map[string]string)},
|
||||
token,
|
||||
name,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Goto) Print(out io.Writer, indent string) {
|
||||
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.name.EndLine, n.name.Value)
|
||||
}
|
@ -2930,7 +2930,7 @@ yydefault:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line parser/parser.y:390
|
||||
{
|
||||
yyVAL.node = node.NewSimpleNode("GoTo").Attribute("Label", yyDollar[2].token.String())
|
||||
yyVAL.node = stmt.NewGoto(yyDollar[1].token, yyDollar[2].token)
|
||||
}
|
||||
case 152:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
|
@ -387,7 +387,7 @@ statement:
|
||||
$$ = stmt.NewTry($1, $3.(node.SimpleNode).Children, $5, $6)
|
||||
}
|
||||
| T_THROW expr ';' { $$ = node.NewSimpleNode("Throw").Append($2) }
|
||||
| T_GOTO T_STRING ';' { $$ = node.NewSimpleNode("GoTo").Attribute("Label", $2.String()) }
|
||||
| T_GOTO T_STRING ';' { $$ = stmt.NewGoto($1, $2) }
|
||||
| T_STRING ':' { $$ = node.NewSimpleNode("Label").Attribute("name", $1.String()) }
|
||||
|
||||
catch_list:
|
||||
|
Loading…
Reference in New Issue
Block a user