[refactoring] update ast structure of "Throw" node
This commit is contained in:
parent
80aa328386
commit
48aaa7cc47
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -1167,15 +1167,14 @@ unticked_statement:
|
|||||||
}
|
}
|
||||||
| T_THROW expr ';'
|
| T_THROW expr ';'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtThrow{ast.Node{}, $2}
|
$$ = &ast.StmtThrow{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokensPosition($1, $3),
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
},
|
||||||
|
ThrowTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
SemiColonTkn: $3,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $3.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.SemiColon, $3.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_GOTO T_STRING ';'
|
| T_GOTO T_STRING ';'
|
||||||
{
|
{
|
||||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -1077,15 +1077,14 @@ statement:
|
|||||||
}
|
}
|
||||||
| T_THROW expr ';'
|
| T_THROW expr ';'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtThrow{ast.Node{}, $2}
|
$$ = &ast.StmtThrow{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokensPosition($1, $3),
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
},
|
||||||
|
ThrowTkn: $1,
|
||||||
// save comments
|
Expr: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
SemiColonTkn: $3,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Expr, $3.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setToken($$, token.SemiColon, $3.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_GOTO T_STRING ';'
|
| T_GOTO T_STRING ';'
|
||||||
{
|
{
|
||||||
|
@ -709,7 +709,9 @@ func (n *StmtSwitch) Accept(v NodeVisitor) {
|
|||||||
// StmtThrow node
|
// StmtThrow node
|
||||||
type StmtThrow struct {
|
type StmtThrow struct {
|
||||||
Node
|
Node
|
||||||
Expr Vertex
|
ThrowTkn *token.Token
|
||||||
|
Expr Vertex
|
||||||
|
SemiColonTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtThrow) Accept(v NodeVisitor) {
|
func (n *StmtThrow) Accept(v NodeVisitor) {
|
||||||
|
@ -260,3 +260,8 @@ func (v *FilterTokens) StmtFinally(n *ast.StmtFinally) {
|
|||||||
n.OpenCurlyBracketTkn = nil
|
n.OpenCurlyBracketTkn = nil
|
||||||
n.CloseCurlyBracketTkn = nil
|
n.CloseCurlyBracketTkn = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *FilterTokens) StmtThrow(n *ast.StmtThrow) {
|
||||||
|
n.ThrowTkn = nil
|
||||||
|
n.SemiColonTkn = nil
|
||||||
|
}
|
||||||
|
@ -2674,23 +2674,11 @@ func (p *Printer) printStmtAltSwitch(n *ast.StmtSwitch) {
|
|||||||
p.printToken(n.SemiColonTkn, ";")
|
p.printToken(n.SemiColonTkn, ";")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) printStmtThrow(n ast.Vertex) {
|
func (p *Printer) printStmtThrow(n *ast.StmtThrow) {
|
||||||
nn := n.(*ast.StmtThrow)
|
p.printToken(n.ThrowTkn, "throw")
|
||||||
p.printFreeFloating(nn, token.Start)
|
p.bufStart = " "
|
||||||
|
p.Print(n.Expr)
|
||||||
p.write([]byte("throw"))
|
p.printToken(n.SemiColonTkn, ";")
|
||||||
if nn.Expr.GetNode().Tokens.IsEmpty() {
|
|
||||||
p.write([]byte(" "))
|
|
||||||
}
|
|
||||||
p.Print(nn.Expr)
|
|
||||||
p.printFreeFloating(nn, token.Expr)
|
|
||||||
|
|
||||||
p.printFreeFloating(nn, token.SemiColon)
|
|
||||||
if n.GetNode().Tokens.IsEmpty() {
|
|
||||||
p.write([]byte(";"))
|
|
||||||
}
|
|
||||||
|
|
||||||
p.printFreeFloating(nn, token.End)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) printStmtTraitAdaptationList(n ast.Vertex) {
|
func (p *Printer) printStmtTraitAdaptationList(n ast.Vertex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user