Text-extraction util for TADSers on Mac or Unix


Tue, 28 Nov 95 13:18:58 PDT

No one asked for this, but it's short, so I'm going to post it anyway. I
recently moved my TADS game development from my slow PC to a Unix shell
account. Great decision (if you have less than a 486/50 or a slow Mac
and have Unix access, try this). Unfortunately, this left me unable to
easily use Rick LaBach's fine TEXTOUT utility. TEXTOUT extracts into a
separate file all the user-visible text in your TADS code for
spell-checking.

So I wrote my own. It's in perl, which makes it best for Unix but will
work on a Mac, too. Or essentially any other platform, for that matter.
If you're on PC, use TEXTOUT--it's much faster.

Potential problem: You need enough free memory (including swap) to hold
the entire TADS source file. I couldn't think of a better way to do it,
since strings can span lines in TADS. Then again, I only spent ten minutes
on the thing.

Bugs, enhancements, comments to mamster@pomona.edu. I'll wait for the
first bug reports before uploading to gmd. Please let me know if you find
this useful!

Happy coding,
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/\\\S/ /g; # Get rid of escape sequences

while( /'([^']+)'|"([^"]+)"/g ) { # Anything between single or double Qs
print "$1$2\n"; # Is there a better way to do this?
}
}