go-toml/lexer/syn_comments.go

22 lines
518 B
Go

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