1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
package ast
import (
"strconv"
"strings"
)
type Comment struct {
Value string
Position *Position
}
func (c *Comment) Text() string {
return strings.TrimPrefix(c.Value, "#")
}
type CommentGroup struct {
List []*Comment
}
func (c *CommentGroup) Dump() string {
if len(c.List) == 0 {
return ""
}
var builder strings.Builder
for _, comment := range c.List {
builder.WriteString(comment.Value)
builder.WriteString("\n")
}
return strconv.Quote(builder.String())
}
|