A golf contest is a programming contest where the winner is the coder who writes the shortest program to complete a task. This tool was designed to help Postscript golfers in golfing competitions such as http://golf.shinh.org.
It reads a postscript program and outputs a new program where tokens are converted to binary form in an attempt to reduce the byte size of the program. Features include:
Unnecessary whitespace is removed. Comments are removed. Operators such as 'add' and 'length' are reduced to their two byte binary representation. Tokens are not converted to binary if doing so would increase their length. Strings with escape codes such as (\n) are converted to strings containing the equivalent binary characters. Optional mode: binary tokens are not allowed. Limitations:
Embedding data in the program and reading it using (for example) 'currentfile 100 string readline' is not handled. For longer files (300 bytes+) it might be worth gzipping the program, but this is not supported. To attempt to reduce the size of a Postscript program, run the following command:
./psgolftool.py < program.ps > program.bin.ps
To disallow binary characters:
./psgolftool.py nobin < program.ps > program.nobin.ps
Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.