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.On(c.OneOrMore(hash)).Skip() 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() case p.On(any).Accept(): p.Repeat() default: p.UnexpectedInput("comment contents") } }