[refactoring] store colon as free-floating token
				
					
				
			This commit is contained in:
		
							parent
							
								
									48e0996a92
								
							
						
					
					
						commit
						b7d32b07bf
					
				
							
								
								
									
										676
									
								
								internal/php7/php7.go
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										676
									
								
								internal/php7/php7.go
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1453,9 +1453,6 @@ function_declaration_statement: | ||||
|                 } | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Name, $5.Tokens) | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.ParamList, $7.Tokens) | ||||
|                 if $8 != nil { | ||||
|                     yylex.(*Parser).setFreeFloatingTokens($$, token.Params, $8.GetNode().Tokens[token.Colon]); delete($8.GetNode().Tokens, token.Colon) | ||||
|                 } | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.ReturnType, $9.Tokens) | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Stmts, $11.Tokens) | ||||
| 
 | ||||
| @ -2286,7 +2283,7 @@ return_type: | ||||
|                 $$ = $2; | ||||
| 
 | ||||
|                 // save comments | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Colon, $1.Tokens) | ||||
|                 yylex.(*Parser).setFreeFloatingTokens($$, token.Start, append($1.Tokens, $$.GetNode().Tokens[token.Start]...)) | ||||
| 
 | ||||
|                 yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) | ||||
|             } | ||||
| @ -2540,9 +2537,6 @@ class_statement: | ||||
|                 } | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Name, $6.Tokens) | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.ParameterList, $8.Tokens) | ||||
|                 if $9 != nil { | ||||
|                     yylex.(*Parser).setFreeFloatingTokens($$, token.Params, $9.GetNode().Tokens[token.Colon]); delete($9.GetNode().Tokens, token.Colon) | ||||
|                 } | ||||
| 
 | ||||
|                 yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) | ||||
|             } | ||||
| @ -4150,9 +4144,6 @@ inline_function: | ||||
|                     yylex.(*Parser).setFreeFloating($$, token.Ampersand, $4.Tokens) | ||||
|                 } | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.ParameterList, $6.Tokens) | ||||
|                 if $8 != nil { | ||||
|                     yylex.(*Parser).setFreeFloatingTokens($$, token.LexicalVars, $8.GetNode().Tokens[token.Colon]); delete($8.GetNode().Tokens, token.Colon) | ||||
|                 } | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.ReturnType, $9.Tokens) | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.Stmts, $11.Tokens) | ||||
| 
 | ||||
| @ -4182,9 +4173,6 @@ inline_function: | ||||
|                     yylex.(*Parser).setFreeFloating($$, token.Ampersand, $3.Tokens) | ||||
|                 }; | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.ParameterList, $5.Tokens) | ||||
|                 if $6 != nil { | ||||
|                     yylex.(*Parser).setFreeFloatingTokens($$, token.Params, $6.GetNode().Tokens[token.Colon]); delete($6.GetNode().Tokens, token.Colon) | ||||
|                 }; | ||||
|                 yylex.(*Parser).setFreeFloating($$, token.ReturnType, $8.Tokens) | ||||
| 
 | ||||
