8000 Parsing an empty string causes odd behavior · Issue #7 · bzick/tokenizer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Parsing an empty string causes odd behavior #7
Closed
@dpedu

Description

@dpedu

This code panics on the marked line. It seems like IsValid() incorrectly returns true when it should return false since there are no more tokens available.

p := tokenizer.New()

stream := p.ParseString("")
defer stream.Close()

for stream.IsValid() {
    token := stream.CurrentToken()
    if token.Is(tokenizer.TokenInteger) { // <--- panic
        fmt.Println(token.ValueInt())
    }
    stream.GoNext()
}

I'm using 1.3.0 and the panic stack trace tells me the problem is here:

github.com/bzick/tokenizer.(*Token).Is(...)
	/xxx/go/pkg/mod/github.com/bzick/tokenizer@v1.3.0/token.go:220

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToDothis will be done

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0