2018-03-18 20:27:34 +00:00
|
|
|
package printer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
2018-04-05 21:39:04 +00:00
|
|
|
"strings"
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
"github.com/z7zmey/php-parser/meta"
|
|
|
|
|
2018-03-19 20:50:07 +00:00
|
|
|
"github.com/z7zmey/php-parser/node/stmt"
|
|
|
|
|
2018-03-18 20:27:34 +00:00
|
|
|
"github.com/z7zmey/php-parser/node"
|
|
|
|
"github.com/z7zmey/php-parser/node/expr"
|
|
|
|
"github.com/z7zmey/php-parser/node/expr/assign"
|
|
|
|
"github.com/z7zmey/php-parser/node/expr/binary"
|
|
|
|
"github.com/z7zmey/php-parser/node/expr/cast"
|
|
|
|
"github.com/z7zmey/php-parser/node/name"
|
|
|
|
"github.com/z7zmey/php-parser/node/scalar"
|
|
|
|
)
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
type Printer struct {
|
2018-07-02 17:48:55 +00:00
|
|
|
w io.Writer
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
// NewPrinter - Constructor for Printer
|
2018-07-02 17:48:55 +00:00
|
|
|
func NewPrinter(w io.Writer) *Printer {
|
2018-04-02 20:57:22 +00:00
|
|
|
return &Printer{
|
2018-07-02 17:48:55 +00:00
|
|
|
w: w,
|
2018-04-02 20:57:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Printer) Print(n node.Node) {
|
|
|
|
p.printNode(n)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Printer) joinPrint(glue string, nn []node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
for k, n := range nn {
|
|
|
|
if k > 0 {
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, glue)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNodes(nn []node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
for _, n := range nn {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
2018-04-03 16:20:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
func (p *Printer) printMeta(n node.Node, tn meta.TokenName) bool {
|
2018-07-02 17:48:55 +00:00
|
|
|
if n == nil {
|
2018-07-29 08:44:38 +00:00
|
|
|
return false
|
2018-07-02 17:48:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
r := false
|
|
|
|
|
|
|
|
for _, m := range *n.GetMeta() {
|
|
|
|
if m.TokenName == tn {
|
2018-07-02 17:48:55 +00:00
|
|
|
io.WriteString(p.w, m.String())
|
2018-07-29 08:44:38 +00:00
|
|
|
r = true
|
2018-07-02 17:48:55 +00:00
|
|
|
}
|
2018-04-03 16:20:55 +00:00
|
|
|
}
|
2018-07-29 08:44:38 +00:00
|
|
|
|
|
|
|
return r
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNode(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
switch n.(type) {
|
|
|
|
|
|
|
|
// node
|
|
|
|
|
2018-05-02 09:14:24 +00:00
|
|
|
case *node.Root:
|
|
|
|
p.printNodeRoot(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *node.Identifier:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodeIdentifier(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *node.Parameter:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodeParameter(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *node.Nullable:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodeNullable(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *node.Argument:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodeArgument(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
// name
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
case *name.NamePart:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNameNamePart(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *name.Name:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNameName(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *name.FullyQualified:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNameFullyQualified(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *name.Relative:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNameRelative(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
// scalar
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
case *scalar.Lnumber:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printScalarLNumber(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *scalar.Dnumber:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printScalarDNumber(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *scalar.String:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printScalarString(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *scalar.EncapsedStringPart:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printScalarEncapsedStringPart(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *scalar.Encapsed:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printScalarEncapsed(n)
|
2018-04-05 21:39:04 +00:00
|
|
|
case *scalar.Heredoc:
|
|
|
|
p.printScalarHeredoc(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *scalar.MagicConstant:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printScalarMagicConstant(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
// assign
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
case *assign.Assign:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssign(n)
|
2018-04-05 09:03:32 +00:00
|
|
|
case *assign.Reference:
|
|
|
|
p.printReference(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.BitwiseAnd:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignBitwiseAnd(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.BitwiseOr:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignBitwiseOr(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.BitwiseXor:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignBitwiseXor(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.Concat:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignConcat(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.Div:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignDiv(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.Minus:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignMinus(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.Mod:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignMod(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.Mul:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignMul(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.Plus:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignPlus(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.Pow:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignPow(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.ShiftLeft:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignShiftLeft(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *assign.ShiftRight:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printAssignShiftRight(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
// binary
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
case *binary.BitwiseAnd:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryBitwiseAnd(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.BitwiseOr:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryBitwiseOr(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.BitwiseXor:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryBitwiseXor(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.BooleanAnd:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryBooleanAnd(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.BooleanOr:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryBooleanOr(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Coalesce:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryCoalesce(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Concat:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryConcat(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Div:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryDiv(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Equal:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryEqual(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.GreaterOrEqual:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryGreaterOrEqual(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Greater:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryGreater(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Identical:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryIdentical(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.LogicalAnd:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryLogicalAnd(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.LogicalOr:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryLogicalOr(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.LogicalXor:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryLogicalXor(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Minus:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryMinus(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Mod:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryMod(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Mul:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryMul(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.NotEqual:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryNotEqual(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.NotIdentical:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryNotIdentical(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Plus:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryPlus(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Pow:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryPow(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.ShiftLeft:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryShiftLeft(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.ShiftRight:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinaryShiftRight(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.SmallerOrEqual:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinarySmallerOrEqual(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Smaller:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinarySmaller(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *binary.Spaceship:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printBinarySpaceship(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
// cast
|
2018-04-05 08:59:29 +00:00
|
|
|
|
|
|
|
case *cast.Array:
|
|
|
|
p.printArray(n)
|
|
|
|
case *cast.Bool:
|
|
|
|
p.printBool(n)
|
|
|
|
case *cast.Double:
|
|
|
|
p.printDouble(n)
|
|
|
|
case *cast.Int:
|
|
|
|
p.printInt(n)
|
|
|
|
case *cast.Object:
|
|
|
|
p.printObject(n)
|
|
|
|
case *cast.String:
|
|
|
|
p.printString(n)
|
|
|
|
case *cast.Unset:
|
|
|
|
p.printUnset(n)
|
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
// expr
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
case *expr.ArrayDimFetch:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprArrayDimFetch(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.ArrayItem:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprArrayItem(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Array:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprArray(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.BitwiseNot:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprBitwiseNot(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.BooleanNot:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprBooleanNot(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.ClassConstFetch:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprClassConstFetch(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Clone:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprClone(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.ClosureUse:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprClosureUse(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Closure:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprClosure(n)
|
2018-03-20 17:48:55 +00:00
|
|
|
case *expr.ConstFetch:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprConstFetch(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Empty:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprEmpty(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.ErrorSuppress:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprErrorSuppress(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Eval:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprEval(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Exit:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprExit(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.FunctionCall:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprFunctionCall(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Include:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprInclude(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.IncludeOnce:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprIncludeOnce(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.InstanceOf:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprInstanceOf(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Isset:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprIsset(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.List:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprList(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.MethodCall:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprMethodCall(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.New:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprNew(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.PostDec:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprPostDec(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.PostInc:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprPostInc(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.PreDec:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprPreDec(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.PreInc:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprPreInc(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Print:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprPrint(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.PropertyFetch:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprPropertyFetch(n)
|
2018-05-14 15:09:11 +00:00
|
|
|
case *expr.Reference:
|
|
|
|
p.printExprReference(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Require:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprRequire(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.RequireOnce:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprRequireOnce(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.ShellExec:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprShellExec(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.ShortArray:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprShortArray(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.ShortList:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprShortList(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.StaticCall:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprStaticCall(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.StaticPropertyFetch:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprStaticPropertyFetch(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Ternary:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprTernary(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.UnaryMinus:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprUnaryMinus(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.UnaryPlus:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprUnaryPlus(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Variable:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprVariable(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.YieldFrom:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprYieldFrom(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
case *expr.Yield:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printExprYield(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
// stmt
|
2018-03-19 20:50:07 +00:00
|
|
|
|
|
|
|
case *stmt.AltElseIf:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtAltElseIf(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
case *stmt.AltElse:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtAltElse(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
case *stmt.AltFor:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtAltFor(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
case *stmt.AltForeach:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtAltForeach(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
case *stmt.AltIf:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtAltIf(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
case *stmt.AltSwitch:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtAltSwitch(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
case *stmt.AltWhile:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtAltWhile(n)
|
2018-03-20 10:21:21 +00:00
|
|
|
case *stmt.Break:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtBreak(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
case *stmt.Case:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtCase(n)
|
2018-03-20 10:21:21 +00:00
|
|
|
case *stmt.Catch:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtCatch(n)
|
2018-03-20 17:48:55 +00:00
|
|
|
case *stmt.ClassMethod:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtClassMethod(n)
|
2018-03-20 18:06:56 +00:00
|
|
|
case *stmt.Class:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtClass(n)
|
2018-03-20 18:37:55 +00:00
|
|
|
case *stmt.ClassConstList:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtClassConstList(n)
|
2018-07-29 08:44:38 +00:00
|
|
|
case *stmt.ConstList:
|
|
|
|
p.printStmtConstList(n)
|
2018-03-20 10:21:21 +00:00
|
|
|
case *stmt.Constant:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtConstant(n)
|
2018-03-20 18:37:55 +00:00
|
|
|
case *stmt.Continue:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtContinue(n)
|
2018-03-28 20:44:02 +00:00
|
|
|
case *stmt.Declare:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtDeclare(n)
|
2018-03-28 21:04:09 +00:00
|
|
|
case *stmt.Default:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtDefault(n)
|
2018-03-28 21:04:09 +00:00
|
|
|
case *stmt.Do:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtDo(n)
|
2018-03-31 11:08:56 +00:00
|
|
|
case *stmt.Echo:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtEcho(n)
|
2018-03-31 11:08:56 +00:00
|
|
|
case *stmt.ElseIf:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtElseif(n)
|
2018-03-31 11:08:56 +00:00
|
|
|
case *stmt.Else:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtElse(n)
|
2018-03-31 11:17:05 +00:00
|
|
|
case *stmt.Expression:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtExpression(n)
|
2018-03-31 11:17:05 +00:00
|
|
|
case *stmt.Finally:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtFinally(n)
|
2018-03-31 11:49:29 +00:00
|
|
|
case *stmt.For:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtFor(n)
|
2018-03-31 11:49:29 +00:00
|
|
|
case *stmt.Foreach:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtForeach(n)
|
2018-03-31 11:49:29 +00:00
|
|
|
case *stmt.Function:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtFunction(n)
|
2018-04-01 12:58:45 +00:00
|
|
|
case *stmt.Global:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtGlobal(n)
|
2018-04-01 12:58:45 +00:00
|
|
|
case *stmt.Goto:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtGoto(n)
|
2018-04-01 12:58:45 +00:00
|
|
|
case *stmt.GroupUse:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtGroupUse(n)
|
2018-04-01 12:58:45 +00:00
|
|
|
case *stmt.HaltCompiler:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtHaltCompiler(n)
|
2018-04-01 14:07:07 +00:00
|
|
|
case *stmt.If:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtIf(n)
|
2018-04-01 14:07:07 +00:00
|
|
|
case *stmt.InlineHtml:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtInlineHTML(n)
|
2018-04-01 21:28:01 +00:00
|
|
|
case *stmt.Interface:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtInterface(n)
|
2018-04-01 21:28:01 +00:00
|
|
|
case *stmt.Label:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtLabel(n)
|
2018-04-01 21:28:01 +00:00
|
|
|
case *stmt.Namespace:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtNamespace(n)
|
2018-04-01 21:43:27 +00:00
|
|
|
case *stmt.Nop:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtNop(n)
|
2018-04-01 21:43:27 +00:00
|
|
|
case *stmt.PropertyList:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtPropertyList(n)
|
2018-04-01 21:43:27 +00:00
|
|
|
case *stmt.Property:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtProperty(n)
|
2018-04-01 21:43:27 +00:00
|
|
|
case *stmt.Return:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtReturn(n)
|
2018-04-01 21:59:31 +00:00
|
|
|
case *stmt.StaticVar:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtStaticVar(n)
|
2018-04-01 21:59:31 +00:00
|
|
|
case *stmt.Static:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtStatic(n)
|
2018-03-19 20:50:07 +00:00
|
|
|
case *stmt.StmtList:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtStmtList(n)
|
2018-04-01 21:59:31 +00:00
|
|
|
case *stmt.Switch:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtSwitch(n)
|
2018-04-01 22:29:24 +00:00
|
|
|
case *stmt.Throw:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtThrow(n)
|
2018-04-01 22:29:24 +00:00
|
|
|
case *stmt.TraitMethodRef:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtTraitMethodRef(n)
|
2018-04-01 22:29:24 +00:00
|
|
|
case *stmt.TraitUseAlias:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtTraitUseAlias(n)
|
2018-04-01 22:29:24 +00:00
|
|
|
case *stmt.TraitUsePrecedence:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtTraitUsePrecedence(n)
|
2018-04-01 22:29:24 +00:00
|
|
|
case *stmt.TraitUse:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtTraitUse(n)
|
2018-04-02 09:41:47 +00:00
|
|
|
case *stmt.Trait:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtTrait(n)
|
2018-04-02 09:41:47 +00:00
|
|
|
case *stmt.Try:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtTry(n)
|
2018-04-02 09:41:47 +00:00
|
|
|
case *stmt.Unset:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtUnset(n)
|
2018-04-02 09:41:47 +00:00
|
|
|
case *stmt.UseList:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtUseList(n)
|
2018-04-01 12:58:45 +00:00
|
|
|
case *stmt.Use:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtUse(n)
|
2018-04-02 09:41:47 +00:00
|
|
|
case *stmt.While:
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printStmtWhile(n)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// node
|
|
|
|
|
2018-05-02 09:14:24 +00:00
|
|
|
func (p *Printer) printNodeRoot(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*node.Root)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-05-02 09:14:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNodeIdentifier(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*node.Identifier)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
io.WriteString(p.w, nn.Value)
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNodeParameter(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*node.Parameter)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
2018-03-18 20:27:34 +00:00
|
|
|
if nn.VariableType != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.VariableType)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.ByRef {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AmpersandToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "&")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Variadic {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EllipsisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "...")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
if nn.DefaultValue != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EqualToken)
|
|
|
|
io.WriteString(p.w, "=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.DefaultValue)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNodeNullable(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*node.Nullable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "?")
|
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNodeArgument(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*node.Argument)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
2018-03-18 20:27:34 +00:00
|
|
|
if nn.IsReference {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AmpersandToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "&")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Variadic {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EllipsisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "...")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// name
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNameNamePart(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*name.NamePart)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
|
|
|
io.WriteString(p.w, nn.Value)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NsSeparatorToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNameName(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*name.Name)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
2018-03-18 20:27:34 +00:00
|
|
|
for k, part := range nn.Parts {
|
|
|
|
if k > 0 {
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "\\")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(part)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNameFullyQualified(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*name.FullyQualified)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
2018-03-18 20:27:34 +00:00
|
|
|
for _, part := range nn.Parts {
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "\\")
|
|
|
|
p.Print(part)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printNameRelative(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*name.Relative)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "namespace")
|
2018-10-25 10:32:18 +00:00
|
|
|
p.printMeta(nn, meta.NsSeparatorToken)
|
|
|
|
|
|
|
|
for _, part := range nn.Parts {
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "\\")
|
|
|
|
p.Print(part)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// scalar
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printScalarLNumber(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*scalar.Lnumber)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
io.WriteString(p.w, nn.Value)
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printScalarDNumber(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*scalar.Dnumber)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
io.WriteString(p.w, nn.Value)
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printScalarString(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*scalar.String)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
io.WriteString(p.w, nn.Value)
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printScalarEncapsedStringPart(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*scalar.EncapsedStringPart)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
io.WriteString(p.w, nn.Value)
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printScalarEncapsed(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*scalar.Encapsed)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "\"")
|
2018-07-02 17:48:55 +00:00
|
|
|
for _, part := range nn.Parts {
|
2018-07-29 08:44:38 +00:00
|
|
|
p.Print(part)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "\"")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 21:39:04 +00:00
|
|
|
func (p *Printer) printScalarHeredoc(n node.Node) {
|
|
|
|
nn := n.(*scalar.Heredoc)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
2018-04-05 21:39:04 +00:00
|
|
|
io.WriteString(p.w, "<<<")
|
|
|
|
io.WriteString(p.w, nn.Label)
|
|
|
|
io.WriteString(p.w, "\n")
|
|
|
|
|
2018-07-09 18:37:07 +00:00
|
|
|
for _, part := range nn.Parts {
|
2018-10-24 19:32:35 +00:00
|
|
|
p.Print(part)
|
2018-04-05 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
2018-07-14 15:00:48 +00:00
|
|
|
io.WriteString(p.w, "\n")
|
2018-04-05 21:39:04 +00:00
|
|
|
io.WriteString(p.w, strings.Trim(nn.Label, "\"'"))
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-05 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printScalarMagicConstant(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*scalar.MagicConstant)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
io.WriteString(p.w, nn.Value)
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Assign
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssign(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.Assign)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EqualToken)
|
|
|
|
io.WriteString(p.w, "=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 09:03:32 +00:00
|
|
|
func (p *Printer) printReference(n node.Node) {
|
|
|
|
nn := n.(*assign.Reference)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EqualToken)
|
|
|
|
io.WriteString(p.w, "=")
|
|
|
|
p.printMeta(nn, meta.AmpersandToken)
|
|
|
|
io.WriteString(p.w, "&")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignBitwiseAnd(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.BitwiseAnd)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AndEqualToken)
|
|
|
|
io.WriteString(p.w, "&")
|
|
|
|
io.WriteString(p.w, "=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignBitwiseOr(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.BitwiseOr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OrEqualToken)
|
|
|
|
io.WriteString(p.w, "|=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignBitwiseXor(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.BitwiseXor)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.XorEqualToken)
|
|
|
|
io.WriteString(p.w, "^=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignConcat(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.Concat)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ConcatEqualToken)
|
|
|
|
io.WriteString(p.w, ".=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignDiv(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.Div)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DivEqualToken)
|
|
|
|
io.WriteString(p.w, "/=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignMinus(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.Minus)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.MinusEqualToken)
|
|
|
|
io.WriteString(p.w, "-=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignMod(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.Mod)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ModEqualToken)
|
|
|
|
io.WriteString(p.w, "%=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignMul(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.Mul)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.MulEqualToken)
|
|
|
|
io.WriteString(p.w, "*=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignPlus(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.Plus)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PlusEqualToken)
|
|
|
|
io.WriteString(p.w, "+=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignPow(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.Pow)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PowEqualToken)
|
|
|
|
io.WriteString(p.w, "**=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignShiftLeft(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.ShiftLeft)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SlEqualToken)
|
|
|
|
io.WriteString(p.w, "<<=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printAssignShiftRight(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*assign.ShiftRight)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SrEqualToken)
|
|
|
|
io.WriteString(p.w, ">>=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// binary
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryBitwiseAnd(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.BitwiseAnd)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AmpersandToken)
|
|
|
|
io.WriteString(p.w, "&")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryBitwiseOr(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.BitwiseOr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.VerticalBarToken)
|
|
|
|
io.WriteString(p.w, "|")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryBitwiseXor(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.BitwiseXor)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CaretToken)
|
|
|
|
io.WriteString(p.w, "^")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryBooleanAnd(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.BooleanAnd)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.BooleanAndToken)
|
|
|
|
io.WriteString(p.w, "&&")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryBooleanOr(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.BooleanOr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.BooleanOrToken)
|
|
|
|
io.WriteString(p.w, "||")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryCoalesce(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Coalesce)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CoalesceToken)
|
|
|
|
io.WriteString(p.w, "??")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryConcat(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Concat)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DotToken)
|
|
|
|
io.WriteString(p.w, ".")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryDiv(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Div)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SlashToken)
|
|
|
|
io.WriteString(p.w, "/")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryEqual(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Equal)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IsEqualToken)
|
|
|
|
io.WriteString(p.w, "==")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryGreaterOrEqual(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.GreaterOrEqual)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IsGreaterOrEqualToken)
|
|
|
|
io.WriteString(p.w, ">=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryGreater(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Greater)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.GreaterToken)
|
|
|
|
io.WriteString(p.w, ">")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryIdentical(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Identical)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IsIdenticalToken)
|
|
|
|
io.WriteString(p.w, "===")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryLogicalAnd(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.LogicalAnd)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.LogicalAndToken)
|
|
|
|
io.WriteString(p.w, "and")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryLogicalOr(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.LogicalOr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.LogicalOrToken)
|
|
|
|
io.WriteString(p.w, "or")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryLogicalXor(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.LogicalXor)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.LogicalXorToken)
|
|
|
|
io.WriteString(p.w, "xor")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryMinus(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Minus)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.MinusToken)
|
|
|
|
io.WriteString(p.w, "-")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryMod(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Mod)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PercentToken)
|
|
|
|
io.WriteString(p.w, "%")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryMul(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Mul)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AsteriskToken)
|
|
|
|
io.WriteString(p.w, "*")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryNotEqual(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.NotEqual)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IsNotEqualToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryNotIdentical(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.NotIdentical)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IsNotIdenticalToken)
|
|
|
|
io.WriteString(p.w, "!==")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryPlus(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Plus)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PlusToken)
|
|
|
|
io.WriteString(p.w, "+")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryPow(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Pow)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PowToken)
|
|
|
|
io.WriteString(p.w, "**")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryShiftLeft(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.ShiftLeft)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SlToken)
|
|
|
|
io.WriteString(p.w, "<<")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinaryShiftRight(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.ShiftRight)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SrToken)
|
|
|
|
io.WriteString(p.w, ">>")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinarySmallerOrEqual(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.SmallerOrEqual)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IsSmallerOrEqualToken)
|
|
|
|
io.WriteString(p.w, "<=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinarySmaller(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Smaller)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.LessToken)
|
|
|
|
io.WriteString(p.w, "<")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printBinarySpaceship(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*binary.Spaceship)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Left)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SpaceshipToken)
|
|
|
|
io.WriteString(p.w, "<=>")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Right)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// cast
|
|
|
|
|
2018-04-05 08:59:29 +00:00
|
|
|
func (p *Printer) printArray(n node.Node) {
|
|
|
|
nn := n.(*cast.Array)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 08:59:29 +00:00
|
|
|
func (p *Printer) printBool(n node.Node) {
|
|
|
|
nn := n.(*cast.Bool)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 08:59:29 +00:00
|
|
|
func (p *Printer) printDouble(n node.Node) {
|
|
|
|
nn := n.(*cast.Double)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 08:59:29 +00:00
|
|
|
func (p *Printer) printInt(n node.Node) {
|
|
|
|
nn := n.(*cast.Int)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 08:59:29 +00:00
|
|
|
func (p *Printer) printObject(n node.Node) {
|
|
|
|
nn := n.(*cast.Object)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 08:59:29 +00:00
|
|
|
func (p *Printer) printString(n node.Node) {
|
|
|
|
nn := n.(*cast.String)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 08:59:29 +00:00
|
|
|
func (p *Printer) printUnset(n node.Node) {
|
|
|
|
nn := n.(*cast.Unset)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// expr
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprArrayDimFetch(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.ArrayDimFetch)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenSquareBracket)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Dim)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseSquareBracket)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprArrayItem(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.ArrayItem)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
if nn.Key != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Key)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DoubleArrowToken)
|
|
|
|
io.WriteString(p.w, "=>")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Val)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprArray(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Array)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ArrayToken)
|
|
|
|
io.WriteString(p.w, "array")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint(",", nn.Items)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprBitwiseNot(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.BitwiseNot)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
p.printMeta(nn, meta.TildeToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "~")
|
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprBooleanNot(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.BooleanNot)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
p.printMeta(nn, meta.ExclamationMarkToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "!")
|
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprClassConstFetch(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.ClassConstFetch)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Class)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PaamayimNekudotayimToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "::")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.ConstantName)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprClone(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Clone)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloneToken)
|
|
|
|
io.WriteString(p.w, "clone")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprClosureUse(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.ClosureUse)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-05-25 06:38:44 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.UseToken)
|
|
|
|
io.WriteString(p.w, "use")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint(",", nn.Uses)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-05-25 06:38:44 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprClosure(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Closure)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
if nn.Static {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.StaticToken)
|
|
|
|
io.WriteString(p.w, "static")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.FunctionToken)
|
|
|
|
io.WriteString(p.w, "function")
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
if nn.ReturnsRef {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AmpersandToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "&")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "(")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.Params)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-05-25 06:38:44 +00:00
|
|
|
if nn.ClosureUse != nil {
|
|
|
|
p.Print(nn.ClosureUse)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.ReturnType != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ReturnType, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.ReturnType)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprConstFetch(n node.Node) {
|
2018-03-20 17:48:55 +00:00
|
|
|
nn := n.(*expr.ConstFetch)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-20 17:48:55 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Constant)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-20 17:48:55 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprEmpty(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Empty)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EmptyToken)
|
|
|
|
io.WriteString(p.w, "empty")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprErrorSuppress(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.ErrorSuppress)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AtToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "@")
|
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprEval(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Eval)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EvalToken)
|
|
|
|
io.WriteString(p.w, "eval")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprExit(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Exit)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ExitToken)
|
2018-07-09 21:51:02 +00:00
|
|
|
if nn.Die {
|
|
|
|
io.WriteString(p.w, "die")
|
|
|
|
} else {
|
|
|
|
io.WriteString(p.w, "exit")
|
|
|
|
}
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-09 21:51:02 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprFunctionCall(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.FunctionCall)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Function)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "(")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.ArgumentList.Arguments)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CommaToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprInclude(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Include)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IncludeToken)
|
|
|
|
io.WriteString(p.w, "include")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprIncludeOnce(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.IncludeOnce)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IncludeOnceToken)
|
|
|
|
io.WriteString(p.w, "include_once")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprInstanceOf(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.InstanceOf)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.InstanceofToken)
|
|
|
|
io.WriteString(p.w, "instanceof")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Class)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprIsset(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Isset)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IssetToken)
|
|
|
|
io.WriteString(p.w, "isset")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint(",", nn.Variables)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn, meta.CommaToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprList(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.List)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ListToken)
|
|
|
|
io.WriteString(p.w, "list")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint(",", nn.Items)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprMethodCall(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.MethodCall)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ObjectOperatorToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "->")
|
|
|
|
p.Print(nn.Method)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "(")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.ArgumentList.Arguments)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CommaToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprNew(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.New)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn, meta.NewAnchor)
|
2018-07-02 17:48:55 +00:00
|
|
|
io.WriteString(p.w, "new")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Class)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-29 16:58:49 +00:00
|
|
|
if nn.ArgumentList != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "(")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.ArgumentList.Arguments)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CommaToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprPostDec(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.PostDec)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DecToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "--")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprPostInc(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.PostInc)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IncToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "++")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprPreDec(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.PreDec)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DecToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "--")
|
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprPreInc(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.PreInc)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IncToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "++")
|
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprPrint(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Print)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PrintToken)
|
|
|
|
io.WriteString(p.w, "print")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprPropertyFetch(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.PropertyFetch)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ObjectOperatorToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "->")
|
|
|
|
p.Print(nn.Property)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-05-14 15:09:11 +00:00
|
|
|
func (p *Printer) printExprReference(n node.Node) {
|
|
|
|
nn := n.(*expr.Reference)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-05-14 15:09:11 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AmpersandToken)
|
2018-05-14 15:09:11 +00:00
|
|
|
io.WriteString(p.w, "&")
|
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-05-14 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprRequire(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Require)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.RequireToken)
|
|
|
|
io.WriteString(p.w, "require")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprRequireOnce(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.RequireOnce)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.RequireOnceToken)
|
|
|
|
io.WriteString(p.w, "require_once")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprShellExec(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.ShellExec)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.BackquoteToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "`")
|
2018-03-18 20:27:34 +00:00
|
|
|
for _, part := range nn.Parts {
|
2018-10-24 19:32:35 +00:00
|
|
|
p.Print(part)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "`")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprShortArray(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.ShortArray)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenSquareBracket)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "[")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.Items)
|
|
|
|
p.printMeta(nn, meta.CloseSquareBracket)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "]")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprShortList(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.ShortList)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenSquareBracket)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "[")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.Items)
|
|
|
|
p.printMeta(nn, meta.CloseSquareBracket)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "]")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprStaticCall(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.StaticCall)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Class)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PaamayimNekudotayimToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "::")
|
|
|
|
p.Print(nn.Call)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "(")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.ArgumentList.Arguments)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CommaToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprStaticPropertyFetch(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.StaticPropertyFetch)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Class)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PaamayimNekudotayimToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "::")
|
|
|
|
p.Print(nn.Property)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprTernary(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Ternary)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Condition)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.QuestionMarkToken)
|
|
|
|
io.WriteString(p.w, "?")
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-04-03 16:59:20 +00:00
|
|
|
if nn.IfTrue != nil {
|
|
|
|
p.Print(nn.IfTrue)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-04-03 16:59:20 +00:00
|
|
|
p.Print(nn.IfFalse)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprUnaryMinus(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.UnaryMinus)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.MinusToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "-")
|
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprUnaryPlus(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.UnaryPlus)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.PlusToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "+")
|
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprVariable(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*expr.Variable)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-07-29 08:44:38 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.VarName)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprYieldFrom(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.YieldFrom)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.YieldFromToken)
|
|
|
|
io.WriteString(p.w, "yield from")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printExprYield(n node.Node) {
|
2018-03-18 20:27:34 +00:00
|
|
|
nn := n.(*expr.Yield)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-18 20:27:34 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.YieldToken)
|
|
|
|
io.WriteString(p.w, "yield")
|
2018-03-18 20:27:34 +00:00
|
|
|
|
|
|
|
if nn.Key != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Key)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DoubleArrowToken)
|
|
|
|
io.WriteString(p.w, "=>")
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Value)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-18 20:27:34 +00:00
|
|
|
}
|
2018-03-19 20:50:07 +00:00
|
|
|
|
|
|
|
// smtm
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtAltElseIf(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.AltElseIf)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ElseifToken)
|
|
|
|
io.WriteString(p.w, "elseif")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-04-02 19:50:36 +00:00
|
|
|
if s := nn.Stmt.(*stmt.StmtList).Stmts; len(s) > 0 {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(s)
|
2018-04-02 19:50:36 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtAltElse(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.AltElse)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ElseToken)
|
|
|
|
io.WriteString(p.w, "else")
|
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-04-02 19:50:36 +00:00
|
|
|
if s := nn.Stmt.(*stmt.StmtList).Stmts; len(s) > 0 {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(s)
|
2018-04-02 19:50:36 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtAltFor(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.AltFor)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ForToken)
|
|
|
|
io.WriteString(p.w, "for")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint(",", nn.Init)
|
|
|
|
p.printMeta(nn, meta.ForInitSemicolonToken)
|
|
|
|
io.WriteString(p.w, ";")
|
|
|
|
p.joinPrint(",", nn.Cond)
|
|
|
|
p.printMeta(nn, meta.ForCondSemicolonToken)
|
|
|
|
io.WriteString(p.w, ";")
|
|
|
|
p.joinPrint(",", nn.Loop)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-03-28 20:15:45 +00:00
|
|
|
s := nn.Stmt.(*stmt.StmtList)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(s.Stmts)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EndforToken)
|
|
|
|
io.WriteString(p.w, "endfor")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtAltForeach(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.AltForeach)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ForeachToken)
|
|
|
|
io.WriteString(p.w, "foreach")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AsToken)
|
|
|
|
io.WriteString(p.w, "as")
|
2018-03-19 20:50:07 +00:00
|
|
|
|
|
|
|
if nn.Key != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Key)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DoubleArrowToken)
|
|
|
|
io.WriteString(p.w, "=>")
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-03-28 20:15:45 +00:00
|
|
|
s := nn.Stmt.(*stmt.StmtList)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(s.Stmts)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EndforeachToken)
|
|
|
|
io.WriteString(p.w, "endforeach")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtAltIf(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.AltIf)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.IfToken)
|
|
|
|
io.WriteString(p.w, "if")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-03-28 20:15:45 +00:00
|
|
|
s := nn.Stmt.(*stmt.StmtList)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(s.Stmts)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
|
|
|
for _, elseif := range nn.ElseIf {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(elseif)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Else != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Else)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EndifToken)
|
|
|
|
io.WriteString(p.w, "endif")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtAltSwitch(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.AltSwitch)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SwitchToken)
|
|
|
|
io.WriteString(p.w, "switch")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.CaseList, meta.CaseSeparatorToken)
|
2018-04-29 20:10:56 +00:00
|
|
|
s := nn.CaseList.Cases
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(s)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EndswitchToken)
|
|
|
|
io.WriteString(p.w, "endswitch")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtAltWhile(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.AltWhile)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.WhileToken)
|
|
|
|
io.WriteString(p.w, "while")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-03-28 20:15:45 +00:00
|
|
|
s := nn.Stmt.(*stmt.StmtList)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(s.Stmts)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EndwhileToken)
|
|
|
|
io.WriteString(p.w, "endwhile")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtBreak(n node.Node) {
|
2018-03-20 10:21:21 +00:00
|
|
|
nn := n.(*stmt.Break)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-20 10:21:21 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.BreakToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "break")
|
2018-03-20 10:21:21 +00:00
|
|
|
if nn.Expr != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-03-20 10:21:21 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-20 10:21:21 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtCase(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.Case)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CaseToken)
|
|
|
|
io.WriteString(p.w, "case")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-29 08:44:38 +00:00
|
|
|
r := p.printMeta(nn, meta.CaseSeparatorToken)
|
|
|
|
if !r {
|
|
|
|
io.WriteString(p.w, ":")
|
|
|
|
}
|
2018-04-02 19:50:36 +00:00
|
|
|
|
|
|
|
if len(nn.Stmts) > 0 {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-04-02 19:50:36 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtCatch(n node.Node) {
|
2018-03-20 10:21:21 +00:00
|
|
|
nn := n.(*stmt.Catch)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-20 10:21:21 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CatchToken)
|
|
|
|
io.WriteString(p.w, "catch")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint("|", nn.Types)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-20 10:21:21 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtClassMethod(n node.Node) {
|
2018-03-20 17:48:55 +00:00
|
|
|
nn := n.(*stmt.ClassMethod)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-20 17:48:55 +00:00
|
|
|
|
|
|
|
if nn.Modifiers != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint("", nn.Modifiers)
|
2018-03-20 17:48:55 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.FunctionToken)
|
|
|
|
io.WriteString(p.w, "function")
|
2018-03-20 17:48:55 +00:00
|
|
|
|
|
|
|
if nn.ReturnsRef {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AmpersandToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "&")
|
2018-03-20 17:48:55 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.MethodName)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "(")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.Params)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-20 17:48:55 +00:00
|
|
|
|
|
|
|
if nn.ReturnType != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ReturnType, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.ReturnType)
|
2018-03-20 17:48:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.Stmt)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-20 17:48:55 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtClass(n node.Node) {
|
2018-03-20 18:06:56 +00:00
|
|
|
nn := n.(*stmt.Class)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-20 18:06:56 +00:00
|
|
|
|
|
|
|
if nn.Modifiers != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint("", nn.Modifiers)
|
2018-03-20 18:06:56 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ClassToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "class")
|
2018-03-20 18:06:56 +00:00
|
|
|
|
|
|
|
if nn.ClassName != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.ClassName)
|
2018-03-20 18:06:56 +00:00
|
|
|
}
|
|
|
|
|
2018-04-29 16:58:49 +00:00
|
|
|
if nn.ArgumentList != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "(")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.ArgumentList.Arguments)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CommaToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ArgumentList, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-20 18:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Extends != nil {
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.Extends, meta.NodeStart)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.Extends, meta.ExtendsToken)
|
|
|
|
io.WriteString(p.w, "extends")
|
2018-05-12 20:10:01 +00:00
|
|
|
p.Print(nn.Extends.ClassName)
|
2018-03-20 18:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Implements != nil {
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.Implements, meta.NodeStart)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.Implements, meta.ImplementsToken)
|
|
|
|
io.WriteString(p.w, "implements")
|
|
|
|
p.joinPrint(",", nn.Implements.InterfaceNames)
|
2018-03-20 18:06:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-20 18:06:56 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtClassConstList(n node.Node) {
|
2018-03-20 18:37:55 +00:00
|
|
|
nn := n.(*stmt.ClassConstList)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-20 18:37:55 +00:00
|
|
|
|
|
|
|
if nn.Modifiers != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint("", nn.Modifiers)
|
2018-03-20 18:37:55 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ConstToken)
|
|
|
|
io.WriteString(p.w, "const")
|
2018-03-20 18:37:55 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.Consts)
|
2018-03-20 18:37:55 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
2018-07-29 08:44:38 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Printer) printStmtConstList(n node.Node) {
|
|
|
|
nn := n.(*stmt.ConstList)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.ConstToken)
|
|
|
|
io.WriteString(p.w, "const")
|
|
|
|
|
|
|
|
p.joinPrint(",", nn.Consts)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-20 18:37:55 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtConstant(n node.Node) {
|
2018-03-20 10:21:21 +00:00
|
|
|
nn := n.(*stmt.Constant)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-20 10:21:21 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.ConstantName)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EqualToken)
|
|
|
|
io.WriteString(p.w, "=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-20 10:21:21 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtContinue(n node.Node) {
|
2018-03-20 18:37:55 +00:00
|
|
|
nn := n.(*stmt.Continue)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-20 18:37:55 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ContinueToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "continue")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
2018-03-20 18:37:55 +00:00
|
|
|
if nn.Expr != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-03-20 18:37:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-20 18:37:55 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtDeclare(n node.Node) {
|
2018-03-28 20:44:02 +00:00
|
|
|
nn := n.(*stmt.Declare)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-28 20:44:02 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DeclareToken)
|
|
|
|
io.WriteString(p.w, "declare")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint(",", nn.Consts)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-31 10:50:35 +00:00
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
if nn.Alt {
|
|
|
|
p.printMeta(nn, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
|
|
|
|
|
|
|
s := nn.Stmt.(*stmt.StmtList)
|
|
|
|
p.printNodes(s.Stmts)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.EnddeclareToken)
|
|
|
|
io.WriteString(p.w, "enddeclare")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
p.Print(nn.Stmt)
|
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-28 20:44:02 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtDefault(n node.Node) {
|
2018-03-28 21:04:09 +00:00
|
|
|
nn := n.(*stmt.Default)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.DefaultToken)
|
|
|
|
io.WriteString(p.w, "default")
|
2018-07-29 08:44:38 +00:00
|
|
|
r := p.printMeta(nn, meta.CaseSeparatorToken)
|
|
|
|
if !r {
|
|
|
|
io.WriteString(p.w, ":")
|
|
|
|
}
|
2018-04-02 19:50:36 +00:00
|
|
|
|
|
|
|
if len(nn.Stmts) > 0 {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-04-02 19:50:36 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-28 21:04:09 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtDo(n node.Node) {
|
2018-03-28 21:04:09 +00:00
|
|
|
nn := n.(*stmt.Do)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.DoToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "do")
|
2018-03-28 21:04:09 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.Stmt)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.WhileToken)
|
|
|
|
io.WriteString(p.w, "while")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-28 21:04:09 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtEcho(n node.Node) {
|
2018-03-31 11:08:56 +00:00
|
|
|
nn := n.(*stmt.Echo)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.EchoToken)
|
|
|
|
p.joinPrint(",", nn.Exprs)
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-31 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtElseif(n node.Node) {
|
2018-03-31 11:08:56 +00:00
|
|
|
nn := n.(*stmt.ElseIf)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-31 11:08:56 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ElseifToken)
|
|
|
|
io.WriteString(p.w, "elseif")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-31 11:08:56 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.Stmt)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-31 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtElse(n node.Node) {
|
2018-03-31 11:08:56 +00:00
|
|
|
nn := n.(*stmt.Else)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-31 11:08:56 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ElseToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "else")
|
2018-03-31 11:08:56 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.Stmt)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-31 11:08:56 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtExpression(n node.Node) {
|
2018-03-19 20:50:07 +00:00
|
|
|
nn := n.(*stmt.Expression)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-19 20:50:07 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-03-20 10:21:21 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-19 20:50:07 +00:00
|
|
|
}
|
2018-03-28 20:44:02 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtFinally(n node.Node) {
|
2018-03-31 11:17:05 +00:00
|
|
|
nn := n.(*stmt.Finally)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-31 11:17:05 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.FinallyToken)
|
|
|
|
io.WriteString(p.w, "finally")
|
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-31 11:17:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtFor(n node.Node) {
|
2018-03-31 11:49:29 +00:00
|
|
|
nn := n.(*stmt.For)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-31 11:49:29 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ForToken)
|
|
|
|
io.WriteString(p.w, "for")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint(",", nn.Init)
|
|
|
|
p.printMeta(nn, meta.ForInitSemicolonToken)
|
|
|
|
io.WriteString(p.w, ";")
|
|
|
|
p.joinPrint(",", nn.Cond)
|
|
|
|
p.printMeta(nn, meta.ForCondSemicolonToken)
|
|
|
|
io.WriteString(p.w, ";")
|
|
|
|
p.joinPrint(",", nn.Loop)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-31 11:49:29 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.Stmt)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-31 11:49:29 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtForeach(n node.Node) {
|
2018-03-31 11:49:29 +00:00
|
|
|
nn := n.(*stmt.Foreach)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-31 11:49:29 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ForeachToken)
|
|
|
|
io.WriteString(p.w, "foreach")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AsToken)
|
|
|
|
io.WriteString(p.w, "as")
|
2018-03-31 11:49:29 +00:00
|
|
|
|
|
|
|
if nn.Key != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Key)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.DoubleArrowToken)
|
|
|
|
io.WriteString(p.w, "=>")
|
2018-03-31 11:49:29 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-31 11:49:29 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.Stmt)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-31 11:49:29 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtFunction(n node.Node) {
|
2018-03-31 11:49:29 +00:00
|
|
|
nn := n.(*stmt.Function)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-03-31 11:49:29 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.FunctionToken)
|
|
|
|
io.WriteString(p.w, "function")
|
2018-03-31 11:49:29 +00:00
|
|
|
|
|
|
|
if nn.ReturnsRef {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AmpersandToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "&")
|
2018-03-31 11:49:29 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.FunctionName)
|
2018-03-31 11:49:29 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "(")
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.Params)
|
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-03-31 11:49:29 +00:00
|
|
|
|
|
|
|
if nn.ReturnType != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.ReturnType, meta.ColonToken)
|
|
|
|
io.WriteString(p.w, ":")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.ReturnType)
|
2018-03-31 11:49:29 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-31 11:49:29 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtGlobal(n node.Node) {
|
2018-04-01 12:58:45 +00:00
|
|
|
nn := n.(*stmt.Global)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 12:58:45 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.GlobalToken)
|
|
|
|
io.WriteString(p.w, "global")
|
|
|
|
p.joinPrint(",", nn.Vars)
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 12:58:45 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtGoto(n node.Node) {
|
2018-04-01 12:58:45 +00:00
|
|
|
nn := n.(*stmt.Goto)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 12:58:45 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.GotoToken)
|
|
|
|
io.WriteString(p.w, "goto")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Label)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 12:58:45 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtGroupUse(n node.Node) {
|
2018-04-01 12:58:45 +00:00
|
|
|
nn := n.(*stmt.GroupUse)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 12:58:45 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.UseToken)
|
|
|
|
io.WriteString(p.w, "use")
|
2018-04-01 12:58:45 +00:00
|
|
|
|
|
|
|
if nn.UseType != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.UseType)
|
2018-04-01 12:58:45 +00:00
|
|
|
}
|
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn, meta.UseLeadingNsSeparatorToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Prefix)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NsSeparatorToken)
|
|
|
|
io.WriteString(p.w, "\\")
|
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
|
|
|
p.joinPrint(",", nn.UseList)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn, meta.CommaToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "}")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 12:58:45 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtHaltCompiler(n node.Node) {
|
2018-07-02 17:48:55 +00:00
|
|
|
nn := n.(*stmt.HaltCompiler)
|
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
|
|
|
p.printMeta(n, meta.HaltCompilerToken)
|
|
|
|
io.WriteString(p.w, "__halt_compiler")
|
|
|
|
p.printMeta(n, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.printMeta(n, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(n, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 12:58:45 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtIf(n node.Node) {
|
2018-04-01 14:07:07 +00:00
|
|
|
nn := n.(*stmt.If)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 14:07:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.IfToken)
|
|
|
|
io.WriteString(p.w, "if")
|
|
|
|
p.printMeta(n, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-04-01 14:07:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.Stmt)
|
2018-04-01 14:07:07 +00:00
|
|
|
|
|
|
|
if nn.ElseIf != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.ElseIf)
|
2018-04-01 14:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Else != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Else)
|
2018-04-01 14:07:07 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 14:07:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtInlineHTML(n node.Node) {
|
2018-04-01 14:07:07 +00:00
|
|
|
nn := n.(*stmt.InlineHtml)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 14:07:07 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.InlineHTMLToken)
|
2018-07-29 08:44:38 +00:00
|
|
|
// io.WriteString(p.w, "?>")
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, nn.Value)
|
2018-07-29 08:44:38 +00:00
|
|
|
// io.WriteString(p.w, "<?php")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 14:07:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtInterface(n node.Node) {
|
2018-04-01 21:28:01 +00:00
|
|
|
nn := n.(*stmt.Interface)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 21:28:01 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.InterfaceToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "interface")
|
2018-04-01 21:28:01 +00:00
|
|
|
|
|
|
|
if nn.InterfaceName != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.InterfaceName)
|
2018-04-01 21:28:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Extends != nil {
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.Extends, meta.NodeStart)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.Extends, meta.ExtendsToken)
|
|
|
|
io.WriteString(p.w, "extends")
|
|
|
|
p.joinPrint(",", nn.Extends.InterfaceNames)
|
2018-04-01 21:28:01 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 21:28:01 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtLabel(n node.Node) {
|
2018-04-01 21:28:01 +00:00
|
|
|
nn := n.(*stmt.Label)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 21:28:01 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.LabelName)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.ColonToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ":")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 21:28:01 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtNamespace(n node.Node) {
|
2018-04-01 21:28:01 +00:00
|
|
|
nn := n.(*stmt.Namespace)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, "namespace")
|
2018-04-02 19:50:36 +00:00
|
|
|
|
|
|
|
if nn.NamespaceName != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.NamespaceName)
|
2018-04-02 19:50:36 +00:00
|
|
|
}
|
2018-04-01 21:28:01 +00:00
|
|
|
|
|
|
|
if nn.Stmts != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-04-01 21:28:01 +00:00
|
|
|
} else {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.SemiColonToken)
|
2018-04-01 21:28:01 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 21:28:01 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtNop(n node.Node) {
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(n, meta.NodeStart)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.SemiColonToken)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(n, meta.NodeEnd)
|
2018-04-01 21:43:27 +00:00
|
|
|
}
|
2018-03-31 11:17:05 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtPropertyList(n node.Node) {
|
2018-04-01 21:43:27 +00:00
|
|
|
nn := n.(*stmt.PropertyList)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 21:43:27 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint("", nn.Modifiers)
|
|
|
|
p.joinPrint(",", nn.Properties)
|
|
|
|
p.printMeta(n, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-31 11:17:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtProperty(n node.Node) {
|
2018-04-01 21:43:27 +00:00
|
|
|
nn := n.(*stmt.Property)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 21:43:27 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-04-01 21:43:27 +00:00
|
|
|
|
|
|
|
if nn.Expr != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(n, meta.EqualToken)
|
|
|
|
io.WriteString(p.w, "=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-04-01 21:43:27 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 21:43:27 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtReturn(n node.Node) {
|
2018-04-01 21:43:27 +00:00
|
|
|
nn := n.(*stmt.Return)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 21:43:27 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ReturnToken)
|
|
|
|
io.WriteString(p.w, "return")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-03-28 20:44:02 +00:00
|
|
|
}
|
2018-04-01 12:58:45 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtStaticVar(n node.Node) {
|
2018-04-01 21:59:31 +00:00
|
|
|
nn := n.(*stmt.StaticVar)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Variable)
|
2018-04-01 21:59:31 +00:00
|
|
|
|
|
|
|
if nn.Expr != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.EqualToken)
|
|
|
|
io.WriteString(p.w, "=")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-04-01 21:59:31 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 21:59:31 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtStatic(n node.Node) {
|
2018-04-01 21:59:31 +00:00
|
|
|
nn := n.(*stmt.Static)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 21:59:31 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.StaticToken)
|
|
|
|
io.WriteString(p.w, "static")
|
|
|
|
p.joinPrint(",", nn.Vars)
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 21:59:31 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtStmtList(n node.Node) {
|
2018-04-01 21:43:27 +00:00
|
|
|
nn := n.(*stmt.StmtList)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 21:43:27 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 21:43:27 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtSwitch(n node.Node) {
|
2018-04-01 21:59:31 +00:00
|
|
|
nn := n.(*stmt.Switch)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 21:59:31 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SwitchToken)
|
|
|
|
io.WriteString(p.w, "switch")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-04-01 21:59:31 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.CaseList, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn.CaseList, meta.CaseSeparatorToken)
|
2018-04-29 20:10:56 +00:00
|
|
|
p.printNodes(nn.CaseList.Cases)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.CaseList, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 21:59:31 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtThrow(n node.Node) {
|
2018-04-01 22:29:24 +00:00
|
|
|
nn := n.(*stmt.Throw)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 22:29:24 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.ThrowToken)
|
|
|
|
io.WriteString(p.w, "throw")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Expr)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtTraitMethodRef(n node.Node) {
|
2018-04-01 22:29:24 +00:00
|
|
|
nn := n.(*stmt.TraitMethodRef)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 22:29:24 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
if nn.Trait != nil {
|
|
|
|
p.Print(nn.Trait)
|
|
|
|
p.printMeta(nn, meta.PaamayimNekudotayimToken)
|
|
|
|
io.WriteString(p.w, "::")
|
|
|
|
}
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Method)
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtTraitUseAlias(n node.Node) {
|
2018-04-01 22:29:24 +00:00
|
|
|
nn := n.(*stmt.TraitUseAlias)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 22:29:24 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Ref)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AsToken)
|
|
|
|
io.WriteString(p.w, "as")
|
2018-04-01 22:29:24 +00:00
|
|
|
|
|
|
|
if nn.Modifier != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Modifier)
|
2018-04-01 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Alias != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Alias)
|
2018-04-01 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtTraitUsePrecedence(n node.Node) {
|
2018-04-01 22:29:24 +00:00
|
|
|
nn := n.(*stmt.TraitUsePrecedence)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 22:29:24 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Ref)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.InsteadofToken)
|
|
|
|
io.WriteString(p.w, "insteadof")
|
|
|
|
p.joinPrint(",", nn.Insteadof)
|
2018-04-01 22:29:24 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtTraitUse(n node.Node) {
|
2018-04-01 22:29:24 +00:00
|
|
|
nn := n.(*stmt.TraitUse)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 22:29:24 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.UseToken)
|
|
|
|
io.WriteString(p.w, "use")
|
|
|
|
p.joinPrint(",", nn.Traits)
|
2018-04-01 22:29:24 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
if adaptationList, ok := nn.TraitAdaptationList.(*stmt.TraitAdaptationList); ok {
|
|
|
|
p.printMeta(adaptationList, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
|
|
|
p.printNodes(adaptationList.Adaptations)
|
|
|
|
p.printMeta(adaptationList, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-04-01 22:29:24 +00:00
|
|
|
} else {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn.TraitAdaptationList, meta.SemiColonToken)
|
2018-04-01 22:29:24 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 22:29:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtTrait(n node.Node) {
|
2018-04-02 09:41:47 +00:00
|
|
|
nn := n.(*stmt.Trait)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.TraitToken)
|
|
|
|
io.WriteString(p.w, "trait")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.TraitName)
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-02 09:41:47 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtTry(n node.Node) {
|
2018-04-02 09:41:47 +00:00
|
|
|
nn := n.(*stmt.Try)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.TryToken)
|
|
|
|
io.WriteString(p.w, "try")
|
|
|
|
p.printMeta(nn, meta.OpenCurlyBracesToken)
|
|
|
|
io.WriteString(p.w, "{")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Stmts)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseCurlyBracesToken)
|
2018-04-03 16:20:55 +00:00
|
|
|
io.WriteString(p.w, "}")
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-04-02 19:50:36 +00:00
|
|
|
if nn.Catches != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.printNodes(nn.Catches)
|
2018-04-02 19:50:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if nn.Finally != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Finally)
|
2018-04-02 19:50:36 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-02 09:41:47 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtUnset(n node.Node) {
|
2018-04-02 09:41:47 +00:00
|
|
|
nn := n.(*stmt.Unset)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.UnsetToken)
|
|
|
|
io.WriteString(p.w, "unset")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
|
|
|
p.joinPrint(",", nn.Vars)
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn, meta.CommaToken)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
|
|
|
io.WriteString(p.w, ")")
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-02 09:41:47 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtUseList(n node.Node) {
|
2018-04-02 09:41:47 +00:00
|
|
|
nn := n.(*stmt.UseList)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.UseToken)
|
|
|
|
io.WriteString(p.w, "use")
|
2018-04-02 09:41:47 +00:00
|
|
|
|
|
|
|
if nn.UseType != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.UseType)
|
2018-04-02 09:41:47 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.joinPrint(",", nn.Uses)
|
|
|
|
p.printMeta(nn, meta.SemiColonToken)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-02 09:41:47 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtUse(n node.Node) {
|
2018-04-01 12:58:45 +00:00
|
|
|
nn := n.(*stmt.Use)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-01 12:58:45 +00:00
|
|
|
|
|
|
|
if nn.UseType != nil {
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.UseType)
|
2018-04-01 12:58:45 +00:00
|
|
|
}
|
|
|
|
|
2018-07-29 08:44:38 +00:00
|
|
|
p.printMeta(nn, meta.UseLeadingNsSeparatorToken)
|
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Use)
|
2018-04-01 12:58:45 +00:00
|
|
|
|
|
|
|
if nn.Alias != nil {
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.AsToken)
|
|
|
|
io.WriteString(p.w, "as")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Alias)
|
2018-04-01 12:58:45 +00:00
|
|
|
}
|
2018-07-02 17:48:55 +00:00
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-01 12:58:45 +00:00
|
|
|
}
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-04-02 20:57:22 +00:00
|
|
|
func (p *Printer) printStmtWhile(n node.Node) {
|
2018-04-02 09:41:47 +00:00
|
|
|
nn := n.(*stmt.While)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.NodeStart)
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.WhileToken)
|
|
|
|
io.WriteString(p.w, "while")
|
|
|
|
p.printMeta(nn, meta.OpenParenthesisToken)
|
|
|
|
io.WriteString(p.w, "(")
|
2018-04-02 20:57:22 +00:00
|
|
|
p.Print(nn.Cond)
|
2018-07-02 17:48:55 +00:00
|
|
|
p.printMeta(nn, meta.CloseParenthesisToken)
|
2018-04-02 20:57:22 +00:00
|
|
|
io.WriteString(p.w, ")")
|
2018-04-02 09:41:47 +00:00
|
|
|
|
2018-07-02 17:48:55 +00:00
|
|
|
p.Print(nn.Stmt)
|
|
|
|
|
|
|
|
p.printMeta(nn, meta.NodeEnd)
|
2018-04-02 09:41:47 +00:00
|
|
|
}
|