xgo/compiler/ast/for_in_stmt.go

33 lines
789 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
2019-01-11 13:27:28 +03:00
import "github.com/d5/tengo/compiler/source"
2019-01-09 10:17:42 +03:00
// ForInStmt represents a for-in statement.
2019-01-09 10:17:42 +03:00
type ForInStmt struct {
ForPos source.Pos
2019-01-09 10:17:42 +03:00
Key *Ident
Value *Ident
Iterable Expr
Body *BlockStmt
}
func (s *ForInStmt) stmtNode() {}
// Pos returns the position of first character belonging to the node.
func (s *ForInStmt) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return s.ForPos
}
// End returns the position of first character immediately after the node.
func (s *ForInStmt) End() source.Pos {
2019-01-09 10:17:42 +03:00
return s.Body.End()
}
func (s *ForInStmt) String() string {
if s.Value != nil {
return "for " + s.Key.String() + ", " + s.Value.String() + " in " + s.Iterable.String() + " " + s.Body.String()
}
return "for " + s.Key.String() + " in " + s.Iterable.String() + " " + s.Body.String()
}