If one of the existing Perl modules already mentioned doesn't do it for you, I'd highly recommend a state machine; SQL is (from what I know) well enough defined that it should be quite a fun little exercise. However, I wouldn't do it character by character -- that's insane -- I'd go word by word (or rather, token by token).
And while I love C for its speed, I'd probably write it in Perl for speed of development -- at least until I started having performance problems anyways.
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds