xgo/ast/assign_stmt.go

38 lines
658 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
"strings"
"github.com/d5/tengo/source"
2019-01-09 10:17:42 +03:00
"github.com/d5/tengo/token"
)
type AssignStmt struct {
Lhs []Expr
Rhs []Expr
Token token.Token
TokenPos source.Pos
2019-01-09 10:17:42 +03:00
}
func (s *AssignStmt) stmtNode() {}
func (s *AssignStmt) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return s.Lhs[0].Pos()
}
func (s *AssignStmt) End() source.Pos {
2019-01-09 10:17:42 +03:00
return s.Rhs[len(s.Rhs)-1].End()
}
func (s *AssignStmt) String() string {
var lhs, rhs []string
for _, e := range s.Lhs {
lhs = append(lhs, e.String())
}
for _, e := range s.Rhs {
rhs = append(rhs, e.String())
}
return strings.Join(lhs, ", ") + " " + s.Token.String() + " " + strings.Join(rhs, ", ")
}