php-parser/token/token.go

50 lines
923 B
Go
Raw Normal View History

2017-12-03 18:49:18 +00:00
package token
2018-01-05 15:03:59 +00:00
import (
"github.com/z7zmey/php-parser/comment"
)
2017-12-08 09:37:32 +00:00
type TokenInterface interface {
GetValue() string
GetStartLine() int
GetEndLine() int
2018-01-08 19:50:39 +00:00
Comments() []comment.Comment
SetComments(comments []comment.Comment) Token
2017-12-08 09:37:32 +00:00
}
2017-12-03 18:49:18 +00:00
type Token struct {
Value string
StartLine int
EndLine int
2018-01-05 11:01:14 +00:00
StartPos int
EndPos int
2018-01-08 19:50:39 +00:00
comments []comment.Comment
2017-12-03 18:49:18 +00:00
}
2018-01-05 11:01:14 +00:00
func NewToken(value []byte, startLine int, endLine int, startPos int, endPos int) Token {
2018-01-05 15:03:59 +00:00
return Token{string(value), startLine, endLine, startPos, endPos, nil}
2017-12-03 18:49:18 +00:00
}
func (t Token) String() string {
return string(t.Value)
}
2017-12-08 09:37:32 +00:00
func (t Token) GetValue() string {
return t.Value
}
func (t Token) GetStartLine() int {
return t.StartLine
}
func (t Token) GetEndLine() int {
return t.EndLine
}
2018-01-05 15:03:59 +00:00
2018-01-08 19:50:39 +00:00
func (t Token) Comments() []comment.Comment {
2018-01-05 15:03:59 +00:00
return t.comments
}
2018-01-08 19:50:39 +00:00
func (t Token) SetComments(comments []comment.Comment) Token {
2018-01-05 15:03:59 +00:00
t.comments = comments
return t
}