php5: save all comments
This commit is contained in:
		
							parent
							
								
									deccf266d9
								
							
						
					
					
						commit
						944a343f0f
					
				| @ -106,3 +106,13 @@ func (l *Parser) GetComments() parser.Comments { | |||||||
| func (l *Parser) GetPositions() parser.Positions { | func (l *Parser) GetPositions() parser.Positions { | ||||||
| 	return l.positions | 	return l.positions | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // helpers | ||||||
|  | 
 | ||||||
|  | func lastNode(nn []node.Node) node.Node { | ||||||
|  | 	return nn[len(nn)-1] | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func firstNode(nn []node.Node) node.Node { | ||||||
|  | 	return nn[0] | ||||||
|  | } | ||||||
|  | |||||||
							
								
								
									
										5888
									
								
								php5/php5.go
									
									
									
									
									
								
							
							
						
						
									
										5888
									
								
								php5/php5.go
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										3026
									
								
								php5/php5.y
									
									
									
									
									
								
							
							
						
						
									
										3026
									
								
								php5/php5.y
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -96,11 +96,6 @@ func (l *Parser) GetPositions() parser.Positions { | |||||||
| 	return l.positions | 	return l.positions | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (l *Parser) setCommentsFromChildNode(n node.Node, c node.Node) { |  | ||||||
| 	l.comments.AddComments(n, l.comments[c]) |  | ||||||
| 	delete(l.comments, c) |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // helpers | // helpers | ||||||
| 
 | 
 | ||||||
| func lastNode(nn []node.Node) node.Node { | func lastNode(nn []node.Node) node.Node { | ||||||
|  | |||||||
							
								
								
									
										580
									
								
								php7/php7.go
									
									
									
									
									
								
							
							
						
						
									
										580
									
								
								php7/php7.go
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										33
									
								
								php7/php7.y
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								php7/php7.y
									
									
									
									
									
								
							| @ -1694,16 +1694,7 @@ parameter: | |||||||
|             { |             { | ||||||
|                 identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) |                 identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) | ||||||
|                 variable := expr.NewVariable(identifier) |                 variable := expr.NewVariable(identifier) | ||||||
| 
 |                 $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) | ||||||
|                 if $1 != nil { |  | ||||||
|                     $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) |  | ||||||
|                 } else if $2 != nil { |  | ||||||
|                     $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) |  | ||||||
|                 } else if $3 != nil { |  | ||||||
|                     $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) |  | ||||||
|                 } else { |  | ||||||
|                     $$ = node.NewParameter($1, variable, nil, $2 != nil, $3 != nil) |  | ||||||
|                 } |  | ||||||
| 
 | 
 | ||||||
|                 // save position |                 // save position | ||||||
|                 yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) |                 yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) | ||||||
| @ -1731,15 +1722,7 @@ parameter: | |||||||
|             { |             { | ||||||
|                 identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) |                 identifier := node.NewIdentifier(strings.TrimLeft($4.Value, "$")) | ||||||
|                 variable := expr.NewVariable(identifier) |                 variable := expr.NewVariable(identifier) | ||||||
|                 if $1 != nil { |                 $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) | ||||||
|                     $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) |  | ||||||
|                 } else if $2 != nil { |  | ||||||
|                     $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) |  | ||||||
|                 } else if $3 != nil { |  | ||||||
|                     $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) |  | ||||||
|                 } else { |  | ||||||
|                     $$ = node.NewParameter($1, variable, $6, $2 != nil, $3 != nil) |  | ||||||
|                 } |  | ||||||
| 
 | 
 | ||||||
|                 // save position |                 // save position | ||||||
|                 yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) |                 yylex.(*Parser).positions.AddPosition(identifier, yylex.(*Parser).positionBuilder.NewTokenPosition($4)) | ||||||
| @ -1832,6 +1815,10 @@ argument_list: | |||||||
| 
 | 
 | ||||||
|                 // save position |                 // save position | ||||||
|                 yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) |                 yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2)) | ||||||
|  | 
 | ||||||
|  |                 // save comments | ||||||
|  |                 yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) | ||||||
|  |                 yylex.(*Parser).comments.AddFromToken($$, $2, comment.CloseParenthesisToken) | ||||||
|             } |             } | ||||||
|     |   '(' non_empty_argument_list possible_comma ')' |     |   '(' non_empty_argument_list possible_comma ')' | ||||||
|             { |             { | ||||||
| @ -1839,6 +1826,13 @@ argument_list: | |||||||
| 
 | 
 | ||||||
|                 // save position |                 // save position | ||||||
|                 yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) |                 yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $4)) | ||||||
|  | 
 | ||||||
|  |                 // save comments | ||||||
|  |                 yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenParenthesisToken) | ||||||
|  |                 if $3 != nil { | ||||||
|  |                     yylex.(*Parser).comments.AddFromToken($$, $3, comment.CommaToken) | ||||||
|  |                 } | ||||||
|  |                 yylex.(*Parser).comments.AddFromToken($$, $4, comment.CloseParenthesisToken) | ||||||
|             } |             } | ||||||
| ; | ; | ||||||
| 
 | 
 | ||||||
| @ -4138,6 +4132,7 @@ encaps_var: | |||||||
|                 $$ = $2; |                 $$ = $2; | ||||||
|             } |             } | ||||||
| ; | ; | ||||||
|  | 
 | ||||||
| encaps_var_offset: | encaps_var_offset: | ||||||
|         T_STRING |         T_STRING | ||||||
|             { |             { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user