[refactoring] update ast structure of "StmtExpression", "StmtInterface" and "StmtProperty" nodes
This commit is contained in:
		
							parent
							
								
									2d6ae3a9a2
								
							
						
					
					
						commit
						5bd63d90ba
					
				
							
								
								
									
										1200
									
								
								internal/php5/php5.go
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1200
									
								
								internal/php5/php5.go
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1033,15 +1033,13 @@ unticked_statement: | |||||||
|             } |             } | ||||||
|     |   yield_expr ';' |     |   yield_expr ';' | ||||||
|             { |             { | ||||||
|                 $$ = &ast.StmtExpression{ast.Node{}, $1} |                 $$ = &ast.StmtExpression{ | ||||||
| 
 |                     Node: ast.Node{ | ||||||
|                 // save position |                         Position: position.NewNodeTokenPosition($1, $2), | ||||||
|                 $$.GetNode().Position = position.NewNodeTokenPosition($1, $2) |                     }, | ||||||
| 
 |                     Expr:         $1, | ||||||
|                 // save comments |                     SemiColonTkn: $2, | ||||||
|                 yylex.(*Parser).MoveFreeFloating($1, $$) |                 } | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setToken($$, token.SemiColon, $2.SkippedTokens) |  | ||||||
|             } |             } | ||||||
|     |   T_GLOBAL global_var_list ';' |     |   T_GLOBAL global_var_list ';' | ||||||
|             { |             { | ||||||
| @ -1081,15 +1079,13 @@ unticked_statement: | |||||||
|             } |             } | ||||||
|     |   expr ';' |     |   expr ';' | ||||||
|             { |             { | ||||||
|                 $$ = &ast.StmtExpression{ast.Node{}, $1} |                 $$ = &ast.StmtExpression{ | ||||||
| 
 |                     Node: ast.Node{ | ||||||
|                 // save position |                         Position: position.NewNodeTokenPosition($1, $2), | ||||||
|                 $$.GetNode().Position = position.NewNodeTokenPosition($1, $2) |                     }, | ||||||
| 
 |                     Expr:         $1, | ||||||
|                 // save comments |                     SemiColonTkn: $2, | ||||||
|                 yylex.(*Parser).MoveFreeFloating($1, $$) |                 } | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setToken($$, token.SemiColon, $2.SkippedTokens) |  | ||||||
|             } |             } | ||||||
|     |   T_UNSET '(' unset_variables ')' ';' |     |   T_UNSET '(' unset_variables ')' ';' | ||||||
|             { |             { | ||||||
| @ -1439,22 +1435,23 @@ unticked_class_declaration_statement: | |||||||
|             } |             } | ||||||
|     |   interface_entry T_STRING interface_extends_list '{' class_statement_list '}' |     |   interface_entry T_STRING interface_extends_list '{' class_statement_list '}' | ||||||
|             { |             { | ||||||
|                 name := &ast.Identifier{ |                 $$ = &ast.StmtInterface{ | ||||||
|  |                     Node: ast.Node{ | ||||||
|  |                         Position: position.NewTokensPosition($1, $6), | ||||||
|  |                     }, | ||||||
|  |                     InterfaceTkn: $1, | ||||||
|  |                     InterfaceName: &ast.Identifier{ | ||||||
|                         Node: ast.Node{ |                         Node: ast.Node{ | ||||||
|                             Position: position.NewTokenPosition($2), |                             Position: position.NewTokenPosition($2), | ||||||
|                         }, |                         }, | ||||||
|                         IdentifierTkn: $2, |                         IdentifierTkn: $2, | ||||||
|                         Value:         $2.Value, |                         Value:         $2.Value, | ||||||
|  |                     }, | ||||||
|  |                     Extends:              $3, | ||||||
|  |                     OpenCurlyBracketTkn:  $4, | ||||||
|  |                     Stmts:                $5, | ||||||
|  |                     CloseCurlyBracketTkn: $6, | ||||||
|                 } |                 } | ||||||
|                 $$ = &ast.StmtInterface{ast.Node{}, name, $3, $5} |  | ||||||
| 
 |  | ||||||
|                 // save position |  | ||||||
|                 $$.GetNode().Position = position.NewTokensPosition($1, $6) |  | ||||||
| 
 |  | ||||||
|                 // save comments |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Name, $4.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Stmts, $6.SkippedTokens) |  | ||||||
|             } |             } | ||||||
| ; | ; | ||||||
| 
 | 
 | ||||||
