simple RE?. if u answer, then i donate $1 to ...
Gareth.McCaughan at pobox.com
Mon May 14 16:48:29 EDT 2001
> the concept is that i do not care if there is leading white space or not. i
> do care that the first non-white space character is NOT a single quote. i am
> trying to write a simple parser for m$-visual basic source code and a
> leading single quote means a comment.
> if you know of a python based parser for vb code, please let me know.
REs are probably not really what you want. Run each line
through string.strip (because you don't care about leading
or trailing whitespace) and then check the first character
line = string.strip(line)
if line=="'": return
... now you can do the real work ...
If I recall right, a single-quote introduces a comment
*anywhere* in a VB line, except in a string. That's a
bit more painful to deal with (whether or not you use
Gareth McCaughan Gareth.McCaughan at pobox.com
.sig under construc
More information about the Python-list