diff --git a/node.go b/node.go index a88f698..90bc2d3 100644 --- a/node.go +++ b/node.go @@ -621,6 +621,32 @@ func (this *conversionState) convertNoFreeFloating(n_ node.Node) (string, error) return "fmt.Print(" + quoted + ")\n", nil // newline - standalone statement + case *stmt.ConstList: + consts := make([]string, 0, len(n.Consts)) + for _, c_ := range n.Consts { + c, ok := c_.(*stmt.Constant) + if !ok { + return "", parseErr{c_, fmt.Errorf("expected stmt.Constant")} + } + + // TODO c.PhpDocComment + + constName := c.ConstantName.(*node.Identifier).Value + + rvalue, err := this.convert(c.Expr) + if err != nil { + return "", parseErr{c, err} + } + + consts = append(consts, constName+" = "+rvalue) + } + + if len(n.Consts) == 1 { + return "const " + consts[0] + "\n", nil + } else { + return "const (\n" + strings.Join(consts, "\n") + ")\n", nil + } + case *stmt.If: hasCondAssign, err := hasInteriorAssignment(n.Cond)