| @ -2851,87 +2848,92 @@ member_modifier: | |||||||
| class_variable_declaration: | class_variable_declaration: | ||||||
|         class_variable_declaration ',' T_VARIABLE |         class_variable_declaration ',' T_VARIABLE | ||||||
|             { |             { | ||||||
|                 identifier := &ast.Identifier{ |                 $$ = append($1, &ast.StmtProperty{ | ||||||
|  |                     Node: ast.Node{ | ||||||
|  |                         Position: position.NewTokenPosition($3), | ||||||
|  |                     }, | ||||||
|  |                     Var: &ast.ExprVariable{ | ||||||
|  |                         Node: ast.Node{ | ||||||
|  |                             Position: position.NewTokenPosition($3), | ||||||
|  |                         }, | ||||||
|  |                         VarName: &ast.Identifier{ | ||||||
|                             Node: ast.Node{ |                             Node: ast.Node{ | ||||||
|                                 Position: position.NewTokenPosition($3), |                                 Position: position.NewTokenPosition($3), | ||||||
|                             }, |                             }, | ||||||
|                             IdentifierTkn: $3, |                             IdentifierTkn: $3, | ||||||
|                             Value:         $3.Value, |                             Value:         $3.Value, | ||||||
|                 } |                         }, | ||||||
|                 variable := &ast.ExprVariable{ast.Node{}, identifier} |                     }, | ||||||
|                 property := &ast.StmtProperty{ast.Node{}, variable, nil} |                 }) | ||||||
|                 $$ = append($1, property) |  | ||||||
| 
 |  | ||||||
|                 // save position |  | ||||||
|                 variable.GetNode().Position = position.NewTokenPosition($3) |  | ||||||
|                 property.GetNode().Position = position.NewTokenPosition($3) |  | ||||||
| 
 |  | ||||||
|                 // save comments |  | ||||||
|                 yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating(property, token.Start, $3.SkippedTokens) |  | ||||||
|             } |             } | ||||||
|     |   class_variable_declaration ',' T_VARIABLE '=' static_scalar |     |   class_variable_declaration ',' T_VARIABLE '=' static_scalar | ||||||
|             { |             { | ||||||
|                 identifier := &ast.Identifier{ |                 $$ = append($1, &ast.StmtProperty{ | ||||||
|  |                     Node: ast.Node{ | ||||||
|  |                         Position: position.NewTokenNodePosition($3, $5), | ||||||
|  |                     }, | ||||||
|  |                     Var: &ast.ExprVariable{ | ||||||
|  |                         Node: ast.Node{ | ||||||
|  |                             Position: position.NewTokenPosition($3), | ||||||
|  |                         }, | ||||||
|  |                         VarName: &ast.Identifier{ | ||||||
|                             Node: ast.Node{ |                             Node: ast.Node{ | ||||||
|                                 Position: position.NewTokenPosition($3), |                                 Position: position.NewTokenPosition($3), | ||||||
|                             }, |                             }, | ||||||
|                             IdentifierTkn: $3, |                             IdentifierTkn: $3, | ||||||
|                             Value:         $3.Value, |                             Value:         $3.Value, | ||||||
|                 } |                         }, | ||||||
|                 variable := &ast.ExprVariable{ast.Node{}, identifier} |                     }, | ||||||
|                 property := &ast.StmtProperty{ast.Node{}, variable, $5} |                     EqualTkn: $4, | ||||||
|                 $$ = append($1, property) |                     Expr:     $5, | ||||||
| 
 |                 }) | ||||||
|                 // save position |  | ||||||
|                 variable.GetNode().Position = position.NewTokenPosition($3) |  | ||||||
|                 property.GetNode().Position = position.NewTokenNodePosition($3, $5) |  | ||||||
| 
 |  | ||||||
|                 // save comments |  | ||||||
|                 yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating(property, token.Start, $3.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating(property, token.Var, $4.SkippedTokens) |  | ||||||
|             } |             } | ||||||
|     |   T_VARIABLE |     |   T_VARIABLE | ||||||
|             { |             { | ||||||
|                 identifier := &ast.Identifier{ |                 $$ = []ast.Vertex{ | ||||||
|  |                     &ast.StmtProperty{ | ||||||
|  |                         Node: ast.Node{ | ||||||
|  |                             Position: position.NewTokenPosition($1), | ||||||
|  |                         }, | ||||||
|  |                         Var: &ast.ExprVariable{ | ||||||
|  |                             Node: ast.Node{ | ||||||
|  |                                 Position: position.NewTokenPosition($1), | ||||||
|  |                             }, | ||||||
|  |                             VarName: &ast.Identifier{ | ||||||
|                                 Node: ast.Node{ |                                 Node: ast.Node{ | ||||||
|                                     Position: position.NewTokenPosition($1), |                                     Position: position.NewTokenPosition($1), | ||||||
|                                 }, |                                 }, | ||||||
|                                 IdentifierTkn: $1, |                                 IdentifierTkn: $1, | ||||||
|                                 Value:         $1.Value, |                                 Value:         $1.Value, | ||||||
|  |                             }, | ||||||
|  |                         }, | ||||||
|  |                         Expr: nil, | ||||||
|  |                     }, | ||||||
|                 } |                 } | ||||||
|                 variable := &ast.ExprVariable{ast.Node{}, identifier} |  | ||||||
|                 property := &ast.StmtProperty{ast.Node{}, variable, nil} |  | ||||||
|                 $$ = []ast.Vertex{property} |  | ||||||
| 
 |  | ||||||
|                 // save position |  | ||||||
|                 variable.GetNode().Position = position.NewTokenPosition($1) |  | ||||||
|                 property.GetNode().Position = position.NewTokenPosition($1) |  | ||||||
| 
 |  | ||||||
|                 // save comments |  | ||||||
|                 yylex.(*Parser).setFreeFloating(property, token.Start, $1.SkippedTokens) |  | ||||||
|             } |             } | ||||||
|     |   T_VARIABLE '=' static_scalar |     |   T_VARIABLE '=' static_scalar | ||||||
|             { |             { | ||||||
|                 identifier := &ast.Identifier{ |                 $$ = []ast.Vertex{ | ||||||
|  |                     &ast.StmtProperty{ | ||||||
|  |                         Node: ast.Node{ | ||||||
|  |                             Position: position.NewTokenNodePosition($1, $3), | ||||||
|  |                         }, | ||||||
|  |                         Var: &ast.ExprVariable{ | ||||||
|  |                             Node: ast.Node{ | ||||||
|  |                                 Position: position.NewTokenPosition($1), | ||||||
|  |                             }, | ||||||
|  |                             VarName: &ast.Identifier{ | ||||||
|                                 Node: ast.Node{ |                                 Node: ast.Node{ | ||||||
|                                     Position: position.NewTokenPosition($1), |                                     Position: position.NewTokenPosition($1), | ||||||
|                                 }, |                                 }, | ||||||
|                                 IdentifierTkn: $1, |                                 IdentifierTkn: $1, | ||||||
|                                 Value:         $1.Value, |                                 Value:         $1.Value, | ||||||
|  |                             }, | ||||||
|  |                         }, | ||||||
|  |                         EqualTkn: $2, | ||||||
|  |                         Expr:     $3, | ||||||
|  |                     }, | ||||||
|                 } |                 } | ||||||
|                 variable := &ast.ExprVariable{ast.Node{}, identifier} |  | ||||||
|                 property := &ast.StmtProperty{ast.Node{}, variable, $3} |  | ||||||
|                 $$ = []ast.Vertex{property} |  | ||||||
| 
 |  | ||||||
|                 // save position |  | ||||||
|                 variable.GetNode().Position = position.NewTokenPosition($1) |  | ||||||
|                 property.GetNode().Position = position.NewTokenNodePosition($1, $3) |  | ||||||
| 
 |  | ||||||
|                 // save comments |  | ||||||
|                 yylex.(*Parser).setFreeFloating(property, token.Start, $2.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating(property, token.Var, $2.SkippedTokens) |  | ||||||
|             } |             } | ||||||
| ; | ; | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										1071
									
								
								internal/php7/php7.go
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1071
									
								
								internal/php7/php7.go
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -989,15 +989,13 @@ statement: | |||||||
|             } |             } | ||||||
|     |   expr ';' |     |   expr ';' | ||||||
|             { |             { | ||||||
|                 $$ = &ast.StmtExpression{ast.Node{}, $1} |                 $$ = &ast.StmtExpression{ | ||||||
| 
 |                     Node: ast.Node{ | ||||||
|                 // save position |                         Position: position.NewNodeTokenPosition($1, $2), | ||||||
|                 $$.GetNode().Position = position.NewNodeTokenPosition($1, $2) |                     }, | ||||||
| 
 |                     Expr:         $1, | ||||||
|                 // save comments |                     SemiColonTkn: $2, | ||||||
|                 yylex.(*Parser).MoveFreeFloating($1, $$) |                 } | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setToken($$, token.SemiColon, $2.SkippedTokens) |  | ||||||
|             } |             } | ||||||
|     |   T_UNSET '(' unset_variables possible_comma ')' ';' |     |   T_UNSET '(' unset_variables possible_comma ')' ';' | ||||||
|             { |             { | ||||||
| @ -1366,22 +1364,23 @@ trait_declaration_statement: | |||||||
| interface_declaration_statement: | interface_declaration_statement: | ||||||
|         T_INTERFACE T_STRING interface_extends_list backup_doc_comment '{' class_statement_list '}' |         T_INTERFACE T_STRING interface_extends_list backup_doc_comment '{' class_statement_list '}' | ||||||
|             { |             { | ||||||
|                 name := &ast.Identifier{ |                 $$ = &ast.StmtInterface{ | ||||||
|  |                     Node: ast.Node{ | ||||||
|  |                         Position: position.NewTokensPosition($1, $7), | ||||||
|  |                     }, | ||||||
|  |                     InterfaceTkn: $1, | ||||||
|  |                     InterfaceName: &ast.Identifier{ | ||||||
|                         Node: ast.Node{ |                         Node: ast.Node{ | ||||||
|                             Position: position.NewTokenPosition($2), |                             Position: position.NewTokenPosition($2), | ||||||
|                         }, |                         }, | ||||||
|                         IdentifierTkn: $2, |                         IdentifierTkn: $2, | ||||||
|                         Value:         $2.Value, |                         Value:         $2.Value, | ||||||
|  |                     }, | ||||||
|  |                     Extends:              $3, | ||||||
|  |                     OpenCurlyBracketTkn:  $5, | ||||||
|  |                     Stmts:                $6, | ||||||
|  |                     CloseCurlyBracketTkn: $7, | ||||||
|                 } |                 } | ||||||
|                 $$ = &ast.StmtInterface{ast.Node{}, name, $3, $6} |  | ||||||
| 
 |  | ||||||
|                 // save position |  | ||||||
|                 $$.GetNode().Position = position.NewTokensPosition($1, $7) |  | ||||||
| 
 |  | ||||||
|                 // save comments |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Name, $5.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Stmts, $7.SkippedTokens) |  | ||||||
|             } |             } | ||||||
| ; | ; | ||||||
| 
 | 
 | ||||||
| @ -2609,42 +2608,46 @@ property_list: | |||||||
| property: | property: | ||||||
|         T_VARIABLE backup_doc_comment |         T_VARIABLE backup_doc_comment | ||||||
|             { |             { | ||||||
|                 identifier := &ast.Identifier{ |                 $$ = &ast.StmtProperty{ | ||||||
|  |                     Node: ast.Node{ | ||||||
|  |                         Position: position.NewTokenPosition($1), | ||||||
|  |                     }, | ||||||
|  |                     Var: &ast.ExprVariable{ | ||||||
|  |                         Node: ast.Node{ | ||||||
|  |                             Position: position.NewTokenPosition($1), | ||||||
|  |                         }, | ||||||
|  |                         VarName: &ast.Identifier{ | ||||||
|                             Node: ast.Node{ |                             Node: ast.Node{ | ||||||
|                                 Position: position.NewTokenPosition($1), |                                 Position: position.NewTokenPosition($1), | ||||||
|                             }, |                             }, | ||||||
|                             IdentifierTkn: $1, |                             IdentifierTkn: $1, | ||||||
|                             Value:         $1.Value, |                             Value:         $1.Value, | ||||||
|  |                         }, | ||||||
|  |                     }, | ||||||
|  |                     Expr: nil, | ||||||
|                 } |                 } | ||||||
|                 variable := &ast.ExprVariable{ast.Node{}, identifier} |  | ||||||
|                 $$ = &ast.StmtProperty{ast.Node{}, variable, nil} |  | ||||||
| 
 |  | ||||||
|                 // save position |  | ||||||
|                 variable.GetNode().Position = position.NewTokenPosition($1) |  | ||||||
|                 $$.GetNode().Position = position.NewTokenPosition($1) |  | ||||||
| 
 |  | ||||||
|                 // save comments |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) |  | ||||||
|             } |             } | ||||||
|     |   T_VARIABLE '=' expr backup_doc_comment |     |   T_VARIABLE '=' expr backup_doc_comment | ||||||
|             { |             { | ||||||
|                 identifier := &ast.Identifier{ |                 $$ = &ast.StmtProperty{ | ||||||
|  |                     Node: ast.Node{ | ||||||
|  |                         Position: position.NewTokenNodePosition($1, $3), | ||||||
|  |                     }, | ||||||
|  |                     Var: &ast.ExprVariable{ | ||||||
|  |                         Node: ast.Node{ | ||||||
|  |                             Position: position.NewTokenPosition($1), | ||||||
|  |                         }, | ||||||
|  |                         VarName: &ast.Identifier{ | ||||||
|                             Node: ast.Node{ |                             Node: ast.Node{ | ||||||
|                                 Position: position.NewTokenPosition($1), |                                 Position: position.NewTokenPosition($1), | ||||||
|                             }, |                             }, | ||||||
|                             IdentifierTkn: $1, |                             IdentifierTkn: $1, | ||||||
|                             Value:         $1.Value, |                             Value:         $1.Value, | ||||||
|  |                         }, | ||||||
|  |                     }, | ||||||
|  |                     EqualTkn: $2, | ||||||
|  |                     Expr:     $3, | ||||||
|                 } |                 } | ||||||
|                 variable := &ast.ExprVariable{ast.Node{}, identifier} |  | ||||||
|                 $$ = &ast.StmtProperty{ast.Node{}, variable, $3} |  | ||||||
| 
 |  | ||||||
|                 // save position |  | ||||||
|                 variable.GetNode().Position = position.NewTokenPosition($1) |  | ||||||
|                 $$.GetNode().Position = position.NewTokenNodePosition($1, $3) |  | ||||||
| 
 |  | ||||||
|                 // save comments |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) |  | ||||||
|                 yylex.(*Parser).setFreeFloating($$, token.Var, $2.SkippedTokens) |  | ||||||
|             } |             } | ||||||
| ; | ; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -439,6 +439,7 @@ func (n *StmtElseIf) Accept(v NodeVisitor) { | |||||||
| type StmtExpression struct { | type StmtExpression struct { | ||||||
| 	Node | 	Node | ||||||
| 	Expr         Vertex | 	Expr         Vertex | ||||||
|  | 	SemiColonTkn *token.Token | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (n *StmtExpression) Accept(v NodeVisitor) { | func (n *StmtExpression) Accept(v NodeVisitor) { | ||||||
| @ -594,9 +595,12 @@ func (n *StmtInlineHtml) Accept(v NodeVisitor) { | |||||||
| // StmtInterface node | // StmtInterface node | ||||||
| type StmtInterface struct { | type StmtInterface struct { | ||||||
| 	Node | 	Node | ||||||
|  | 	InterfaceTkn         *token.Token | ||||||
| 	InterfaceName        Vertex | 	InterfaceName        Vertex | ||||||
| 	Extends              Vertex | 	Extends              Vertex | ||||||
|  | 	OpenCurlyBracketTkn  *token.Token | ||||||
| 	Stmts                []Vertex | 	Stmts                []Vertex | ||||||
|  | 	CloseCurlyBracketTkn *token.Token | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (n *StmtInterface) Accept(v NodeVisitor) { | func (n *StmtInterface) Accept(v NodeVisitor) { | ||||||
| @ -655,6 +659,7 @@ func (n *StmtNop) Accept(v NodeVisitor) { | |||||||
| type StmtProperty struct { | type StmtProperty struct { | ||||||
| 	Node | 	Node | ||||||
| 	Var      Vertex | 	Var      Vertex | ||||||
|  | 	EqualTkn *token.Token | ||||||
| 	Expr     Vertex | 	Expr     Vertex | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user