This shows you the differences between two versions of the page.
— |
tutorials:snobol [2013/07/10 02:57] (current) howellp created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | === Using SNOBOL/ | ||
+ | == Introduction == | ||
+ | |||
+ | SNOBOL (StriNg Oriented and symBOlic Language) is a generic name for a family of programming languages designed for the manipulation of strings. Among its features are symbolic naming of strings and pattern matching, making it especially suitable for text analysis. SNOBOL was developed in the 1960s at AT&T Bell Laboratories by David Farber, Ralph Griswold, and Ivan Polonsky. | ||
+ | |||
+ | The implementation of SNOBOL available on TWENEX.ORG is SITBOL20 and was developed at Stevens Institute of Technology. The documentation for SITBOL20 is not readily available. Nonetheless, | ||
+ | |||
+ | == Starting SNOBOL/ | ||
+ | |||
+ | To start SNOBOL, type " | ||
+ | |||
+ | |||
+ | @snobol | ||
+ | SITBOL> | ||
+ | |||
+ | At this point, SNOBOL is expecting a file-name or device-name for input. For example, | ||
+ | |||
+ | |||
+ | SITBOL> | ||
+ | or | ||
+ | SITBOL> | ||
+ | |||
+ | |||
+ | In the first case, SNOBOL will attempt to read and run the code in " | ||
+ | |||
+ | Here is an example of an interactive session in SITBOL20 at TWENEX.ORG. | ||
+ | |||
+ | @snobol | ||
+ | SITBOL> | ||
+ | * This is a comment. | ||
+ | OUTPUT = " | ||
+ | END | ||
+ | Hello, World! | ||
+ | SITBOL>/ | ||
+ | EXIT | ||
+ | @ | ||
+ | |||
+ | Note that comments begin in the first column and are prefixed with an asterisk. Although not shown, line continuation is indicated by a plus-sign in the first column. Likewise, labels begin in the first column. All other instructions should begin after the first column. By convention, instructions start at column 9 and GOTOs start at column 56 (it is not a rule; just try to be consistent). | ||
+ | |||
+ | To leave SNOBOL, type "/ | ||
+ | |||
+ | SITBOL>/ | ||
+ | EXIT | ||
+ | @ | ||
+ | |||
+ | You can also have SNOBOL load your program and begin running it by including the file-name of your program on the command line; e.g., | ||
+ | |||
+ | @snobol my_code.sno | ||
+ | |||
+ | == SNOBOL I/O on TWENEX.ORG == | ||
+ | |||
+ | SNOBOL has a few predefined variables reserved for I/O. For example, assignment from INPUT or to OUTPUT will read or write, respectively, | ||
+ | |||
+ | < | ||
+ | * Simple SNOBOL I/O example. | ||
+ | | ||
+ | | ||
+ | | ||
+ | END | ||
+ | </ | ||
+ | |||
+ | SNOBOL provides for greater control over I/O with the INPUT() and OUTPUT() functions. Parameters to these functions allow for association of names to input and output devices and files, as well as specification of I/O mode and format. Unfortunately, | ||
+ | |||
+ | Historically, | ||
+ | |||
+ | | ||
+ | |||
+ | which associates a name with a device reference number, and specifies the output format. The format option is a string in FORTRAN IV style. For example, | ||
+ | |||
+ | OUTPUT(' | ||
+ | |||
+ | Likewise, the INPUT() function takes the form | ||
+ | |||
+ | INPUT(' | ||
+ | |||
+ | which associates a name with a device reference number, and specifies that the resulting string is to have a given length. For example, | ||
+ | |||
+ | INPUT(' | ||
+ | |||
+ | These descriptions and examples of the INPUT() and OUTPUT() functions are from the " | ||
+ | |||
+ | INPUT(' | ||
+ | and | ||
+ | OUTPUT(' | ||
+ | |||
+ | The following example shows how to associate a name with an I/O device (or file) and specify format options in SITBOL20 at TWENEX.ORG. | ||
+ | |||
+ | < | ||
+ | * Example of INPUT() and OUTPUT() parameters. | ||
+ | * The ' | ||
+ | * being appended to output. | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | END | ||
+ | </ | ||
+ | |||
+ | Notice in the above example, output was specifically routed to the TTY: device and line-feeds were suppressed with the format option. Likewise, input was specifically taken from the TTY: device. | ||
+ | Device names, as listed in the " | ||
+ | |||
+ | * LISTING-DEVICE | ||
+ | * MTAn: Magnetic Tape | ||
+ | * DTAn: DEC Tape | ||
+ | * DSK: Disk | ||
+ | * PTP: Paper Tape Punch | ||
+ | * LPT: Line Printer | ||
+ | * TTY: | ||
+ | *CDP: Card Punch | ||
+ | * SOURCE-DEVICE | ||
+ | * MTAn: Magnetic Tape | ||
+ | * DTAn: DEC Tape | ||
+ | * DSK: Disk | ||
+ | * TTY: | ||
+ | * CDR: Card Reader | ||
+ | * PTR: Paper Tape Reader | ||
+ | |||
+ | No definitive reference has been identified that describes format options for the SITBOL20 INPUT() and OUTPUT() functions; however, they seem to correspond generally to those of CSNOBOL4 (snobol4 on SDF), but limited to one character. These are: | ||
+ | |||
+ | * A: For OUTPUT() the unit will be opened for append access. | ||
+ | * B: The unit will be opened for binary access. | ||
+ | * C: Character at a time I/O. | ||
+ | * T: Terminal mode. No newline characters are added on output. | ||
+ | * Q: Quiet mode. Turns off input echo on terminals. | ||
+ | * U: Update mode. The unit is opened for both input and output. | ||
+ | * W: Unbuffered writes. | ||
+ | |||
+ | |||
+ | == Bibliography & Resources == | ||
+ | |||
+ | Griswold, Ralph E., J. F. Poage, and I. P. Polonsky. //The Snobol4 Programming Language.// Second Edition. | ||
+ | ftp:// | ||
+ | |||
+ | Hockey, Susan M. //Snobol Programming for the Humanities.// | ||
+ | www.worldcat.org/ | ||
+ | |||
+ | SNOBOL4.ORG. //SNOBOL4 Resources.// | ||
+ | http:// | ||
+ | |||
+ | Wade, L. P. PDP-10 SNOBOL4 User's Guide. October 17, 1970.\\ | ||
+ | http:// | ||
+ | |||
+ | Wikipedia.org. // | ||
+ | https:// |