-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I was noticing that the ParserDispatcher can not complete cleanly, it gets no signal that the buffer has ended and you need to check it at the end. You can see it here in the example.
examples/parserlog/main.go
parser.Parse(dispatcher, bts)
if str != "" {
fmt.Printf("[Print] %s\n", str)
}having some irritation with checking and cleaning up state at the end, like shown here with the str != ""
It would be nice to add a nil terminating Sequence item to the sequence to allow the ParserDispatcher a chance to clean any state.
We would need to small change in the parser.Parse function to something like this.
// Parse parses the given dispatcher and byte buffer.
func (p *Parser) Parse(dispatcher ParserDispatcher, b []byte) {
for i := 0; i < len(b); i++ {
p.Advance(dispatcher, b[i], i < len(b)-1)
}
dispatcher(SequenceEnd(0)) /// <-- added line
}Thanks
Tom
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request