home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG051.ARK / INTRO.DOC < prev    next >
Text File  |  1984-04-29  |  22KB  |  602 lines

  1.             STAGE2 INTRODUCTION
  2.  
  3. COPYRIGHT:
  4.     Written:  06/15/79
  5.     Updated:  06/17/79
  6.  
  7.     This introductory material is the property of:
  8.         Dick Curtiss
  9.         843 NW 54th
  10.         Seattle, Washington  98107
  11.  
  12.     Permission is granted to copy for personal use only.
  13.  
  14.     This material may NOT be used for publication without written
  15.     permission of the author.
  16.  
  17. STAGE2 PROGRAMMING TECHNIQUE:
  18.     STAGE2 is unlike conventional languages and requires getting
  19.     used to a different way of approaching a problem.  By its nature,
  20.     STAGE2 forces a top down approach to problem solving using stepwise
  21.     refinement and recursive descent.  Expect to read this material
  22.     several times before it sinks in.  The best way to learn STAGE2 is
  23.     to study examples and experiment.  Good luck!
  24.  
  25. EXAMPLE PROBLEM:
  26.     Suppose it is desired to recognize the following WHILE statement
  27.     and translate it into assembler type language.
  28.  
  29.         WHILE ( X < Y )  PRINT X*Y : X = X + 1  ; Comment
  30.  
  31.     A top level macro would be used to recognize the "WHILE" as a keyword.
  32.     As part of the recognition process the statement would be broken into
  33.     three parts, "WHILE", "X < Y", and the rest of the line.  The first
  34.     step in the translation process is to generate a looping label.  Next,
  35.     "X < Y" would be passed on to a set of macros designed to generate a
  36.     sequence of assembler language instructions which evaluate the
  37.     conditional expression.  Then a "jump if false" instruction would be
  38.     generated to branch to the loop exit label.
  39.  
  40.     Next, the remainder of the line would be passed on to macros designed
  41.     to recursively break apart multiple statement lines and process each
  42.     single statement with still other specialized macros.  After
  43.     decomposition of the "WHILE" statement is complete, a jump instruction
  44.     is generated to branch to the looping label.  Finally, "WHILE"
  45.     statement processing is completed by generating a loop exit label.
  46.  
  47. EXAMPLE MACRO EXPANSION:
  48.     LOOP:
  49.         LOAD        X
  50.         CMP-LT        Y
  51.         J-FALSE        EXIT
  52.  
  53.         LOAD        X
  54.         MULTIPLY    Y
  55.         CALL        PRINT-RESULT
  56.  
  57.         LOAD        X
  58.         ADD        #1
  59.         STORE        X
  60.  
  61.         JUMP        LOOP
  62.     EXIT:
  63.  
  64. EXAMPLE MACROS:
  65.     WHILE$($)$#        To recognize WHILE statement
  66.     LOOP:!F13%            output looping label
  67.     CONDITION !20%            macro call to parse conditional expression
  68.         J-FALSE    EXIT!F13%   output exit jump
  69.     STATEMENT !30%            macro call to parse remainder of line
  70.         JUMP    LOOP!F13%   output loop jump
  71.     EXIT:!F13%            output loop exit label
  72.     % ------------------------- end of macro
  73.     CONDITION $<$#        To recognize less than compare
  74.         LOAD    !10!F13%    output load X instruction
  75.         CMP-LT    !20!F13%    output compare Y instruction
  76.     % ------------------------- end of macro
  77.     STATEMENT $:$#        To recognize and split multiple statement
  78.     PROCESS !10%            macro call to process single statement
  79.     STATEMENT !20%            recursive macro call to parse rest of line
  80.     % ------------------------- end of macro
  81.     STATEMENT $;$#        To recognize and split statement with comment
  82.     PROCESS !10%            macro call to process single statement
  83.     % ------------------------- end of macro
  84.     STATEMENT $#        To recognize single statement
  85.     PROCESS !10%            macro call to process single statement
  86.     % ------------------------- end of macro
  87.     PROCESS PRINT$#        To recognize and process PRINT statement
  88.         *** macro code not shown
  89.     % ------------------------- end of macro
  90.     PROCESS $=$#        To recognize and process assignment stmt.
  91.         *** macro code not shown
  92.     % ------------------------- end of macro
  93.  
  94. READING MACROS:
  95.     Macros consist of a template line followed by one or more code
  96.     body lines.  The macro is terminated by an empty code body line.
  97.  
  98.     Macro templates, which are terminated by a special template end
  99.     character, consist of character strings with special parameter
  100.     flag characters interspersed.
  101.  
  102.     Code body lines are terminated by a special code body line end
  103.     character.  An empty code body line (macro terminator) has the
  104.     code body line end character in column 1.  A special escape
  105.     character is used in code body lines for parameter reference
  106.     and invocation of processor functions.
  107.  
  108.     Characters in a line following the special end characters are
  109.     taken as comment only.
  110.  
  111. SPECIAL CHARACTERS:
  112.     #  Template end of line
  113.     $  Template parameter flag
  114.     %  Code body end of line
  115.     !  Code body escape
  116.     (  Left bracket
  117.     )  Right bracket
  118.  
  119.     These special characters are user selectable on the first line
  120.     of input to STAGE2.  The particular characters shown above were
  121.     arbitrarily chosen for the examples which follow.
  122.  
  123. MACRO EXAMPLE:
  124.     This macro may be used to store information into the STAGE2
  125.     built in memory.
  126.  
  127.     MEM[$]=$#            1. Template line
  128.     !F3%                2. Store into memory
  129.     %                3. End of macro
  130.  
  131.     The template in line 1 contains two parameter flags (maximum
  132.     of nine allowed).  For a string to match the template it must
  133.     contain the literal characters in the order shown in the
  134.     template line.  The parameter flag characters, "$", will match
  135.     any balanced strings including a null string.  A balanced string
  136.     is one containing equal numbers of left and right bracketing
  137.     characters, usually "(" and ")".
  138.  
  139.     Line 2 contains a processor function request.  The escape
  140.     character "!" folowed by "F" followed by a digit specifies one
  141.     of ten possible functions.  The "F" can actually be any non-
  142.     numeric or special character.  The function "3" shown in the
  143.     example instructs STAGE2 to store parameter string 2 into the
  144.     memory using parameter string 1 for access to memory.  In other words
  145.     the string in parameter 1 is given a value in memory and that value
  146.     is the string in parameter 2.
  147.  
  148.     Parameter 1 is the string segment represented by the first "$"
  149.     in the template and parameter 2 is the string segment represented
  150.     by the second "$" in the template.  The maximum number of
  151.     parameters is nine.
  152.  
  153.     Line 3 is an empty code body line or macro terminator.
  154.  
  155.     Strings for a successful match:
  156.         MEM[25]=TWENTY FIVE#
  157.             Parameter 1 = "25"
  158.             Parameter 2 = "TWENTY FIVE"
  159.             Parameters 3-9 = ""
  160.  
  161.         MEM[ABC]=HELLO#
  162.             P1 = "ABC"
  163.             P2 = "HELLO"
  164.  
  165.         MEM[EQUATION]=A=2*(B+C)#
  166.             P1 = "EQUATION"
  167.             P2 = "A=2*(B+C)"
  168.  
  169.         MEM[X=Y]=Z#
  170.             P1 = "X=Y"
  171.             P2 = "Z"
  172.  
  173.     Strings for a match failure:
  174.         MM[12]="E" MISSING#
  175.  
  176.         MEM [XYZ]=SPACE AFTER "MEM"#
  177.  
  178.         MEM[ABC)]=UNBALANCED STRING#
  179.  
  180.         MEM[ABC]=UNBALANCED (STRING#
  181.  
  182. MACRO EXAMPLE:
  183.     This macro may be used to print information stored in the
  184.     memory.
  185.  
  186.     PRINT MEM[$]#            4. Template line
  187.     !10=!11!F14%            5. Extract info and output
  188.     %                6. End of macro
  189.  
  190.     The template in line 4 contains 1 parameter flag which
  191.     represents the string which will be used to access the memory.
  192.  
  193.     The first escape character in line 5 is followed by a non-zero
  194.     digit, "1", which is taken to be a reference to parameter string
  195.     1.  The digit, "0", following the parameter reference is a
  196.     conversion code (0-8 allowed).  Conversion "0" copies the
  197.     parameter string unchanged to the constructed line.  The
  198.     constructed line can be thought of as a scratch string which is
  199.     empty at the start of a code body line scan.  In summary the
  200.     three characters "!10" instruct STAGE2 to append parameter 1 to
  201.     the constructed line.
  202.  
  203.     The next character in line 5 is a literal "=" which is appended
  204.     to the constructed line.  Next is another escape character
  205.     followed by the digit "1".  This is another reference to
  206.     parameter string 1.  This time, however, the conversion digit
  207.     is a "1" which instructs STAGE2 to append information from the
  208.     memory to the constructed line using the specified
  209.     parameter string for access.
  210.  
  211.     At this point 3 items have been appended to the constructed line:
  212.     parameter string 1, "=", and a string from the memory.  The
  213.     next character in line 5 is another escape.  This time, however,
  214.     the following character is non-numeric indicating a processor
  215.     function request.  The next character, the digit "1", specifies
  216.     the output function.  The following digit, "4", specifies the
  217.     output channel.  "!F14" causes output of the constructed line to
  218.     channel 4.  When the channel number is ommitted output is to
  219.     channel 3 by default.  Processing of line 5 is now complete
  220.     and line 6 terminates the macro.
  221.  
  222.     Strings for successful match:
  223.         PRINT MEM[25]#
  224.             Channel 4 output = "25=TWENTY FIVE"
  225.  
  226.         PRINT MEM[ABC]#
  227.             Ch4 = "ABC=HELLO"
  228.  
  229.         PRINT MEM[PDQ]#
  230.             Ch4 = "PDQ="       nothing stored previously
  231.  
  232. MACRO EXAMPLE:
  233.     This macro will also display information stored in the memory
  234.     but formatted into fields.
  235.  
  236.     FORMAT MEM[$]#            7. Template line
  237.     !11!26%                8. Extract info
  238.     !F14%                9. Output
  239.     1111111= 22222222222222222%    10. Format
  240.     %                11. End of macro
  241.  
  242.     As in line 5, the "!11" in line 8 appends information from the
  243.     memory to the constructed line using parameter 1 for
  244.     access.  Then "!2" is a reference to parameter 2.  The
  245.     following conversion digit, "6", instructs STAGE2 to copy the
  246.     constructed line into the specified parameter.  This also
  247.     results in clearing the constructed line to null.  Processing
  248.     of line 8 is complete as the end of line character comes next.
  249.     It is possible, however, to have more operations appear in that
  250.     same code body line (i.e. "!11!26 !F14#").  The character after
  251.     the 6 in this alternative is ignored so a space is shown.
  252.  
  253.     At this point parameter 1 still has the string resulting from
  254.     the template match and parameter 2 contains the string extracted
  255.     from the memory using parameter 1 for access.
  256.  
  257.     The output request in line 9 is like that of line 5 except that
  258.     the constructed line is empty (null).  This condition instructs
  259.     STAGE2 to use the following code body line as a formatting
  260.     template which should not be confused with macro templates.
  261.     Fields of numeric characters refer to corresponding parameter
  262.     strings.  Non-numerics in the formatting template appear in the
  263.     output line as is.  Parameter strings are inserted into the fields
  264.     left justified (leading blanks are not suppressed) and blank
  265.     filled or truncated on the right depending on parameter length
  266.     and field width.
  267.  
  268.     Strings for successful match:
  269.         FORMAT MEM[25]#
  270.             Ch4 = "25     = TWENTY FIVE      "
  271.  
  272.         FORMAT MEM[ABC]#
  273.             Ch4 = "ABC    = HELLO            "
  274.  
  275.         FORMAT MEM[PDQ]#
  276.             Ch4 = "PDQ    =                  "
  277.  
  278. EXAMPLE RUN:
  279.     FILE "MEMORY.INP"
  280.         #$%!0 (+-*/)            0. Special character selection
  281.         MEM[$]=$#            1. Template line
  282.         !F3%                2. Store into memory
  283.         %                3. End of macro
  284.         PRINT MEM[$]#            4. Template line
  285.         !10=!11!F14%            5. Extract info and output
  286.         %                6. End of macro
  287.         FORMAT MEM[$]#            7. Template line
  288.         !11!26%                8. Extract info
  289.         !F14%                9. Output
  290.         1111111= 22222222222222222%    10. Format
  291.         %                11. End of macro
  292.         END#                12. Template line
  293.         !F0%                13. Terminate processing
  294.         %%                14. End of macros
  295.         MEM[25]=TWENTY FIVE#
  296.         MEM[ABC]=HELLO#
  297.         MEM[EQUATION]=A=2*(B+C)#
  298.         MEM[X=Y]=Z#
  299.         MM[12]="E" MISSING#
  300.         MEM [XYZ]=SPACE AFTER "MEM"#
  301.         MEM[ABC)]=UNBALANCED STRING#
  302.         MEM[ABC]=UNBALANCED (STRING#
  303.         PRINT MEM[25]#
  304.         PRINT MEM[ABC]#
  305.         PRINT MEM[PDQ]#
  306.         FORMAT MEM[25]#
  307.         FORMAT MEM[ABC]#
  308.         FORMAT MEM[PDQ]#
  309.         END#
  310.  
  311.         Note:    The "#" shown at the end of the input lines are
  312.             optional in the CP/M implementation as carriage
  313.             return is sufficient for an end of line condition.
  314.             The special character when used is the same
  315.             terminator used for macro template end of line.  It
  316.             can be used if it is desired to allow comment
  317.             information in the source input stream.
  318.  
  319.     COMMAND LINES:
  320.         STAGE2 CH3,CH4=MEMORY.INP
  321.         TYPE CH3
  322.         TYPE CH4
  323.  
  324. FLAG LINE:
  325.     The first line read by STAGE2 is used to specify the user's special
  326.     symbol selections.
  327.  
  328.     column    description
  329.       1      End of template and source input lines
  330.       2      Template parameter flag
  331.       3      End of code body line
  332.       4      Escape character for code body (parameter or function ref.)
  333.       5      The character for zero
  334.       6      Space character for formatted output
  335.       7      Open bracket (arithmetic expressions and balanced strings)
  336.       8      Addition operator
  337.       9      Subtraction operator
  338.      10      Multiplication operator
  339.      11      Division operator
  340.      12      Closing bracket (to match #7)
  341.  
  342.  
  343. PARAMETER CONVERSIONS:
  344.  
  345.     There are a maximum of ten parameters, numbered 0 through 9.
  346.     Parameter 0 is a special case.
  347.     There are nine possible parameter conversions, numbered 0 through
  348.     8.  Most of this discussion will refer to specific parameters but
  349.     the remarks apply generally to parameters 1 through 9.
  350.  
  351.     !10    Append parameter string 1 to the constructed line.
  352.  
  353.     !20    Append P2 to the CL.
  354.  
  355.     !11    Append MEM(P1) to the CL.  Using P1 for access, append the
  356.         value of the symbol to the CL.
  357.         CASE
  358.             ( P1 = null )  Generate error mesage and trace back
  359.             ( P1 undefined )  Append null to the CL
  360.             ( otherwise )  Append MEM(P1) to the CL
  361.             fin
  362.  
  363.     !12    Similar to conversion 1 except when P1 is undefined.
  364.         CASE
  365.             ( P1 = null )  Generate error message and trace back
  366.             ( P1 undefined )
  367.             MEM(P1) = S1  ; define from symbol generator
  368.             S1 = S1 + 1   ; increment symbol generator
  369.             Append MEM(P1)
  370.             fin
  371.             ( otherwise )  Append MEM(P1) to the CL
  372.             fin
  373.  
  374.     !13    Useful only in conjunction with context-controlled iteration.
  375.         (Described after !17)
  376.  
  377.     !14    Append EVAL(P1)  ; Evaluate the parameter string as an
  378.         arithmetic expression and append a string of digits to the CL
  379.         to represent the result.  Non-numeric items in the expression
  380.         will be taken as symbols for memory reference.  An undefined
  381.         symbol is treated as zero.  If null, P1 will be treated as
  382.         zero.  A symbol with a non-numeric value will cause an error
  383.         message and traceback.
  384.  
  385.     !15    Append LEN(P1) to the CL  ; Append a string of digits to the CL
  386.         to represent the length of the parameter string.  A null string
  387.         results in a single zero digit.
  388.  
  389.     !16    P1 = CL, CL = null  ; Copies the CL into parameter 1, replacing
  390.         whatever might have been there before.  Also, the CL is
  391.         cleared.  The character immediately following "!16" will be
  392.         ignored.  If it is the end of code body line character
  393.         processing will continue on the following line.  Otherwise,
  394.         processing will continue with the next character.  When used
  395.         inside of an iteration loop the string placed in the specified
  396.         parameter is not retained from one iteration to the next or
  397.         after exit from the loop.
  398.  
  399.     !17    This starts a context controlled iteration loop.  The current
  400.         value of the specified parameter is saved as the iteration
  401.         process will supply new values for the parameter.  The
  402.         original value will will be restored after exit from the loop.
  403.  
  404.         The CL  is scanned for break characters which are specified
  405.         following the digit "7".  All of the characters up to the end
  406.         of line character will be used as break characters.  If no
  407.         break characters are specified the CL scan is broken on each
  408.         character.  When a break character or the end of the CL is
  409.         reached scanning stops and the scanned string (excluding the
  410.         break character) is copied into the specified parameter.  The
  411.         scanned string and break character are deleted from the CL.
  412.         Break characters enclosed in brackets will not be recognized as
  413.         the scanned string would not be balanced.  After scanning stops
  414.         code body lines are expanded within the loop which ends at an
  415.         "!F8".  After all lines within the loop have been processed,
  416.         scanning of the CL continues unless the CL is null.  When the
  417.         CL is null the iteration loop is terminated.
  418.  
  419.     !F8    Processor function to define the scope of an iteration loop.
  420.  
  421.     !13    Append BREAK(P1) to the CL  ; The break character is the 
  422.         single character immediately following the specified
  423.         parameter which represents a substring of the line being
  424.         scanned.  When the end of line is reached, the break
  425.         character is null.
  426.  
  427.     !18    Append a string of digits to the CL to represent the internal
  428.         storage code for the character in P1.  Unless P1 contains
  429.         exactly one character an error message and traceback will
  430.         result.
  431.  
  432. SYMBOL GENERATOR:
  433.  
  434.     !0    Parameter  "0" is a reference to an internal symbol generator.
  435.         Within a given macro expansion up to ten unique symbols
  436.         (actually integers or strings of digits) are available; "!00"
  437.         through "!09".  After the macro expansion is complete the
  438.         symbol generator is incremented so that future macro expansions
  439.         will get different symbols.
  440.  
  441. PROCESSOR FUNCTIONS:
  442.  
  443.     There are eleven processor functions, numbered 0 through 9 and E.
  444.     Some processor functions assume use of specific parameters.
  445.  
  446.     !F0    Terminate processing.
  447.  
  448.     !F1    Output request.  The output request must appear at the end of
  449.         a code body line.  The CL is output if it is not null.  If it
  450.         is null the following code body line will be used as a format
  451.         specification for output.  A format line specifies exactly
  452.         the number of characters in the line to be output.  Non-numeric
  453.         characters in the format specification are output exactly as
  454.         they are.  Parameter fields in the format specification are
  455.         denoted by strings of identical digits.  "22222" is a five
  456.         character field into which parameter string 2 will be inserted,
  457.         left justified with blank fill or truncation on the right as
  458.         required.  A given parameter may be referenced for more than
  459.         one field in the formatted line.
  460.  
  461.         !F14    Output the CL to channel 4.
  462.         !F1    Output to channel 3 as default channel.
  463.         !F12R    Output to channel 2 after rewind.
  464.  
  465.     !F2    Change I/O channels and copy text from the specified input
  466.         channel to the specified output channel.  If P1 is null no
  467.         copying takes place.  Copying continues up to an input line
  468.         whose initial substring matches P1.  The line which matches
  469.         P1 is ignored, copying stops and the input channel is 
  470.         positioned to the line following the matched line.  If no
  471.         match line is found end of file terminates the copy.
  472.  
  473.         WHEN ( input channel specified )
  474.             make it the new current input (CI) channel
  475.             fin
  476.         ELSE  the current input channel number is unchanged
  477.  
  478.         WHEN ( output channel specified )
  479.             copy to the specified channel
  480.             fin
  481.         ELSE  copy to channel 3
  482.  
  483.         5!F2    CI = 5 , out is 3
  484.  
  485.         2R!F2    CI = 2 , Rewind 2 , out is 3
  486.  
  487.         !F24    CI unchanged , out is 4
  488.  
  489.         2!F23R    CI = 2 , out is 3 , Rewind 3 before copy
  490.  
  491.         In all cases no copy takes place if P1 is null.
  492.  
  493.  
  494.     !F3    MEM(P1) = P2  ; Using parameter string 1 for access, store
  495.         parameter string 2 into memory. (i.e. the value of P1 is
  496.         defined to be P2).  If P1 is null an error message and
  497.         traceback result.
  498.  
  499.     !F4    Set the skip counter unconditionally.  The skip counter applies
  500.         to macro code body lines.  The skip feature allows conditional
  501.         expansion of portions of a macro code body.  Parameter string 1
  502.         is evaluated as an arithmetic expression (see conversion 4
  503.         description) and the result is placed in the skip counter.
  504.  
  505.         SKIP = EVAL(P1)
  506.  
  507.  
  508.     !F5    Set skip counter based on string compare for equality.  The
  509.         test condition is specified by a character following "!F5".
  510.  
  511.         !F50   IF ( P1 == P2 )  SKIP = EVAL(P3)
  512.         !F51   IF ( P1 <> P2 )  SKIP = EVAL(P3)
  513.  
  514.  
  515.     !F6    Set skip counter based on the relative values of 2 arithmetic
  516.         expressions.  The test condition is specified by a character
  517.         following "!F6".
  518.  
  519.         !F6-   IF ( P1 <  P2 )  SKIP = EVAL(P3)
  520.         !F60   IF ( P1 == P2 )  SKIP = EVAL(P3)
  521.         !F61   IF ( P1 <> P2 )  SKIP = EVAL(P3)
  522.         !F6+   IF ( P1  > P2 )  SKIP = EVAL(P3)
  523.  
  524.  
  525.     !F7    Count-controlled iteration.  The CL is evaluated as an
  526.         arithmetic expression (see conversion 4 description) and the
  527.         resulting value is placed in an iteration counter.  The loop,
  528.         which ends at an "!F8", is repeated with the iteration counter
  529.         decremented for each iteration.  The loop terminates when the
  530.         counter reaches zero.
  531.  
  532.     !F8    Defines the scope of count-controlled loops and context-
  533.         controlled loops.  Loop nesting is permitted.  Skipping out of
  534.         loops is permitted.  Skipping over entire loops is tricky
  535.         business (see Waite's book, page 398).
  536.  
  537.     !F9    Terminates expansion of the current macro.
  538.  
  539.     !FE    Force an error message and traceback.  All macro calls to the
  540.         current level will be output in reverse order to channel 4.
  541.         The last traceback line is the current input line.
  542.  
  543. -----------------------------------------------------------------------
  544.  
  545. STAGE2 PROGRAM:
  546.     This is a highly simplified description of the STAGE2 algorithm.
  547.  
  548.     PROGRAM;
  549.  
  550.     PROCEDURE MATCH ( STRING );
  551.         BEGIN
  552.  
  553.         attempt to match STRING against macro templates
  554.  
  555.         IF  MATCH_SUCCESSFUL  THEN
  556.  
  557.         FOR  each line of macro code body  DO
  558.             BEGIN
  559.             scan code body line and perform operations
  560.             IF  CONSTRUCTED_LINE <> NULL  THEN
  561.             MATCH ( CONSTRUCTED_LINE );    {note recursive call}
  562.             END
  563.  
  564.         ELSE  output STRING to channel 3
  565.  
  566.         END;
  567.  
  568.     BEGIN    { ---------------- program starts here ------------ }
  569.  
  570.         INPUT_FLAG_LINE    {gets special character definitions from
  571.                  the first line input from channel 1}
  572.  
  573.         INPUT_MACROS    {reads macro code bodies into memory from
  574.                  channel 1 and builds templates into tree
  575.                  structure for the template matching
  576.                  algorithm}
  577.  
  578.         INPUT_NEXT_LINE    {gets first source line from input file
  579.                  (channel 1) - this is the first line
  580.                  following the last macro}
  581.  
  582.         WHILE  NOT END_OF_FILE  DO
  583.  
  584.         BEGIN
  585.         MATCH ( LINE );    {attempt to match the line against all
  586.                  macro templates}
  587.  
  588.         INPUT_NEXT_LINE
  589.  
  590.         END;
  591.  
  592.     END.
  593.  
  594.  
  595.     Except for switching channels or rewinding channels, the STAGE2
  596.     user has no control over input.  The processor has a built in loop
  597.     for input as can be seen in the above program.  Output, however,
  598.     is under user control through macro body processing.  If STAGE2
  599.     fails to match an input line against a macro template the line
  600.     will be output to channel 3 as is and the processor will go on
  601.     to the next input line.
  602.