[refactoring] update ast structure of "Switch", "Case", "Default" nodes; remove "CaseList" node
This commit is contained in:
@@ -9431,78 +9431,68 @@ func TestStmtSwitch(t *testing.T) {
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
CaseList: &ast.StmtCaseList{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 2,
|
||||
EndLine: 5,
|
||||
StartPos: 17,
|
||||
EndPos: 58,
|
||||
CaseList: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 22,
|
||||
EndPos: 36,
|
||||
},
|
||||
},
|
||||
},
|
||||
Cases: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 22,
|
||||
EndPos: 36,
|
||||
StartPos: 27,
|
||||
EndPos: 28,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 27,
|
||||
EndPos: 28,
|
||||
},
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 30,
|
||||
EndPos: 36,
|
||||
},
|
||||
StartPos: 30,
|
||||
EndPos: 36,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 40,
|
||||
EndPos: 54,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 40,
|
||||
EndPos: 54,
|
||||
StartPos: 45,
|
||||
EndPos: 46,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 45,
|
||||
EndPos: 46,
|
||||
},
|
||||
},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 48,
|
||||
EndPos: 54,
|
||||
},
|
||||
StartPos: 48,
|
||||
EndPos: 54,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -9560,78 +9550,68 @@ func TestStmtSwitch_Semicolon(t *testing.T) {
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
CaseList: &ast.StmtCaseList{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 2,
|
||||
EndLine: 5,
|
||||
StartPos: 17,
|
||||
EndPos: 59,
|
||||
CaseList: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 23,
|
||||
EndPos: 37,
|
||||
},
|
||||
},
|
||||
},
|
||||
Cases: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 23,
|
||||
EndPos: 37,
|
||||
StartPos: 28,
|
||||
EndPos: 29,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 28,
|
||||
EndPos: 29,
|
||||
},
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 31,
|
||||
EndPos: 37,
|
||||
},
|
||||
StartPos: 31,
|
||||
EndPos: 37,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 41,
|
||||
EndPos: 55,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 41,
|
||||
EndPos: 55,
|
||||
StartPos: 46,
|
||||
EndPos: 47,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 46,
|
||||
EndPos: 47,
|
||||
},
|
||||
},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 49,
|
||||
EndPos: 55,
|
||||
},
|
||||
StartPos: 49,
|
||||
EndPos: 55,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -9670,7 +9650,7 @@ func TestStmtSwitch_Alt(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtAltSwitch{
|
||||
&ast.StmtSwitch{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 2,
|
||||
@@ -9679,6 +9659,7 @@ func TestStmtSwitch_Alt(t *testing.T) {
|
||||
EndPos: 65,
|
||||
},
|
||||
},
|
||||
Alt: true,
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
@@ -9690,71 +9671,61 @@ func TestStmtSwitch_Alt(t *testing.T) {
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
CaseList: &ast.StmtCaseList{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: -1,
|
||||
StartPos: 22,
|
||||
EndPos: -1,
|
||||
CaseList: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: -1,
|
||||
StartPos: 22,
|
||||
EndPos: -1,
|
||||
},
|
||||
},
|
||||
},
|
||||
Cases: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: -1,
|
||||
StartPos: 22,
|
||||
EndPos: -1,
|
||||
EndLine: 3,
|
||||
StartPos: 27,
|
||||
EndPos: 28,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 27,
|
||||
EndPos: 28,
|
||||
},
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
&ast.StmtDefault{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: -1,
|
||||
StartPos: 33,
|
||||
EndPos: -1,
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtDefault{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: -1,
|
||||
StartPos: 33,
|
||||
EndPos: -1,
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 5,
|
||||
EndLine: -1,
|
||||
StartPos: 45,
|
||||
EndPos: -1,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 5,
|
||||
EndLine: -1,
|
||||
StartPos: 45,
|
||||
EndPos: -1,
|
||||
EndLine: 5,
|
||||
StartPos: 50,
|
||||
EndPos: 51,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 5,
|
||||
EndLine: 5,
|
||||
StartPos: 50,
|
||||
EndPos: 51,
|
||||
},
|
||||
},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -9788,7 +9759,7 @@ func TestStmtSwitch_AltSemicolon(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtAltSwitch{
|
||||
&ast.StmtSwitch{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 2,
|
||||
@@ -9797,6 +9768,7 @@ func TestStmtSwitch_AltSemicolon(t *testing.T) {
|
||||
EndPos: 54,
|
||||
},
|
||||
},
|
||||
Alt: true,
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
@@ -9808,60 +9780,50 @@ func TestStmtSwitch_AltSemicolon(t *testing.T) {
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
CaseList: &ast.StmtCaseList{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: -1,
|
||||
StartPos: 23,
|
||||
EndPos: -1,
|
||||
CaseList: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: -1,
|
||||
StartPos: 23,
|
||||
EndPos: -1,
|
||||
},
|
||||
},
|
||||
},
|
||||
Cases: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: -1,
|
||||
StartPos: 23,
|
||||
EndPos: -1,
|
||||
EndLine: 3,
|
||||
StartPos: 28,
|
||||
EndPos: 29,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 3,
|
||||
EndLine: 3,
|
||||
StartPos: 28,
|
||||
EndPos: 29,
|
||||
},
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: -1,
|
||||
StartPos: 34,
|
||||
EndPos: -1,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: -1,
|
||||
StartPos: 34,
|
||||
EndPos: -1,
|
||||
EndLine: 4,
|
||||
StartPos: 39,
|
||||
EndPos: 40,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 4,
|
||||
EndLine: 4,
|
||||
StartPos: 39,
|
||||
EndPos: 40,
|
||||
},
|
||||
},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
1185
internal/php5/php5.go
generated
1185
internal/php5/php5.go
generated
File diff suppressed because it is too large
Load Diff
@@ -940,22 +940,13 @@ unticked_statement:
|
||||
}
|
||||
| T_SWITCH parenthesis_expr switch_case_list
|
||||
{
|
||||
switch n := $3.(type) {
|
||||
case *ast.StmtSwitch:
|
||||
n.Cond = $2
|
||||
case *ast.StmtAltSwitch:
|
||||
n.Cond = $2
|
||||
default:
|
||||
panic("unexpected node type")
|
||||
}
|
||||
$3.(*ast.StmtSwitch).SwitchTkn = $1
|
||||
$3.(*ast.StmtSwitch).OpenParenthesisTkn = $2.(*ast.ParserBrackets).OpenBracketTkn
|
||||
$3.(*ast.StmtSwitch).Cond = $2.(*ast.ParserBrackets).Child
|
||||
$3.(*ast.StmtSwitch).CloseParenthesisTkn = $2.(*ast.ParserBrackets).CloseBracketTkn
|
||||
$3.(*ast.StmtSwitch).Node.Position = position.NewTokenNodePosition($1, $3)
|
||||
|
||||
$$ = $3
|
||||
|
||||
// save position
|
||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
||||
}
|
||||
| T_BREAK ';'
|
||||
{
|
||||
@@ -1790,62 +1781,53 @@ declare_list:
|
||||
switch_case_list:
|
||||
'{' case_list '}'
|
||||
{
|
||||
caseList := &ast.StmtCaseList{ast.Node{}, $2}
|
||||
$$ = &ast.StmtSwitch{ast.Node{}, nil, caseList}
|
||||
|
||||
// save position
|
||||
caseList.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(caseList, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(caseList, token.CaseListEnd, $3.SkippedTokens)
|
||||
$$ = &ast.StmtSwitch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $3),
|
||||
},
|
||||
OpenCurlyBracketTkn: $1,
|
||||
CaseList: $2,
|
||||
CloseCurlyBracketTkn: $3,
|
||||
}
|
||||
}
|
||||
| '{' ';' case_list '}'
|
||||
{
|
||||
caseList := &ast.StmtCaseList{ast.Node{}, $3}
|
||||
$$ = &ast.StmtSwitch{ast.Node{}, nil, caseList}
|
||||
|
||||
// save position
|
||||
caseList.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(caseList, token.Start, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(caseList, token.CaseListStart, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(caseList, token.CaseListEnd, $4.SkippedTokens)
|
||||
$$ = &ast.StmtSwitch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
OpenCurlyBracketTkn: $1,
|
||||
CaseSeparatorTkn: $2,
|
||||
CaseList: $3,
|
||||
CloseCurlyBracketTkn: $4,
|
||||
}
|
||||
}
|
||||
| ':' case_list T_ENDSWITCH ';'
|
||||
{
|
||||
caseList := &ast.StmtCaseList{ast.Node{}, $2}
|
||||
$$ = &ast.StmtAltSwitch{ast.Node{}, nil, caseList}
|
||||
|
||||
// save position
|
||||
caseList.GetNode().Position = position.NewNodeListPosition($2)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Cond, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(caseList, token.CaseListEnd, $3.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.AltEnd, $4.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $4.SkippedTokens)
|
||||
$$ = &ast.StmtSwitch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $4),
|
||||
},
|
||||
Alt: true,
|
||||
ColonTkn: $1,
|
||||
CaseList: $2,
|
||||
EndSwitchTkn: $3,
|
||||
SemiColonTkn: $4,
|
||||
}
|
||||
}
|
||||
| ':' ';' case_list T_ENDSWITCH ';'
|
||||
{
|
||||
|
||||
caseList := &ast.StmtCaseList{ast.Node{}, $3}
|
||||
$$ = &ast.StmtAltSwitch{ast.Node{}, nil, caseList}
|
||||
|
||||
// save position
|
||||
caseList.GetNode().Position = position.NewNodeListPosition($3)
|
||||
$$.GetNode().Position = position.NewTokensPosition($1, $5)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating($$, token.Cond, $1.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloatingTokens(caseList, token.CaseListStart, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(caseList, token.CaseListEnd, $4.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating($$, token.AltEnd, $5.SkippedTokens)
|
||||
yylex.(*Parser).setToken($$, token.SemiColon, $5.SkippedTokens)
|
||||
$$ = &ast.StmtSwitch{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokensPosition($1, $5),
|
||||
},
|
||||
Alt: true,
|
||||
ColonTkn: $1,
|
||||
CaseSeparatorTkn: $2,
|
||||
CaseList: $3,
|
||||
EndSwitchTkn: $4,
|
||||
SemiColonTkn: $5,
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1853,33 +1835,30 @@ switch_case_list:
|
||||
case_list:
|
||||
/* empty */
|
||||
{
|
||||
$$ = []ast.Vertex{}
|
||||
$$ = nil
|
||||
}
|
||||
| case_list T_CASE expr case_separator inner_statement_list
|
||||
{
|
||||
_case := &ast.StmtCase{ast.Node{}, $3, $5}
|
||||
$$ = append($1, _case)
|
||||
|
||||
// save position
|
||||
_case.GetNode().Position = position.NewTokenNodeListPosition($2, $5)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(_case, token.Start, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(_case, token.Expr, $4.SkippedTokens)
|
||||
yylex.(*Parser).setToken(_case, token.CaseSeparator, $4.SkippedTokens)
|
||||
$$ = append($1, &ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodeListPosition($2, $5),
|
||||
},
|
||||
CaseTkn: $2,
|
||||
Cond: $3,
|
||||
CaseSeparatorTkn: $4,
|
||||
Stmts: $5,
|
||||
})
|
||||
}
|
||||
| case_list T_DEFAULT case_separator inner_statement_list
|
||||
{
|
||||
_default := &ast.StmtDefault{ast.Node{}, $4}
|
||||
$$ = append($1, _default)
|
||||
|
||||
// save position
|
||||
_default.GetNode().Position = position.NewTokenNodeListPosition($2, $4)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).setFreeFloating(_default, token.Start, $2.SkippedTokens)
|
||||
yylex.(*Parser).setFreeFloating(_default, token.Default, $3.SkippedTokens)
|
||||
yylex.(*Parser).setToken(_default, token.CaseSeparator, $3.SkippedTokens)
|
||||
$$ = append($1, &ast.StmtDefault{
|
||||
Node: ast.Node{
|
||||
Position: position.NewTokenNodeListPosition($2, $4),
|
||||
},
|
||||
DefaultTkn: $2,
|
||||
CaseSeparatorTkn: $3,
|
||||
Stmts: $4,
|
||||
})
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -6894,7 +6894,7 @@ func TestPhp5(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
&ast.StmtAltSwitch{
|
||||
&ast.StmtSwitch{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 118,
|
||||
@@ -6903,6 +6903,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 2606,
|
||||
},
|
||||
},
|
||||
Alt: true,
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
@@ -6914,75 +6915,65 @@ func TestPhp5(t *testing.T) {
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
CaseList: &ast.StmtCaseList{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 119,
|
||||
EndLine: -1,
|
||||
StartPos: 2563,
|
||||
EndPos: -1,
|
||||
CaseList: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 119,
|
||||
EndLine: -1,
|
||||
StartPos: 2563,
|
||||
EndPos: -1,
|
||||
},
|
||||
},
|
||||
},
|
||||
Cases: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 119,
|
||||
EndLine: -1,
|
||||
StartPos: 2563,
|
||||
EndPos: -1,
|
||||
EndLine: 119,
|
||||
StartPos: 2568,
|
||||
EndPos: 2569,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 119,
|
||||
EndLine: 119,
|
||||
StartPos: 2568,
|
||||
EndPos: 2569,
|
||||
},
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
&ast.StmtDefault{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 120,
|
||||
EndLine: -1,
|
||||
StartPos: 2575,
|
||||
EndPos: -1,
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtDefault{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 120,
|
||||
EndLine: -1,
|
||||
StartPos: 2575,
|
||||
EndPos: -1,
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 121,
|
||||
EndLine: -1,
|
||||
StartPos: 2588,
|
||||
EndPos: -1,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 121,
|
||||
EndLine: -1,
|
||||
StartPos: 2588,
|
||||
EndPos: -1,
|
||||
EndLine: 121,
|
||||
StartPos: 2593,
|
||||
EndPos: 2594,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 121,
|
||||
EndLine: 121,
|
||||
StartPos: 2593,
|
||||
EndPos: 2594,
|
||||
},
|
||||
},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
},
|
||||
},
|
||||
&ast.StmtAltSwitch{
|
||||
&ast.StmtSwitch{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 124,
|
||||
@@ -6991,6 +6982,7 @@ func TestPhp5(t *testing.T) {
|
||||
EndPos: 2656,
|
||||
},
|
||||
},
|
||||
Alt: true,
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
@@ -7002,60 +6994,50 @@ func TestPhp5(t *testing.T) {
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
CaseList: &ast.StmtCaseList{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 125,
|
||||
EndLine: -1,
|
||||
StartPos: 2626,
|
||||
EndPos: -1,
|
||||
CaseList: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 125,
|
||||
EndLine: -1,
|
||||
StartPos: 2626,
|
||||
EndPos: -1,
|
||||
},
|
||||
},
|
||||
},
|
||||
Cases: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 125,
|
||||
EndLine: -1,
|
||||
StartPos: 2626,
|
||||
EndPos: -1,
|
||||
EndLine: 125,
|
||||
StartPos: 2631,
|
||||
EndPos: 2632,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 125,
|
||||
EndLine: 125,
|
||||
StartPos: 2631,
|
||||
EndPos: 2632,
|
||||
},
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 126,
|
||||
EndLine: -1,
|
||||
StartPos: 2638,
|
||||
EndPos: -1,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 126,
|
||||
EndLine: -1,
|
||||
StartPos: 2638,
|
||||
EndPos: -1,
|
||||
EndLine: 126,
|
||||
StartPos: 2643,
|
||||
EndPos: 2644,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 126,
|
||||
EndLine: 126,
|
||||
StartPos: 2643,
|
||||
EndPos: 2644,
|
||||
},
|
||||
},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -7079,78 +7061,68 @@ func TestPhp5(t *testing.T) {
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
CaseList: &ast.StmtCaseList{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 129,
|
||||
EndLine: 132,
|
||||
StartPos: 2669,
|
||||
EndPos: 2710,
|
||||
CaseList: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 130,
|
||||
EndLine: 130,
|
||||
StartPos: 2675,
|
||||
EndPos: 2689,
|
||||
},
|
||||
},
|
||||
},
|
||||
Cases: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 130,
|
||||
EndLine: 130,
|
||||
StartPos: 2675,
|
||||
EndPos: 2689,
|
||||
StartPos: 2680,
|
||||
EndPos: 2681,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 130,
|
||||
EndLine: 130,
|
||||
StartPos: 2680,
|
||||
EndPos: 2681,
|
||||
},
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 130,
|
||||
EndLine: 130,
|
||||
StartPos: 2683,
|
||||
EndPos: 2689,
|
||||
},
|
||||
StartPos: 2683,
|
||||
EndPos: 2689,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 131,
|
||||
EndLine: 131,
|
||||
StartPos: 2694,
|
||||
EndPos: 2708,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 131,
|
||||
EndLine: 131,
|
||||
StartPos: 2694,
|
||||
EndPos: 2708,
|
||||
StartPos: 2699,
|
||||
EndPos: 2700,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 131,
|
||||
EndLine: 131,
|
||||
StartPos: 2699,
|
||||
EndPos: 2700,
|
||||
},
|
||||
},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 131,
|
||||
EndLine: 131,
|
||||
StartPos: 2702,
|
||||
EndPos: 2708,
|
||||
},
|
||||
StartPos: 2702,
|
||||
EndPos: 2708,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -7178,78 +7150,68 @@ func TestPhp5(t *testing.T) {
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
CaseList: &ast.StmtCaseList{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 134,
|
||||
EndLine: 137,
|
||||
StartPos: 2723,
|
||||
EndPos: 2765,
|
||||
CaseList: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 135,
|
||||
EndLine: 135,
|
||||
StartPos: 2730,
|
||||
EndPos: 2744,
|
||||
},
|
||||
},
|
||||
},
|
||||
Cases: []ast.Vertex{
|
||||
&ast.StmtCase{
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 135,
|
||||
EndLine: 135,
|
||||
StartPos: 2730,
|
||||
EndPos: 2744,
|
||||
StartPos: 2735,
|
||||
EndPos: 2736,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 135,
|
||||
EndLine: 135,
|
||||
StartPos: 2735,
|
||||
EndPos: 2736,
|
||||
},
|
||||
},
|
||||
Value: []byte("1"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 135,
|
||||
EndLine: 135,
|
||||
StartPos: 2738,
|
||||
EndPos: 2744,
|
||||
},
|
||||
StartPos: 2738,
|
||||
EndPos: 2744,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&ast.StmtCase{
|
||||
},
|
||||
&ast.StmtCase{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 136,
|
||||
EndLine: 136,
|
||||
StartPos: 2749,
|
||||
EndPos: 2763,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 136,
|
||||
EndLine: 136,
|
||||
StartPos: 2749,
|
||||
EndPos: 2763,
|
||||
StartPos: 2754,
|
||||
EndPos: 2755,
|
||||
},
|
||||
},
|
||||
Cond: &ast.ScalarLnumber{
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 136,
|
||||
EndLine: 136,
|
||||
StartPos: 2754,
|
||||
EndPos: 2755,
|
||||
},
|
||||
},
|
||||
Value: []byte("2"),
|
||||
},
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtBreak{
|
||||
Node: ast.Node{
|
||||
Position: &position.Position{
|
||||
StartLine: 136,
|
||||
EndLine: 136,
|
||||
StartPos: 2757,
|
||||
EndPos: 2763,
|
||||
},
|
||||
StartPos: 2757,
|
||||
EndPos: 2763,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user