[refactoring] store expr parenthesis
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1530,11 +1530,16 @@ func (p *Printer) printExprEmpty(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprEmpty)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
io.WriteString(p.w, "empty")
|
||||
p.printFreeFloating(nn, token.Empty)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Expr.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Expr)
|
||||
p.printFreeFloating(nn, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Expr.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn, token.End)
|
||||
}
|
||||
@@ -1551,12 +1556,18 @@ func (p *Printer) printExprErrorSuppress(n ast.Vertex) {
|
||||
func (p *Printer) printExprEval(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprEval)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
io.WriteString(p.w, "eval")
|
||||
p.printFreeFloating(nn, token.Eval)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Expr.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Expr)
|
||||
p.printFreeFloating(nn, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Expr.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn, token.End)
|
||||
}
|
||||
@@ -1570,7 +1581,6 @@ func (p *Printer) printExprExit(n ast.Vertex) {
|
||||
} else {
|
||||
io.WriteString(p.w, "exit")
|
||||
}
|
||||
p.printFreeFloating(nn, token.Exit)
|
||||
|
||||
if nn.Expr != nil && nn.Expr.GetNode().Tokens.IsEmpty() && nn.GetNode().Tokens.IsEmpty() {
|
||||
io.WriteString(p.w, " ")
|
||||
@@ -2163,11 +2173,17 @@ func (p *Printer) printStmtAltSwitch(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
io.WriteString(p.w, "switch")
|
||||
p.printFreeFloating(nn, token.Switch)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Cond)
|
||||
p.printFreeFloating(nn, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn, token.Cond)
|
||||
io.WriteString(p.w, ":")
|
||||
|
||||
@@ -2192,11 +2208,17 @@ func (p *Printer) printStmtAltWhile(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
io.WriteString(p.w, "while")
|
||||
p.printFreeFloating(nn, token.While)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Cond)
|
||||
p.printFreeFloating(nn, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn, token.Cond)
|
||||
io.WriteString(p.w, ":")
|
||||
|
||||
@@ -2543,11 +2565,17 @@ func (p *Printer) printStmtDo(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.Stmts)
|
||||
|
||||
io.WriteString(p.w, "while")
|
||||
p.printFreeFloating(nn, token.While)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Cond)
|
||||
p.printFreeFloating(nn, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn, token.Cond)
|
||||
|
||||
p.printFreeFloating(nn, token.SemiColon)
|
||||
@@ -2587,11 +2615,16 @@ func (p *Printer) printStmtElseif(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
io.WriteString(p.w, "elseif")
|
||||
p.printFreeFloating(nn, token.ElseIf)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Cond)
|
||||
p.printFreeFloating(nn, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.Print(nn.Stmt)
|
||||
|
||||
@@ -2794,11 +2827,16 @@ func (p *Printer) printStmtIf(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
io.WriteString(p.w, "if")
|
||||
p.printFreeFloating(n, token.If)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Cond)
|
||||
p.printFreeFloating(n, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.Print(nn.Stmt)
|
||||
|
||||
@@ -3020,11 +3058,16 @@ func (p *Printer) printStmtSwitch(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
io.WriteString(p.w, "switch")
|
||||
p.printFreeFloating(nn, token.Switch)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Cond)
|
||||
p.printFreeFloating(nn, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn.CaseList, token.Start)
|
||||
io.WriteString(p.w, "{")
|
||||
@@ -3292,11 +3335,16 @@ func (p *Printer) printStmtWhile(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
io.WriteString(p.w, "while")
|
||||
p.printFreeFloating(nn, token.While)
|
||||
io.WriteString(p.w, "(")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, "(")
|
||||
}
|
||||
|
||||
p.Print(nn.Cond)
|
||||
p.printFreeFloating(nn, token.Expr)
|
||||
io.WriteString(p.w, ")")
|
||||
|
||||
if _, ok := nn.Cond.(*ast.ParserBrackets); !ok {
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
|
||||
p.Print(nn.Stmt)
|
||||
|
||||
|
||||
@@ -27,28 +27,19 @@ const (
|
||||
|
||||
Namespace
|
||||
Static
|
||||
Class
|
||||
Use
|
||||
While
|
||||
For
|
||||
Switch
|
||||
Foreach
|
||||
Declare
|
||||
Label
|
||||
Finally
|
||||
List
|
||||
Default
|
||||
If
|
||||
ElseIf
|
||||
Else
|
||||
Function
|
||||
Alias
|
||||
Equal
|
||||
Exit
|
||||
Array
|
||||
Isset
|
||||
Empty
|
||||
Eval
|
||||
Echo
|
||||
Try
|
||||
Catch
|
||||
@@ -68,7 +59,6 @@ const (
|
||||
AdaptationList
|
||||
LexicalVarList
|
||||
|
||||
OpenParenthesisToken
|
||||
CloseParenthesisToken
|
||||
)
|
||||
|
||||
|
||||
@@ -30,52 +30,42 @@ func _() {
|
||||
_ = x[Cond-19]
|
||||
_ = x[Namespace-20]
|
||||
_ = x[Static-21]
|
||||
_ = x[Class-22]
|
||||
_ = x[Use-23]
|
||||
_ = x[While-24]
|
||||
_ = x[For-25]
|
||||
_ = x[Switch-26]
|
||||
_ = x[Foreach-27]
|
||||
_ = x[Declare-28]
|
||||
_ = x[Label-29]
|
||||
_ = x[Finally-30]
|
||||
_ = x[List-31]
|
||||
_ = x[Default-32]
|
||||
_ = x[If-33]
|
||||
_ = x[ElseIf-34]
|
||||
_ = x[Else-35]
|
||||
_ = x[Function-36]
|
||||
_ = x[Alias-37]
|
||||
_ = x[Equal-38]
|
||||
_ = x[Exit-39]
|
||||
_ = x[Array-40]
|
||||
_ = x[Isset-41]
|
||||
_ = x[Empty-42]
|
||||
_ = x[Eval-43]
|
||||
_ = x[Echo-44]
|
||||
_ = x[Try-45]
|
||||
_ = x[Catch-46]
|
||||
_ = x[Unset-47]
|
||||
_ = x[Stmts-48]
|
||||
_ = x[VarList-49]
|
||||
_ = x[ConstList-50]
|
||||
_ = x[NameList-51]
|
||||
_ = x[ParamList-52]
|
||||
_ = x[ModifierList-53]
|
||||
_ = x[ArrayPairList-54]
|
||||
_ = x[CaseListStart-55]
|
||||
_ = x[CaseListEnd-56]
|
||||
_ = x[PropertyList-57]
|
||||
_ = x[ParameterList-58]
|
||||
_ = x[AdaptationList-59]
|
||||
_ = x[LexicalVarList-60]
|
||||
_ = x[OpenParenthesisToken-61]
|
||||
_ = x[CloseParenthesisToken-62]
|
||||
_ = x[Use-22]
|
||||
_ = x[For-23]
|
||||
_ = x[Foreach-24]
|
||||
_ = x[Declare-25]
|
||||
_ = x[Label-26]
|
||||
_ = x[Finally-27]
|
||||
_ = x[List-28]
|
||||
_ = x[Default-29]
|
||||
_ = x[Function-30]
|
||||
_ = x[Alias-31]
|
||||
_ = x[Equal-32]
|
||||
_ = x[Array-33]
|
||||
_ = x[Isset-34]
|
||||
_ = x[Echo-35]
|
||||
_ = x[Try-36]
|
||||
_ = x[Catch-37]
|
||||
_ = x[Unset-38]
|
||||
_ = x[Stmts-39]
|
||||
_ = x[VarList-40]
|
||||
_ = x[ConstList-41]
|
||||
_ = x[NameList-42]
|
||||
_ = x[ParamList-43]
|
||||
_ = x[ModifierList-44]
|
||||
_ = x[ArrayPairList-45]
|
||||
_ = x[CaseListStart-46]
|
||||
_ = x[CaseListEnd-47]
|
||||
_ = x[PropertyList-48]
|
||||
_ = x[ParameterList-49]
|
||||
_ = x[AdaptationList-50]
|
||||
_ = x[LexicalVarList-51]
|
||||
_ = x[CloseParenthesisToken-52]
|
||||
}
|
||||
|
||||
const _Position_name = "StartEndSemiColonAltEndAmpersandNameKeyVarReturnTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondNamespaceStaticClassUseWhileForSwitchForeachDeclareLabelFinallyListDefaultIfElseIfElseFunctionAliasEqualExitArrayIssetEmptyEvalEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndPropertyListParameterListAdaptationListLexicalVarListOpenParenthesisTokenCloseParenthesisToken"
|
||||
const _Position_name = "StartEndSemiColonAltEndAmpersandNameKeyVarReturnTypeCaseSeparatorLexicalVarsParamsRefCastExprInitExprCondExprIncExprTrueCondNamespaceStaticUseForForeachDeclareLabelFinallyListDefaultFunctionAliasEqualArrayIssetEchoTryCatchUnsetStmtsVarListConstListNameListParamListModifierListArrayPairListCaseListStartCaseListEndPropertyListParameterListAdaptationListLexicalVarListCloseParenthesisToken"
|
||||
|
||||
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}
|
||||
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, 142, 145, 152, 159, 164, 171, 175, 182, 190, 195, 200, 205, 210, 214, 217, 222, 227, 232, 239, 248, 256, 265, 277, 290, 303, 314, 326, 339, 353, 367, 388}
|
||||
|
||||
func (i Position) String() string {
|
||||
if i < 0 || i >= Position(len(_Position_index)-1) {
|
||||
|
||||
Reference in New Issue
Block a user