go-toml/parser/syn_comments.go

24 lines
474 B
Go

package parser
import (
"github.com/mmakaay/toml/parsekit"
)
// A '#' hash symbol marks the rest of the line as a comment.
func stateCommentStart(p *parsekit.P) {
p.SkipConsecutive(hash)
p.RouteTo(stateCommentContent)
}
// All characters up to the end of the line are included in the comment.
func stateCommentContent(p *parsekit.P) {
switch {
case p.AtEndOfLine():
p.EmitLiteralTrim(ItemComment)
p.RouteReturn()
default:
p.AcceptAny()
p.RouteRepeat()
}
}