[refactoring] store argument list parenthesis

This commit is contained in:
Vadym Slizov 2020-08-09 01:37:09 +02:00
parent fd5d891037
commit 4aae540aad
7 changed files with 29 additions and 46 deletions

BIN
internal/php5/php5.go generated

Binary file not shown.

View File

@ -2404,8 +2404,8 @@ function_call_parameter_list:
$$.GetNode().Position = position.NewTokensPosition($1, $2) $$.GetNode().Position = position.NewTokensPosition($1, $2)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.ArgumentList, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $2.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -2417,8 +2417,8 @@ function_call_parameter_list:
$$.GetNode().Position = position.NewTokensPosition($1, $3) $$.GetNode().Position = position.NewTokensPosition($1, $3)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.ArgumentList, $3.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -2432,8 +2432,8 @@ function_call_parameter_list:
$$.GetNode().Position = position.NewTokensPosition($1, $3) $$.GetNode().Position = position.NewTokensPosition($1, $3)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.ArgumentList, $3.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }

BIN
internal/php7/php7.go generated

Binary file not shown.

View File

@ -2318,8 +2318,8 @@ argument_list:
$$.GetNode().Position = position.NewTokensPosition($1, $2) $$.GetNode().Position = position.NewTokensPosition($1, $2)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloating($$, token.ArgumentList, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $2.Tokens)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
@ -2331,11 +2331,11 @@ argument_list:
$$.GetNode().Position = position.NewTokensPosition($1, $4) $$.GetNode().Position = position.NewTokensPosition($1, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Start, $1.Tokens)
if $3 != nil { if $3 != nil {
yylex.(*Parser).setFreeFloating($$, token.ArgumentList, append($3.Tokens, $4.Tokens...)) yylex.(*Parser).setFreeFloatingTokens($$, token.End, append($3.Tokens, $4.Tokens...))
} else { } else {
yylex.(*Parser).setFreeFloating($$, token.ArgumentList, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.Tokens)
} }
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)

View File