|                 // normalize | ||||
|  | ||||
| @ -1409,7 +1409,7 @@ func (p *Printer) printExprArrowFunction(n ast.Vertex) { | ||||
| 	p.printFreeFloating(nn, token.Params) | ||||
| 
 | ||||
| 	if nn.ReturnType != nil { | ||||
| 		io.WriteString(p.w, ":") | ||||
| 		p.bufStart = ":" | ||||
| 		p.Print(nn.ReturnType) | ||||
| 	} | ||||
| 	p.printFreeFloating(nn, token.ReturnType) | ||||
| @ -1505,7 +1505,7 @@ func (p *Printer) printExprClosure(n ast.Vertex) { | ||||
| 	p.printFreeFloating(nn, token.LexicalVars) | ||||
| 
 | ||||
| 	if nn.ReturnType != nil { | ||||
| 		io.WriteString(p.w, ":") | ||||
| 		p.bufStart = ":" | ||||
| 		p.Print(nn.ReturnType) | ||||
| 	} | ||||
| 	p.printFreeFloating(nn, token.ReturnType) | ||||
| @ -2285,7 +2285,7 @@ func (p *Printer) printStmtClassMethod(n ast.Vertex) { | ||||
| 	p.printFreeFloating(nn, token.Params) | ||||
| 
 | ||||
| 	if nn.ReturnType != nil { | ||||
| 		io.WriteString(p.w, ":") | ||||
| 		p.bufStart = ":" | ||||
| 		p.Print(nn.ReturnType) | ||||
| 	} | ||||
| 
 | ||||
| @ -2703,7 +2703,7 @@ func (p *Printer) printStmtFunction(n ast.Vertex) { | ||||
| 	p.printFreeFloating(nn, token.Params) | ||||
| 
 | ||||
| 	if nn.ReturnType != nil { | ||||
| 		io.WriteString(p.w, ":") | ||||
| 		p.bufStart = ":" | ||||
| 		p.Print(nn.ReturnType) | ||||
| 	} | ||||
| 	p.printFreeFloating(nn, token.ReturnType) | ||||
|  | ||||
| @ -6,7 +6,6 @@ type Position int | ||||
| const ( | ||||
| 	Start Position = iota | ||||
| 	End | ||||
| 	Colon | ||||
| 	SemiColon | ||||
| 	AltEnd | ||||
| 	Dollar | ||||
|  | ||||
| @ -10,84 +10,83 @@ func _() { | ||||
| 	var x [1]struct{} | ||||
| 	_ = x[Start-0] | ||||
| 	_ = x[End-1] | ||||
| 	_ = x[Colon-2] | ||||
| 	_ = x[SemiColon-3] | ||||
| 	_ = x[AltEnd-4] | ||||
| 	_ = x[Dollar-5] | ||||
| 	_ = x[Ampersand-6] | ||||
| 	_ = x[Name-7] | ||||
| 	_ = x[Prefix-8] | ||||
| 	_ = x[Key-9] | ||||
| 	_ = x[Var-10] | ||||
| 	_ = x[UseType-11] | ||||
| 	_ = x[ReturnType-12] | ||||
| 	_ = x[OptionalType-13] | ||||
| 	_ = x[CaseSeparator-14] | ||||
| 	_ = x[LexicalVars-15] | ||||
| 	_ = x[Params-16] | ||||
| 	_ = x[Ref-17] | ||||
| 	_ = x[Cast-18] | ||||
| 	_ = x[Expr-19] | ||||
| 	_ = x[InitExpr-20] | ||||
| 	_ = x[CondExpr-21] | ||||
| 	_ = x[IncExpr-22] | ||||
| 	_ = x[True-23] | ||||
| 	_ = x[Cond-24] | ||||
| 	_ = x[HaltCompiller-25] | ||||
| 	_ = x[Namespace-26] | ||||
| 	_ = x[Static-27] | ||||
| 	_ = x[Class-28] | ||||
| 	_ = x[Use-29] | ||||
| 	_ = x[While-30] | ||||
| 	_ = x[For-31] | ||||
| 	_ = x[Switch-32] | ||||
| 	_ = x[Break-33] | ||||
| 	_ = x[Foreach-34] | ||||
| 	_ = x[Declare-35] | ||||
| 	_ = x[Label-36] | ||||
| 	_ = x[Finally-37] | ||||
| 	_ = x[List-38] | ||||
| 	_ = x[Default-39] | ||||
| 	_ = x[If-40] | ||||
| 	_ = x[ElseIf-41] | ||||
| 	_ = x[Else-42] | ||||
| 	_ = x[Variadic-43] | ||||
| 	_ = x[Function-44] | ||||
| 	_ = x[DoubleArrow-45] | ||||
| 	_ = x[Alias-46] | ||||
| 	_ = x[As-47] | ||||
| 	_ = x[Equal-48] | ||||
| 	_ = x[Exit-49] | ||||
| 	_ = x[Array-50] | ||||
| 	_ = x[Isset-51] | ||||
| 	_ = x[Empty-52] | ||||
| 	_ = x[Eval-53] | ||||
| 	_ = x[Echo-54] | ||||
| 	_ = x[Try-55] | ||||
| 	_ = x[Catch-56] | ||||
| 	_ = x[Unset-57] | ||||
| 	_ = x[Stmts-58] | ||||
| 	_ = x[VarList-59] | ||||
| 	_ = x[ConstList-60] | ||||
| 	_ = x[NameList-61] | ||||
| 	_ = x[ParamList-62] | ||||
| 	_ = x[ModifierList-63] | ||||
| 	_ = x[ArrayPairList-64] | ||||
| 	_ = x[CaseListStart-65] | ||||
| 	_ = x[CaseListEnd-66] | ||||
| 	_ = x[ArgumentList-67] | ||||
| 	_ = x[PropertyList-68] | ||||
| 	_ = x[ParameterList-69] | ||||
| 	_ = x[AdaptationList-70] | ||||
| 	_ = x[LexicalVarList-71] | ||||
| 	_ = x[UseDeclarationList-72] | ||||
| 	_ = x[OpenParenthesisToken-73] | ||||
| 	_ = x[CloseParenthesisToken-74] | ||||
| 	_ = x[SemiColon-2] | ||||
| 	_ = x[AltEnd-3] | ||||
| 	_ = x[Dollar-4] | ||||
| 	_ = x[Ampersand-5] | ||||
| 	_ = x[Name-6] | ||||
| 	_ = x[Prefix-7] | ||||
| 	_ = x[Key-8] | ||||
| 	_ = x[Var-9] | ||||
| 	_ = x[UseType-10] | ||||
| 	_ = x[ReturnType-11] | ||||
| 	_ = x[OptionalType-12] | ||||
| 	_ = x[CaseSeparator-13] | ||||
| 	_ = x[LexicalVars-14] | ||||
| 	_ = x[Params-15] | ||||
| 	_ = x[Ref-16] | ||||
| 	_ = x[Cast-17] | ||||
| 	_ = x[Expr-18] | ||||
| 	_ = x[InitExpr-19] | ||||
| 	_ = x[CondExpr-20] | ||||
| 	_ = x[IncExpr-21] | ||||
| 	_ = x[True-22] | ||||
| 	_ = x[Cond-23] | ||||
| 	_ = x[HaltCompiller-24] | ||||
| 	_ = x[Namespace-25] | ||||
| 	_ = x[Static-26] | ||||
| 	_ = x[Class-27] | ||||
| 	_ = x[Use-28] | ||||
| 	_ = x[While-29] | ||||
| 	_ = x[For-30] | ||||
| 	_ = x[Switch-31] | ||||
| 	_ = x[Break-32] | ||||
| 	_ = x[Foreach-33] | ||||
| 	_ = x[Declare-34] | ||||
| 	_ = x[Label-35] | ||||
| 	_ = x[Finally-36] | ||||
| 	_ = x[List-37] | ||||
| 	_ = x[Default-38] | ||||
| 	_ = x[If-39] | ||||
| 	_ = x[ElseIf-40] | ||||
| 	_ = x[Else-41] | ||||
| 	_ = x[Variadic-42] | ||||
| 	_ = x[Function-43] | ||||
| 	_ = x[DoubleArrow-44] | ||||
| 	_ = x[Alias-45] | ||||
| 	_ = x[As-46] | ||||
| 	_ = x[Equal-47] | ||||
| 	_ = x[Exit-48] | ||||
| 	_ = x[Array-49] | ||||
| 	_ = x[Isset-50] | ||||
| 	_ = x[Empty-51] | ||||
| 	_ = x[Eval-52] | ||||
| 	_ = x[Echo-53] | ||||
| 	_ = x[Try-54] | ||||
| 	_ = x[Catch-55] | ||||
| 	_ = x[Unset-56] | ||||
| 	_ = x[Stmts-57] | ||||
| 	_ = x[VarList-58] | ||||
| 	_ = x[ConstList-59] | ||||
| 	_ = x[NameList-60] | ||||
| 	_ = x[ParamList-61] | ||||
| 	_ = x[ModifierList-62] | ||||
| 	_ = x[ArrayPairList-63] | ||||
| 	_ = x[CaseListStart-64] | ||||
| 	_ = x[CaseListEnd-65] | ||||
| 	_ = x[ArgumentList-66] | ||||
| 	_ = x[PropertyList-67] | ||||
| 	_ = x[ParameterList-68] | ||||
| 	_ = x[AdaptationList-69] | ||||
| 	_ = x[LexicalVarList-70] | ||||
| 	_ = x[UseDeclarationList-71] | ||||
| 	_ = x[OpenParenthesisToken-72] | ||||
| 	_ = x[CloseParenthesisToken-73] | ||||
| } | ||||
| 
 | ||||
| const _Position_name = "StartEndColonSemiColonAltEndDollarAmpersandNamePrefixKeyVarUseTypeReturnTypeOptionalTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchBreakForeachDeclareLabelFinallyListDefaultIfElseIfElseVariadicFunctionDoubleArrowAliasAsEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListUseDeclarationListOpenParenthesisTokenCloseParenthesisToken" | ||||
| const _Position_name = "StartEndSemiColonAltEndDollarAmpersandNamePrefixKeyVarUseTypeReturnTypeOptionalTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchBreakForeachDeclareLabelFinallyListDefaultIfElseIfElseVariadicFunctionDoubleArrowAliasAsEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListUseDeclarationListOpenParenthesisTokenCloseParenthesisToken" | ||||
| 
 | ||||
| var _Position_index = [...]uint16{0, 5, 8, 13, 22, 28, 34, 43, 47, 53, 56, 59, 66, 76, 88, 101, 112, 118, 121, 125, 129, 137, 145, 152, 156, 160, 173, 182, 188, 193, 196, 201, 204, 210, 215, 222, 229, 234, 241, 245, 252, 254, 260, 264, 272, 280, 291, 296, 298, 303, 307, 312, 317, 322, 326, 330, 333, 338, 343, 348, 355, 364, 372, 381, 393, 406, 419, 430, 442, 454, 467, 481, 495, 513, 533, 554} | ||||
| var _Position_index = [...]uint16{0, 5, 8, 17, 23, 29, 38, 42, 48, 51, 54, 61, 71, 83, 96, 107, 113, 116, 120, 124, 132, 140, 147, 151, 155, 168, 177, 183, 188, 191, 196, 199, 205, 210, 217, 224, 229, 236, 240, 247, 249, 255, 259, 267, 275, 286, 291, 293, 298, 302, 307, 312, 317, 321, 325, 328, 333, 338, 343, 350, 359, 367, 376, 388, 401, 414, 425, 437, 449, 462, 476, 490, 508, 528, 549} | ||||
| 
 | ||||
| func (i Position) String() string { | ||||
| 	if i < 0 || i >= Position(len(_Position_index)-1) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user