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