megaparsack
megaparsack copied to clipboard
string-ci/p only compares first char case-insensitively
Hi, I had a few things failing and narrowed it down to the use of string-ci/p:
(parse-string (string-ci/p "LDA") "lda")
=>
(failure (message (srcloc 'string 1 0 1 2) #\d '("DA")))
I think it's due to the fact that string-ci/p calls chars/p, which only uses char-parser on the first character, before defaulting to string/p when recurring:
(define (string-ci/p str)
(chars/p str char-ci/p))
(define (chars/p str char-parser)
(if (zero? (string-length str))
(pure "")
(label/p str (do (char-parser (string-ref str 0))
(string/p (substring str 1)) ;should be (chars/p (substring str 1) char-parser) ?
(pure str)))))
Thank you.
Seconded, having this issue. The fix in #29 looks right, although the test-case for it looks wrong.