[refactoring] update ast structure of "Unset" node
This commit is contained in:
		
							parent
							
								
									8b4d65ac4d
								
							
						
					
					
						commit
						62fc16da97
					
				
							
								
								
									
										1080
									
								
								internal/php5/php5.go
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1080
									
								
								internal/php5/php5.go
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -241,7 +241,7 @@ import ( | ||||
| %type <node> trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method | ||||
| %type <node> static_scalar_value static_operation static_var_list global_var_list | ||||
| %type <node> ctor_arguments function_call_parameter_list echo_expr_list | ||||
| %type <node> trait_adaptations | ||||
| %type <node> trait_adaptations unset_variables | ||||
| %type <node> switch_case_list | ||||
| %type <node> method_body | ||||
| %type <node> foreach_statement for_statement while_statement | ||||
| @ -255,7 +255,7 @@ import ( | ||||
| %type <list> top_statement_list namespace_name use_declarations use_function_declarations use_const_declarations | ||||
| %type <list> inner_statement_list encaps_list isset_variables non_empty_array_pair_list | ||||
| %type <list> array_pair_list assignment_list lexical_var_list elseif_list new_elseif_list non_empty_for_expr | ||||
| %type <list> for_expr case_list unset_variables declare_list catch_statement additional_catches | ||||
| %type <list> for_expr case_list declare_list catch_statement additional_catches | ||||
| %type <list> non_empty_additional_catches parameter_list non_empty_parameter_list class_statement_list | ||||
| %type <list> class_statement_list variable_modifiers method_modifiers class_variable_declaration | ||||
| %type <list> interface_list non_empty_function_call_parameter_list trait_list trait_adaptation_list non_empty_trait_adaptation_list | ||||
| @ -1084,17 +1084,13 @@ unticked_statement: | ||||
|             } | ||||
|     |   T_UNSET '(' unset_variables ')' ';' | ||||
|             { | ||||
|                 $$ = &ast.StmtUnset{ast.Node{}, $3} | ||||
|                 $3.(*ast.StmtUnset).UnsetTkn = $1 | ||||
|                 $3.(*ast.StmtUnset).OpenParenthesisTkn = $2 | ||||
|                 $3.(*ast.StmtUnset).CloseParenthesisTkn = $4 | ||||
|                 $3.(*ast.StmtUnset).SemiColonTkn = $5 | ||||
|                 $3.(*ast.StmtUnset).Node.Position = position.NewTokensPosition($1, $5) | ||||
| 
 | ||||
|                 // save position | ||||
|                 $$.GetNode().Position = position.NewTokensPosition($1, $5) | ||||
| 
 | ||||
|                 // save comments | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Unset, $2.SkippedTokens) | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.VarList, $4.SkippedTokens) | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.CloseParenthesisToken, $5.SkippedTokens) | ||||
|                 yylex.(*Parser).setToken($$, token.SemiColon, $5.SkippedTokens) | ||||
|                 $$ = $3 | ||||
|             } | ||||
|     |   T_FOREACH '(' variable T_AS foreach_variable foreach_optional_arg ')' foreach_statement | ||||
|             { | ||||
| @ -1334,14 +1330,16 @@ additional_catch: | ||||
| unset_variables: | ||||
|         unset_variable | ||||
|             { | ||||
|                 $$ = []ast.Vertex{$1} | ||||
|                 $$ = &ast.StmtUnset{ | ||||
|                     Vars: []ast.Vertex{$1}, | ||||
|                 } | ||||
|             } | ||||
|     |   unset_variables ',' unset_variable | ||||
|             { | ||||
|                 $$ = append($1, $3) | ||||
|                 $1.(*ast.StmtUnset).Vars = append($1.(*ast.StmtUnset).Vars, $3) | ||||
|                 $1.(*ast.StmtUnset).SeparatorTkns = append($1.(*ast.StmtUnset).SeparatorTkns, $2) | ||||
| 
 | ||||
|                 // save comments | ||||
|                 yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens) | ||||
|                 $$ = $1 | ||||
|             } | ||||
| ; | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										1125
									
								
								internal/php7/php7.go
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1125
									
								
								internal/php7/php7.go
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -264,6 +264,7 @@ import ( | ||||
| %type <node> method_body | ||||
| %type <node> foreach_statement for_statement while_statement | ||||
| %type <node> inline_function | ||||
| %type <node> unset_variables | ||||
| %type <ClassExtends> extends_from | ||||
| %type <ClassImplements> implements_list | ||||
| %type <InterfaceExtends> interface_extends_list | ||||
| @ -277,7 +278,7 @@ import ( | ||||
| %type <list> encaps_list backticks_expr namespace_name catch_name_list catch_list class_const_list | ||||
| %type <list> const_list for_exprs non_empty_for_exprs | ||||
| %type <list> unprefixed_use_declarations inline_use_declarations property_list | ||||
| %type <list> case_list trait_adaptation_list unset_variables | ||||
| %type <list> case_list trait_adaptation_list | ||||
| %type <list> use_declarations lexical_var_list isset_variables non_empty_array_pair_list | ||||
| %type <list> array_pair_list non_empty_argument_list top_statement_list | ||||
| %type <list> inner_statement_list parameter_list non_empty_parameter_list class_statement_list | ||||
| @ -998,21 +999,14 @@ statement: | ||||
|             } | ||||
|     |   T_UNSET '(' unset_variables possible_comma ')' ';' | ||||
|             { | ||||
|                 $$ = &ast.StmtUnset{ast.Node{}, $3} | ||||
|                 $3.(*ast.StmtUnset).UnsetTkn = $1 | ||||
|                 $3.(*ast.StmtUnset).OpenParenthesisTkn = $2 | ||||
|                 $3.(*ast.StmtUnset).SeparatorTkns = append($3.(*ast.StmtUnset).SeparatorTkns, $4) | ||||
|                 $3.(*ast.StmtUnset).CloseParenthesisTkn = $5 | ||||
|                 $3.(*ast.StmtUnset).SemiColonTkn = $6 | ||||
|                 $3.(*ast.StmtUnset).Node.Position = position.NewTokensPosition($1, $6) | ||||
| 
 | ||||
|                 // save position | ||||
|                 $$.GetNode().Position = position.NewTokensPosition($1, $6) | ||||
| 
 | ||||
|                 // save comments | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Unset, $2.SkippedTokens) | ||||
|                 if $4 != nil { | ||||
|                     yylex.(*Parser).setFreeFloating($$, token.VarList, append($4.SkippedTokens, $5.SkippedTokens...)) | ||||
|                 } else { | ||||
|                     yylex.(*Parser).setFreeFloating($$, token.VarList, $5.SkippedTokens) | ||||
|                 } | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.CloseParenthesisToken, $6.SkippedTokens) | ||||
|                 yylex.(*Parser).setToken($$, token.SemiColon, $6.SkippedTokens) | ||||
|                 $$ = $3 | ||||
|             } | ||||
|     |   T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement | ||||
|             { | ||||
| @ -1205,14 +1199,16 @@ finally_statement: | ||||
| unset_variables: | ||||
|         unset_variable | ||||
|             { | ||||
|                 $$ = []ast.Vertex{$1} | ||||
|                 $$ = &ast.StmtUnset{ | ||||
|                     Vars: []ast.Vertex{$1}, | ||||
|                 } | ||||
|             } | ||||
|     |   unset_variables ',' unset_variable | ||||
|             { | ||||
|                 $$ = append($1, $3) | ||||
|                 $1.(*ast.StmtUnset).Vars = append($1.(*ast.StmtUnset).Vars, $3) | ||||
|                 $1.(*ast.StmtUnset).SeparatorTkns = append($1.(*ast.StmtUnset).SeparatorTkns, $2) | ||||
| 
 | ||||
|                 // save comments | ||||
|                 yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens) | ||||
|                 $$ = $1 | ||||
|             } | ||||
| ; | ||||
| 
 | ||||
|  | ||||
| @ -783,7 +783,12 @@ func (n *StmtTry) Accept(v NodeVisitor) { | ||||
| // StmtUnset node | ||||
| type StmtUnset struct { | ||||
| 	Node | ||||
| 	Vars []Vertex | ||||
| 	UnsetTkn            *token.Token | ||||
| 	OpenParenthesisTkn  *token.Token | ||||
| 	Vars                []Vertex | ||||
| 	SeparatorTkns       []*token.Token | ||||
| 	CloseParenthesisTkn *token.Token | ||||
| 	SemiColonTkn        *token.Token | ||||
| } | ||||
| 
 | ||||
| func (n *StmtUnset) Accept(v NodeVisitor) { | ||||
|  | ||||
| @ -204,3 +204,12 @@ func (v *FilterTokens) StmtEcho(n *ast.StmtEcho) { | ||||
| func (v *FilterTokens) StmtInlineHtml(n *ast.StmtInlineHtml) { | ||||
| 	n.InlineHtmlTkn = nil | ||||
| } | ||||
| 
 | ||||
| func (v *FilterTokens) StmtUnset(n *ast.StmtUnset) { | ||||
| 	n.UnsetTkn = nil | ||||
| 	n.OpenParenthesisTkn = nil | ||||
| 	n.SeparatorTkns = nil | ||||
| 	n.CloseParenthesisTkn = nil | ||||
| 	n.SemiColonTkn = nil | ||||
| 	n.SemiColonTkn = nil | ||||
| } | ||||
|  | ||||
| @ -2905,24 +2905,12 @@ func (p *Printer) printStmtTry(n ast.Vertex) { | ||||
| 	p.printFreeFloating(nn, token.End) | ||||
| } | ||||
| 
 | ||||
| func (p *Printer) printStmtUnset(n ast.Vertex) { | ||||
| 	nn := n.(*ast.StmtUnset) | ||||
| 	p.printFreeFloating(nn, token.Start) | ||||
| 
 | ||||
| 	p.write([]byte("unset")) | ||||
| 	p.printFreeFloating(nn, token.Unset) | ||||
| 	p.write([]byte("(")) | ||||
| 	p.joinPrint(",", nn.Vars) | ||||
| 	p.printFreeFloating(nn, token.VarList) | ||||
| 	p.write([]byte(")")) | ||||
| 	p.printFreeFloating(nn, token.CloseParenthesisToken) | ||||
| 
 | ||||
| 	p.printFreeFloating(nn, token.SemiColon) | ||||
| 	if n.GetNode().Tokens.IsEmpty() { | ||||
| 		p.write([]byte(";")) | ||||
| 	} | ||||
| 
 | ||||
| 	p.printFreeFloating(nn, token.End) | ||||
| func (p *Printer) printStmtUnset(n *ast.StmtUnset) { | ||||
| 	p.printToken(n.UnsetTkn, "unset") | ||||
| 	p.printToken(n.OpenParenthesisTkn, "(") | ||||
| 	p.printSeparatedList(n.Vars, n.SeparatorTkns, ",") | ||||
| 	p.printToken(n.CloseParenthesisTkn, ")") | ||||
| 	p.printToken(n.SemiColonTkn, ";") | ||||
| } | ||||
| 
 | ||||
| func (p *Printer) printStmtUse(n *ast.StmtUse) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user