xgo/compiler/ast/inc_dec_stmt.go

30 lines
659 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
2019-01-11 13:27:28 +03:00
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
2019-01-09 10:17:42 +03:00
)
// IncDecStmt represents increment or decrement statement.
2019-01-09 10:17:42 +03:00
type IncDecStmt struct {
Expr Expr
Token token.Token
TokenPos source.Pos
2019-01-09 10:17:42 +03:00
}
func (s *IncDecStmt) stmtNode() {}
// Pos returns the position of first character belonging to the node.
func (s *IncDecStmt) Pos() source.Pos {
2019-01-09 10:17:42 +03:00
return s.Expr.Pos()
}
// End returns the position of first character immediately after the node.
func (s *IncDecStmt) End() source.Pos {
return source.Pos(int(s.TokenPos) + 2)
2019-01-09 10:17:42 +03:00
}
func (s *IncDecStmt) String() string {
return s.Expr.String() + s.Token.String()
}