From 8f874944e34e7646689e6d96d5ce647542cbf4c8 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Thu, 11 Jan 2018 20:49:00 +0200 Subject: [PATCH] add token comments --- token/token.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/token/token.go b/token/token.go index 146cb14..0da6189 100644 --- a/token/token.go +++ b/token/token.go @@ -4,6 +4,7 @@ import ( "github.com/z7zmey/php-parser/comment" ) +// Token value returned by lexer type Token struct { Value string StartLine int @@ -13,6 +14,8 @@ type Token struct { comments []comment.Comment } +// NewToken Token constructor +// TODO: return pointer func NewToken(value []byte, startLine int, endLine int, startPos int, endPos int) Token { return Token{string(value), startLine, endLine, startPos, endPos, nil} } @@ -21,20 +24,12 @@ func (t Token) String() string { return string(t.Value) } -func (t Token) GetValue() string { - return t.Value -} -func (t Token) GetStartLine() int { - return t.StartLine -} -func (t Token) GetEndLine() int { - return t.EndLine -} - +// Comments returns attached comments func (t Token) Comments() []comment.Comment { return t.comments } +// SetComments attach comments func (t Token) SetComments(comments []comment.Comment) Token { t.comments = comments return t