##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: # Modified: 2016-12-03/20:07-0500 ##+ # # snobol.icn, run snobol4 programs # # Requires snobol4 # $define VERSION 0.1 link options procedure main(argv) opts := options(argv, "-h! -v! -source!", optError) if \opts["h"] then return showHelp() if \opts["v"] then return showVersion() if \opts["source"] then return showSource() # run the rest of the arguments as snobol4 files every arg := !argv do snobol(arg) end # # Run a snobol4 program, trim formfeeds # procedure snobol(filename) local sf sf := open("snobol4 " || filename, "p") | stop("no snobol4") while write(trim(read(sf), '\f', 0)) end # # show help, version and source info # procedure showVersion() write(&errout, &progname, " ", VERSION, " ", __DATE__) end procedure showHelp() showVersion() write(&errout, "Usage: snobol [opts] files...") write(&errout, "\t-h\tshow this help") write(&errout, "\t-v\tshow version") write(&errout, "\t-source\tlist source code") write(&errout) write(&errout, "all other arguments are run as SNOBOL4 sources") end procedure showSource() local f f := open(&file, "r") | stop("Source file ", &file, " unavailable") every write(!f) close(f) end # # options error # procedure optError(s) write(&errout, s) stop("Try ", &progname, " -h for more information") end