* Ignores comments
* Ignores << variable >>
* Ignores format strings ("You")
* Produces more attractive output for proofreading
* Only runs under Perl 5 -- sorry, Mac users, but there's probably a much
better way to do this on the Mac anyway.
* Runs much more slowly. Still, though, I was able to run the
250K-plus WorldClass include file through it on a heavily-trafficked
mid-range SparcStation in under a second.
Do not use the previous version! It won't break anything, but it probably
won't work, either. Sorry to be so impetuous. More bugs are certainly in
there and I'd like to hear about them.
It should go without saying, but be sure your code compiles before running
untads on it--if tadsc doesn't like it, there's a good chance untads won't
either.
Thanks,
Matthew
---Cut Here---
#!/usr/bin/perl -0777
# The -0777 is important! It means "read in the whole file instead of
# iterating through it line-by-line." If your system doesn't support
# hash-bang notation, be sure to put this option on the perl command line.
# untads -- Extract user-readable text from TADS source files
# for spell-checking or proofreading
# by Matthew Amster
# placed in the public domain
# usage:
# untads file.t > output.txt
# OR untads file.t | spell
while( <> ) { # Actually slurping whole file
s#/\*.*?\*/##gs; # Kill C comments
s#//.*?\n#\n#g; # Kill C++ comments
s/<<.*>>//g; # Kill variable includes
s/\w+//g; # Kill format strings
s/\\./ /g; # Kill escape sequences (and apostrophes...)
s/\n[\t ]+/\n/g; # Collapse line indents
while( /'([^']*)'|"([^"]*)"/g ) { # Anything between single or double Qs
print "$1$2\n";
}
}