XP is just a number | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
It's not clear (at least, not to me) what you mean by "cleaning whitespace from source code". The first interpretation that comes to my mind would be something like "removing all whitespace that is not syntactically significant to the compiler/interpreter" for each progamming language in question.
If this is what you mean, there's still the question of what you want to do with comments in the source code (remove them entirely, or just normalize whitespace?); presumably, you'll need to be able to identify the beginnings and endings of quoted strings, so you can leave the enclosed whitespace as is (assuming you don't want to change the output of the program as a side effect of "cleaning" the source code). In any case, you're probably going to need something like Parse::RecDescent, which is, effectively, the perl version of "yacc". It'll be a challenge, and I wish you luck, but once you work out how the rules are stated, and figure out the rules you need for each language, switching from one rule set to another should be pretty trivial. If you mean something else by "cleaning whitespace", it would be hard for me to guess what that might be. In reply to Re: Cleaning Whitespace from Source Code
by graff
|
|