Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing an empty string causes odd behavior #7

Closed
dpedu opened this issue Mar 17, 2023 · 2 comments
Closed

Parsing an empty string causes odd behavior #7

dpedu opened this issue Mar 17, 2023 · 2 comments
Labels
ToDo this will be done

Comments

@dpedu
Copy link

dpedu commented Mar 17, 2023

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
@bzick
Copy link
Owner

bzick commented Mar 17, 2023

I'll fix that

@bzick bzick added the ToDo this will be done label Mar 17, 2023
bzick added a commit that referenced this issue Apr 5, 2024
@bzick
Copy link
Owner

bzick commented Apr 5, 2024

Fixed in 1.4.4

@bzick bzick closed this as completed Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ToDo this will be done
Projects
None yet
Development

No branches or pull requests

2 participants