@ -1587,12 +1587,9 @@ func (p *Printer) printExprFunctionCall(n ast.Vertex) {
p.Print(nn.Function) p.Print(nn.Function)
p.printFreeFloating(nn.ArgumentList, token.Start) p.printFreeFloatingOrDefault(nn.ArgumentList, token.Start, "(")
io.WriteString(p.w, "(")
p.joinPrint(",", nn.ArgumentList.Arguments) p.joinPrint(",", nn.ArgumentList.Arguments)
p.printFreeFloating(nn.ArgumentList, token.ArgumentList) p.printFreeFloatingOrDefault(nn.ArgumentList, token.End, ")")
io.WriteString(p.w, ")")
p.printFreeFloating(nn.ArgumentList, token.End)
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
@ -1674,12 +1671,9 @@ func (p *Printer) printExprMethodCall(n ast.Vertex) {
io.WriteString(p.w, "->") io.WriteString(p.w, "->")
p.Print(nn.Method) p.Print(nn.Method)
p.printFreeFloating(nn.ArgumentList, token.Start) p.printFreeFloatingOrDefault(nn.ArgumentList, token.Start, "(")
io.WriteString(p.w, "(")
p.joinPrint(",", nn.ArgumentList.Arguments) p.joinPrint(",", nn.ArgumentList.Arguments)
p.printFreeFloating(nn.ArgumentList, token.ArgumentList) p.printFreeFloatingOrDefault(nn.ArgumentList, token.End, ")")
io.WriteString(p.w, ")")
p.printFreeFloating(nn.ArgumentList, token.End)
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
@ -1693,12 +1687,9 @@ func (p *Printer) printExprNew(n ast.Vertex) {
p.Print(nn.Class) p.Print(nn.Class)
if nn.ArgumentList != nil { if nn.ArgumentList != nil {
p.printFreeFloating(nn.ArgumentList, token.Start) p.printFreeFloatingOrDefault(nn.ArgumentList, token.Start, "(")
io.WriteString(p.w, "(")
p.joinPrint(",", nn.ArgumentList.Arguments) p.joinPrint(",", nn.ArgumentList.Arguments)
p.printFreeFloating(nn.ArgumentList, token.ArgumentList) p.printFreeFloatingOrDefault(nn.ArgumentList, token.End, ")")
io.WriteString(p.w, ")")
p.printFreeFloating(nn.ArgumentList, token.End)
} }
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
@ -1851,12 +1842,9 @@ func (p *Printer) printExprStaticCall(n ast.Vertex) {
io.WriteString(p.w, "::") io.WriteString(p.w, "::")
p.Print(nn.Call) p.Print(nn.Call)
p.printFreeFloating(nn.ArgumentList, token.Start) p.printFreeFloatingOrDefault(nn.ArgumentList, token.Start, "(")
io.WriteString(p.w, "(")
p.joinPrint(",", nn.ArgumentList.Arguments) p.joinPrint(",", nn.ArgumentList.Arguments)
p.printFreeFloating(nn.ArgumentList, token.ArgumentList) p.printFreeFloatingOrDefault(nn.ArgumentList, token.End, ")")
io.WriteString(p.w, ")")
p.printFreeFloating(nn.ArgumentList, token.End)
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
@ -2320,12 +2308,9 @@ func (p *Printer) printStmtClass(n ast.Vertex) {
} }
if nn.ArgumentList != nil { if nn.ArgumentList != nil {
p.printFreeFloating(nn.ArgumentList, token.Start) p.printFreeFloatingOrDefault(nn.ArgumentList, token.Start, "(")
io.WriteString(p.w, "(")
p.joinPrint(",", nn.ArgumentList.Arguments) p.joinPrint(",", nn.ArgumentList.Arguments)
p.printFreeFloating(nn.ArgumentList, token.ArgumentList) p.printFreeFloatingOrDefault(nn.ArgumentList, token.End, ")")
io.WriteString(p.w, ")")
p.printFreeFloating(nn.ArgumentList, token.End)
} }
if nn.Extends != nil { if nn.Extends != nil {

View File

@ -63,7 +63,6 @@ const (
ArrayPairList ArrayPairList
CaseListStart CaseListStart
CaseListEnd CaseListEnd
ArgumentList
PropertyList PropertyList
ParameterList ParameterList
AdaptationList AdaptationList

View File

@ -65,18 +65,17 @@ func _() {
_ = x[ArrayPairList-54] _ = x[ArrayPairList-54]
_ = x[CaseListStart-55] _ = x[CaseListStart-55]
_ = x[CaseListEnd-56] _ = x[CaseListEnd-56]
_ = x[ArgumentList-57] _ = x[PropertyList-57]
_ = x[PropertyList-58] _ = x[ParameterList-58]
_ = x[ParameterList-59] _ = x[AdaptationList-59]
_ = x[AdaptationList-60] _ = x[LexicalVarList-60]
_ = x[LexicalVarList-61] _ = x[OpenParenthesisToken-61]
_ = x[OpenParenthesisToken-62] _ = x[CloseParenthesisToken-62]
_ = x[CloseParenthesisToken-63]
} }
const _Position_name = "StartEndSemiColonAltEndAmpersandNameKeyVarReturnTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondNamespaceStaticClassUseWhileForSwitchForeachDeclareLabelFinallyListDefaultIfElseIfElseFunctionAliasEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListOpenParenthesisTokenCloseParenthesisToken" const _Position_name = "StartEndSemiColonAltEndAmpersandNameKeyVarReturnTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondNamespaceStaticClassUseWhileForSwitchForeachDeclareLabelFinallyListDefaultIfElseIfElseFunctionAliasEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndPropertyListParameterListAdaptationListLexicalVarListOpenParenthesisTokenCloseParenthesisToken"
var _Position_index = [...]uint16{0, 5, 8, 17, 23, 32, 36, 39, 42, 52, 65, 76, 82, 85, 89, 93, 101, 109, 116, 120, 124, 133, 139, 144, 147, 152, 155, 161, 168, 175, 180, 187, 191, 198, 200, 206, 210, 218, 223, 228, 232, 237, 242, 247, 251, 255, 258, 263, 268, 273, 280, 289, 297, 306, 318, 331, 344, 355, 367, 379, 392, 406, 420, 440, 461} var _Position_index = [...]uint16{0, 5, 8, 17, 23, 32, 36, 39, 42, 52, 65, 76, 82, 85, 89, 93, 101, 109, 116, 120, 124, 133, 139, 144, 147, 152, 155, 161, 168, 175, 180, 187, 191, 198, 200, 206, 210, 218, 223, 228, 232, 237, 242, 247, 251, 255, 258, 263, 268, 273, 280, 289, 297, 306, 318, 331, 344, 355, 367, 380, 394, 408, 428, 449}
func (i Position) String() string { func (i Position) String() string {
if i < 0 || i >= Position(len(_Position_index)-1) { if i < 0 || i >= Position(len(_Position_index)-1) {