Coincidentally, I got frustrated with PBASIC last year, so one night when I was bored I wrote a PBASIC preprocessor. It has nested If-then-else constructs, as well as do-while loops. I meant to post it here, but I never got around to it. You can take a look at it if you want. The source code is at:
http://www.cis.ohio-state.edu/~kiracofe/epbc-src.tgz
A linux binary is available at
http://www.cis.ohio-state.edu/~kiracofe/epbc-bin.tgz
It's written in straightforward C++, so it should compile in MS Visual C++ although I've never tried it. Note that you'll need lex if you want to modify the lexer. If there is interest, I'll try to get some Windows binaries available. Just e-mail me at
kiracofe.8@osu.edu.
As far as the structure of the compiler goes, it's pretty straightforward. I use lex to tokenize the input stream. I wrote the parser myself instead of using yacc (or bison or whatever) b/c the language was so simple, I figured this would be easier. Everything is implemented using C++ virtual functions. This makes the writing of nested constructs very easy. (e.g. we can call a function to output a statement without having to worry about what kind of statement it is, since each statement class knows how to "output itself"). Once you understand the BNF of the language (included in the README), the structure of the code should make sense, I hope...
If you have any comments, questions, or suggestions, let me know...