[refactoring] remove unused token positions

This commit is contained in:
Vadym Slizov 2020-08-03 22:44:49 +02:00
parent b7d32b07bf
commit a70e34d726
3 changed files with 63 additions and 84 deletions

View File

@ -532,7 +532,6 @@ func (p *Printer) printNodeArgument(n ast.Vertex) {
if nn.Variadic { if nn.Variadic {
io.WriteString(p.w, "...") io.WriteString(p.w, "...")
} }
p.printFreeFloating(nn, token.Variadic)
p.Print(nn.Expr) p.Print(nn.Expr)
@ -1916,7 +1915,6 @@ func (p *Printer) printExprVariable(n ast.Vertex) {
p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = "" p.bufStart = ""
p.printFreeFloating(nn, token.Dollar)
if _, ok := nn.VarName.(*ast.Identifier); !ok { if _, ok := nn.VarName.(*ast.Identifier); !ok {
io.WriteString(p.w, "$") io.WriteString(p.w, "$")
} }
@ -2313,7 +2311,6 @@ func (p *Printer) printStmtClass(n ast.Vertex) {
} }
p.printFreeFloating(nn, token.ModifierList) p.printFreeFloating(nn, token.ModifierList)
io.WriteString(p.w, "class") io.WriteString(p.w, "class")
p.printFreeFloating(nn, token.Class)
if nn.ClassName != nil { if nn.ClassName != nil {
p.bufStart = " " p.bufStart = " "

View File

@ -8,15 +8,11 @@ const (
End End
SemiColon SemiColon
AltEnd AltEnd
Dollar
Ampersand Ampersand
Name Name
Prefix
Key Key
Var Var
UseType
ReturnType ReturnType
OptionalType
CaseSeparator CaseSeparator
LexicalVars LexicalVars
Params Params
@ -37,7 +33,6 @@ const (
While While
For For
Switch Switch
Break
Foreach Foreach
Declare Declare
Label Label
@ -47,11 +42,8 @@ const (
If If
ElseIf ElseIf
Else Else
Variadic
Function Function
DoubleArrow
Alias Alias
As
Equal Equal
Exit Exit
Array Array
@ -77,7 +69,6 @@ const (
ParameterList ParameterList
AdaptationList AdaptationList
LexicalVarList LexicalVarList
UseDeclarationList
OpenParenthesisToken OpenParenthesisToken
CloseParenthesisToken CloseParenthesisToken

View File

@ -12,81 +12,72 @@ func _() {
_ = x[End-1] _ = x[End-1]
_ = x[SemiColon-2] _ = x[SemiColon-2]
_ = x[AltEnd-3] _ = x[AltEnd-3]
_ = x[Dollar-4] _ = x[Ampersand-4]
_ = x[Ampersand-5] _ = x[Name-5]
_ = x[Name-6] _ = x[Key-6]
_ = x[Prefix-7] _ = x[Var-7]
_ = x[Key-8] _ = x[ReturnType-8]
_ = x[Var-9] _ = x[CaseSeparator-9]
_ = x[UseType-10] _ = x[LexicalVars-10]
_ = x[ReturnType-11] _ = x[Params-11]
_ = x[OptionalType-12] _ = x[Ref-12]
_ = x[CaseSeparator-13] _ = x[Cast-13]
_ = x[LexicalVars-14] _ = x[Expr-14]
_ = x[Params-15] _ = x[InitExpr-15]
_ = x[Ref-16] _ = x[CondExpr-16]
_ = x[Cast-17] _ = x[IncExpr-17]
_ = x[Expr-18] _ = x[True-18]
_ = x[InitExpr-19] _ = x[Cond-19]
_ = x[CondExpr-20] _ = x[HaltCompiller-20]
_ = x[IncExpr-21] _ = x[Namespace-21]
_ = x[True-22] _ = x[Static-22]
_ = x[Cond-23] _ = x[Class-23]
_ = x[HaltCompiller-24] _ = x[Use-24]
_ = x[Namespace-25] _ = x[While-25]
_ = x[Static-26] _ = x[For-26]
_ = x[Class-27] _ = x[Switch-27]
_ = x[Use-28] _ = x[Foreach-28]
_ = x[While-29] _ = x[Declare-29]
_ = x[For-30] _ = x[Label-30]
_ = x[Switch-31] _ = x[Finally-31]
_ = x[Break-32] _ = x[List-32]
_ = x[Foreach-33] _ = x[Default-33]
_ = x[Declare-34] _ = x[If-34]
_ = x[Label-35] _ = x[ElseIf-35]
_ = x[Finally-36] _ = x[Else-36]
_ = x[List-37] _ = x[Function-37]
_ = x[Default-38] _ = x[Alias-38]
_ = x[If-39] _ = x[Equal-39]
_ = x[ElseIf-40] _ = x[Exit-40]
_ = x[Else-41] _ = x[Array-41]
_ = x[Variadic-42] _ = x[Isset-42]
_ = x[Function-43] _ = x[Empty-43]
_ = x[DoubleArrow-44] _ = x[Eval-44]
_ = x[Alias-45] _ = x[Echo-45]
_ = x[As-46] _ = x[Try-46]
_ = x[Equal-47] _ = x[Catch-47]
_ = x[Exit-48] _ = x[Unset-48]
_ = x[Array-49] _ = x[Stmts-49]
_ = x[Isset-50] _ = x[VarList-50]
_ = x[Empty-51] _ = x[ConstList-51]
_ = x[Eval-52] _ = x[NameList-52]
_ = x[Echo-53] _ = x[ParamList-53]
_ = x[Try-54] _ = x[ModifierList-54]
_ = x[Catch-55] _ = x[ArrayPairList-55]
_ = x[Unset-56] _ = x[CaseListStart-56]
_ = x[Stmts-57] _ = x[CaseListEnd-57]
_ = x[VarList-58] _ = x[ArgumentList-58]
_ = x[ConstList-59] _ = x[PropertyList-59]
_ = x[NameList-60] _ = x[ParameterList-60]
_ = x[ParamList-61] _ = x[AdaptationList-61]
_ = x[ModifierList-62] _ = x[LexicalVarList-62]
_ = x[ArrayPairList-63] _ = x[OpenParenthesisToken-63]
_ = x[CaseListStart-64] _ = x[CloseParenthesisToken-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 = "StartEndSemiColonAltEndDollarAmpersandNamePrefixKeyVarUseTypeReturnTypeOptionalTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchBreakForeachDeclareLabelFinallyListDefaultIfElseIfElseVariadicFunctionDoubleArrowAliasAsEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListUseDeclarationListOpenParenthesisTokenCloseParenthesisToken" const _Position_name = "StartEndSemiColonAltEndAmpersandNameKeyVarReturnTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondHaltCompillerNamespaceStaticClassUseWhileForSwitchForeachDeclareLabelFinallyListDefaultIfElseIfElseFunctionAliasEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndArgumentListPropertyListParameterListAdaptationListLexicalVarListOpenParenthesisTokenCloseParenthesisToken"
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} 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, 137, 146, 152, 157, 160, 165, 168, 174, 181, 188, 193, 200, 204, 211, 213, 219, 223, 231, 236, 241, 245, 250, 255, 260, 264, 268, 271, 276, 281, 286, 293, 302, 310, 319, 331, 344, 357, 368, 380, 392, 405, 419, 433, 453, 474}
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) {