|
|
1.1 ! root 1: .TH SNOCONE 1 ! 2: .CT 1 prog_other ! 3: .SH NAME ! 4: snocone \- snobol with syntactic sugar ! 5: .SH SYNOPSIS ! 6: .B snocone ! 7: .I file ... ! 8: .SH DESCRIPTION ! 9: .I Snocone ! 10: is a programming language, syntactically ! 11: similar to C, that compiles into ! 12: .SM SNOBOL4. ! 13: The Snocone compiler translates the concatenation of all ! 14: the input files into a ! 15: .SM SNOBOL4 ! 16: program, which it writes in ! 17: .FR a.out . ! 18: When ! 19: .F a.out ! 20: is executed, the ! 21: .SM SNOBOL4 ! 22: interpreter will automatically be invoked. ! 23: A synopsis of Snocone syntax follows. ! 24: .SS Lexical conventions ! 25: .br ! 26: Everything after the first unquoted ! 27: .L # ! 28: on an input line is ignored. ! 29: .br ! 30: Statements normally end at the end of the line. ! 31: If the last character on a line is an operator, ! 32: open parenthesis or bracket, or comma, the statement is ! 33: continued on the next line. ! 34: .SS "Binary operators, \fRgrouped by decreasing precedence" ! 35: .TP ! 36: .B [] ! 37: Array and table indexing (denoted in ! 38: .SM SNOBOL4 ! 39: by ! 40: .LR <> ). ! 41: .PD 0 ! 42: .TP ! 43: .B $ . ! 44: conditional and immediate pattern value assignment, ! 45: as in ! 46: .SM SNOBOL4 ! 47: .TP ! 48: .B ^ ! 49: power; right-associative as in ! 50: .SM SNOBOL4 ! 51: .TP ! 52: .B * / % ! 53: multiplication, division, remainder; ! 54: unlike ! 55: .SM SNOBOL4, ! 56: all have the same precedence. ! 57: .TP ! 58: .B + - ! 59: addition, subtraction ! 60: .TP ! 61: .B ! 62: < > <= >= == != :<: :>: :<=: :>=: :==: :!=: ! 63: comparison operators; the ones surrounded by colons ! 64: compare strings, the others compare numbers. ! 65: These operators behave as ! 66: .SM SNOBOL4 ! 67: predicates: they return ! 68: the null string if the condition is true, ! 69: and fail if it is false. ! 70: .TP ! 71: .B && ! 72: concatenation; ! 73: evaluates its right operand ! 74: only after its left operand has been successfully ! 75: evaluated. ! 76: It therefore acts as logical ! 77: .I and ! 78: when applied to predicates. ! 79: The null string may be concatenated to any value. ! 80: .TP ! 81: .B |\^| ! 82: the value of the left operand if possible, otherwise ! 83: the value of the right operand. ! 84: .TP ! 85: .B | ! 86: pattern value alternation. ! 87: .TP ! 88: .B ? ! 89: pattern match. ! 90: Returns the part of the left operand matched by the ! 91: right operand, which must be a pattern. ! 92: May be used on the left of an assignment ! 93: if the left operand is appropriate. ! 94: Right-associative. ! 95: .TP ! 96: .B = ! 97: assignment ! 98: .PD ! 99: .SS Unary operators ! 100: .TP ! 101: .B + ! 102: The numeric equivalent of its argument. ! 103: .PD 0 ! 104: .TP ! 105: .B - ! 106: The numeric equivalent of its argument, with the sign reversed. ! 107: .TP ! 108: .B * ! 109: Unevaluated expression, as in ! 110: .SM SNOBOL4. ! 111: .TP ! 112: .B $ ! 113: If ! 114: .I v ! 115: is a value of type ! 116: .BR name , ! 117: then ! 118: .BI $ v ! 119: is the variable of that name. ! 120: .TP ! 121: .B @ ! 122: Pattern matching cursor assignment. ! 123: .TP ! 124: .B ~ ! 125: Logical negation: returns the null string if its argument ! 126: fails, and fails otherwise. ! 127: .TP ! 128: .B ? ! 129: Returns the null string if its argument succeeds, ! 130: and fails otherwise. ! 131: .TP ! 132: .B \&. ! 133: Returns a value of type ! 134: .B name ! 135: that refers to its (lvalue) argument. ! 136: .PD ! 137: .SS Statements ! 138: .PP ! 139: Statements may be prefixed by one or more labels. ! 140: A label is an identifier followed by a colon, as in C. ! 141: All labels are global: ! 142: it is a good idea to prefix labels in procedures ! 143: with the name of the procedure. ! 144: .TP ! 145: .I expression ! 146: The given ! 147: .I expression ! 148: is evaluated for its side effects. ! 149: .TP ! 150: .BI { " statement ... " } ! 151: The ! 152: .I statements ! 153: are executed sequentially. ! 154: .TP ! 155: .BI "if (" expression ) " statement \fR[ " else " statement\fR ]" ! 156: If evaluation of the ! 157: .I expression ! 158: succeeds, the first ! 159: .I statement ! 160: is executed. ! 161: Otherwise, the second ! 162: .IR statement , ! 163: if any, is executed. ! 164: An ! 165: .I else ! 166: belongs to the closest unmatched ! 167: .BR if . ! 168: .TP ! 169: .BI "while (" expression ") " statement ! 170: The ! 171: .I statement ! 172: is executed repeatedly, as long as the ! 173: .I expression ! 174: can be successfully evaluated. ! 175: .TP ! 176: .BI "do " statement " while (" expression ) ! 177: Like the ! 178: .B while ! 179: statement, except that the ! 180: .I statement ! 181: is executed once before the first time the ! 182: .I expression ! 183: is evaluated. ! 184: .TP ! 185: .B ! 186: for (\fIe1\fP, \fIe2\fP, \fIe3\fP) \fIstatement\fP ! 187: As in C, except that commas are used instead of semicolons. ! 188: .TP ! 189: .BR return " [\fIexpression\fP]" ! 190: returns the value of the ! 191: .I expression ! 192: from the current function. ! 193: If ! 194: .I expression ! 195: fails or is missing, the value returned is that of the ! 196: variable with the same name as the function. ! 197: If that variable was never set, the function returns ! 198: the null string. ! 199: .TP ! 200: .BR nreturn " [\fIexpression\fP]" ! 201: The ! 202: .I expression ! 203: must be the name of a variable. ! 204: That variable is returned from the current ! 205: function as an lvalue. ! 206: If the ! 207: .I expression ! 208: fails or is missing, the variable with the ! 209: same name as the function must have been set to the ! 210: name of a variable. ! 211: .TP ! 212: .B freturn ! 213: The current function returns failure. ! 214: .TP ! 215: .BI goto " label" ! 216: Transfer control to the given ! 217: .I label. ! 218: .HP Procedures ! 219: .PP ! 220: Procedures may not be textually nested, but may be recursive ! 221: and may call each other in forward references. ! 222: The general form of a procedure declaration is: ! 223: .IP ! 224: .B ! 225: procedure \fIname\fP (\fIargs\fP) \fIlocals\fP { \fIstatement ... \fP} ! 226: .PP ! 227: The ! 228: .I args ! 229: and ! 230: .I locals ! 231: are lists of variable names, separated by commas. ! 232: Since Snocone is a dynamically typed language, further ! 233: declarations are not necessary. ! 234: Although procedures are not textually nested, names are ! 235: dynamically scoped: a procedure can reference the local variables ! 236: and parameters of its caller as if they were global variables. ! 237: .HP Input-Output ! 238: .PP ! 239: Assigning a (string) value to the variable ! 240: .L output ! 241: causes that value to be written as a single line on the ! 242: standard output. ! 243: Accessing the variable ! 244: .L input ! 245: causes a line to be read from the standard input. ! 246: The access fails at end of file. ! 247: Accessing or assigning to the variable ! 248: .L terminal ! 249: causes a line to be read from or written to the ! 250: standard error file. ! 251: Other input-output is as implemented by ! 252: the Macrospitbol interpreter; see ! 253: .IR langs (1). ! 254: .SH SEE ALSO ! 255: A. R. Koenig, ! 256: `The Snocone Programming Language', ! 257: this manual, Volume 2 ! 258: .br ! 259: .IR langs (1) ! 260: .SH BUGS ! 261: Run-time diagnostics refer to ! 262: .SM SNOBOL4 ! 263: source statement numbers, ! 264: not to Snocone line numbers. ! 265: .br ! 266: Extremely long statements can overflow the ! 267: .SM SNOBOL4 ! 268: compiler's ! 269: limits on input line length.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.