eatonphil/gosql

Report a `cursor` bug

bingbig opened this issue · 4 comments

Hi, It's an awesome project! But panic throw out when I run the code, it seems to be a problem caused by cursor++ @L413. Maybe you have fixed it already.

gosql/parser.go

Lines 402 to 414 in 6a788b6

atLeastOneSemicolon := false
for expectToken(tokens, cursor, tokenFromSymbol(semicolonSymbol)) {
cursor++
atLeastOneSemicolon = true
}
if !atLeastOneSemicolon {
helpMessage(tokens, cursor, "Expected semi-colon delimiter between statements")
return nil, errors.New("Missing semi-colon between statements")
}
cursor++
}

Looking forward to view more commits.

Hey! Could you include the full program you ran and the stacktrace?

$ go run cmd/libraryexample/main.go 
panic: Failed to parse, expected statement

goroutine 1 [running]:
main.main()
        /Users/liub/golang/gosql/cmd/libraryexample/main.go:17 +0x742
exit status 2

Gotcha, you were right. The extra cursor update on line 413 causes multiple statements to be parsed incorrectly. Fixed in b1e42e0.

Thank you!