go-toml/parser/syn_comments.go

24 lines
524 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) parsekit.StateFn {
p.SkipConsecutive(hash)
return stateCommentContent
}
// All characters up to the end of the line are included in the comment.
func stateCommentContent(p *parsekit.P) parsekit.StateFn {
switch {
case p.AtEndOfLine():
p.EmitLiteralTrim(ItemComment)
return p.ToParentState()
default:
p.AcceptAny()
return stateCommentContent
}
}