man(1) Manual page archive


     SNOCONE(1)                                             SNOCONE(1)

     NAME
          snocone - snobol with syntactic sugar

     SYNOPSIS
          snocone file ...

     DESCRIPTION
          Snocone is a programming language, syntactically similar to
          C, that compiles into SNOBOL4.  The Snocone compiler trans-
          lates the concatenation of all the input files into a SNO-
          BOL4 program, which it writes in a.out. The first line of
          a.out arranges that if a.out is executed, the SNOBOL4 inter-
          preter will automatically be invoked.

          A synopsis of the Snocone syntax follows.

          Lexical conventions
                Everything after the first # on an input line is
                ignored.
                Statements normally end at the end of the line.  If
                the last character on a line is an operator, open
                parenthesis or bracket, or comma, the statment is con-
                tinued on the next line.
                Spaces generally follow C conventions.

          Binary operators (grouped by decreasing precedence):

          $ .   conditional and immediate pattern value assignment, as
                in SNOBOL4
          ^     power; right-associative as in SNOBOL4
          * / % multiplication, division, remainder; unlike SNOBOL4,
                all have the same precedence.
          + -   addition, subtraction
          <  >  <=  >=  ==  !=  :<:  :>:  :<=:  :>=:  :==:  :!=:
                comparison operators; the ones surrounded by colons do
                character comparisons, the others do numeric compar-
                isons.  These operators behave as SNOBOL4 predicates:
                they return the null string if the indicated condition
                is true, and fail if it is false.
          &&    concatenation; evaluates its right operand only after
                its left operand has been successfully evaluated.  It
                therefore acts as logical and when applied to predi-
                cates.  The null string may be concatenated to any
                value.
          ||    the value of the left operand if possible, otherwise
                the value of the right operand.  Behaves as logical or
                when applied to predicates.
          |     pattern value alternation.
          ?     pattern match.  Returns the part of the left operand
                matched by the right operand, which must be a pattern.

     SNOCONE(1)                                             SNOCONE(1)

                May be used on the left of an assignment if the left
                operand is appropriate.  Right-associative.
          =     assignment

          Unary operators; all map to their SNOBOL4 equivalents and
                have the same (highest) precedence.

          +     The numeric equivalent of its argument.
          -     The numeric equivalent of its argument, with the sign
                reversed.
          *     Unevaluated expression, as in SNOBOL4.
          $     If v is a value of type name, then $v is the variable
                of that name.
          @     Pattern matching cursor assignment.
          ~     Logical negation: returns the null string if its argu-
                ment fails, and fails otherwise.
          ?     Returns the null string if its argument succeeds, and
                fails otherwise.
          Returns a value of type
                name that refers to its (lvalue) argument.

          Statements

          Statements may be prefixed by one or more labels.  A label
          is an identifier followed by a colon, as in C.  All labels
          are global: it is a good idea to begin labels in procedures
          with the name of the procedure.

          expression
               The given expression is evaluated for its side effects.

          { statement ... }
               The statements are executed sequentially.

          if (expression) statement [ else statement ]
               If evaluation of the expression succeeds, the first
               statement is executed.  Otherwise, the second
               statement, if any, is executed.  An else belongs to the
               closest unmatched if.

          while (expression) statement
               The statement is executed repeatedly, as long as the
               expression can be successfully evaluated.

          do statement while (expression)
               Like the while statement, except that the statement is
               executed once before the first time the expression is
               evaluated.

          for (e1, e2, e3) statement
               As in C, except that commas are used instead of semi-
               colons.

     SNOCONE(1)                                             SNOCONE(1)

          return [expression]
               returns the value of the expression from the current
               function.  If expression fails or is missing, the value
               returned is that of the variable with the same name as
               the function.  If that variable was never set, the
               function returns the null string.

          nreturn [expression]
               The expression must be the name of a variable.  That
               variable is returned from the current function as an
               lvalue.  If the expression fails or is missing, the
               variable with the same name as the function must have
               been set to the name of a variable.

          freturn
               The current function returns failure.

          goto label
               Transfer control to the given label.

          Procedures may not be textually nested, but may be recursive
          and may call each other in forward references.  The general
          form of a procedure declaration is:

                procedure name (args) locals { statement ... }

          The args and locals are lists of variable names, separated
          by commas.  Since Snocone is a dynamically typed language,
          further declarations are not necessary.  Although procedures
          are not textually nested, names are dynamically scoped: a
          procedure can reference the local variables and parameters
          of its caller as if they were global variables.

          Assigning a (string) value to the variable output causes
          that value to be written as a single line on the standard
          output.  Accessing the variable input causes a line to be
          read from the standard input.  The access fails at end of
          file.  Accessing or assigning to the variable terminal
          causes a line to be read from or written to the standard
          error file.  Other input-output is as implemented by the
          Macrospitbol interpreter (see spitbol(1)).

     BUGS
          Run-time diagnostics refer to SNOBOL4 source statement num-
          bers, not to Snocone line numbers.
          Extremely long statements can overflow the SNOBOL4
          compiler's limits on input line length.