Search                        Top                                  Index
HELP GO_ON                                          John Gibson Apr 1996

    go_on expression to prefix: statement-sequence endgo_on

    go_on expression to lab1, lab2, ..., labN else elselab ;

A Pop-11 go_on statement causes a jump to a specified label depending
upon a given integer.

         CONTENTS - (Use <ENTER> g to access required sections)

  1   First Format
  2   Second Format
  3   See Also

1  First Format

The first format of go_on is

    go_on expression to prefix :

where expression must produce an integer (otherwise a mishap results).

prefix is any (non-syntax) word that will mark the different cases
inside statement-sequence. The go_on statement defines this word as a
temporary macro which takes one argument and produces a label. Inside
statement-sequence you can then use

     prefix arg:

to label each case, where arg is an integer or the word default. (Note
that arg is macro-expanded, so may itself be a macro for an integer

Labels for different integer values may appear in any order in the
statement. (However, currently, the spread between the minimum and
maximum integer values specified must not be greater than 1024.)

In addition, the prefix macro can be used in a goto, i.e.

    goto prefix arg

where in this context, arg may also be the word end to mean go to the
end of the statement.

For example (where x contains an integer),

    go_on x to Case:
        Case 2:
            <some code>
            goto Case end;

        Case 5:
            <some code>
            goto Case 2;

        Case default:
            <some code>

All integer values for which there is no corresponding prefix label will
go to the default label (if the default label itself is absent, one is
inserted automatically together with code to produce a mishap).

Note that the whole statement is generated inside a lexical block, and
the prefix macro is lexically scoped within that block. Thus you cannot
refer to prefix outside of the statement.

2  Second Format

The second (older) format of go_on is

    go_on expression to lab1, lab2, ..., labN else elselab ;

where the else elselab part is optional. expression must produce an
integer I from 1 to N which then selects the label from lab1 to labN to
go to.  If I is not between 1 and N inclusive, then elselab is jumped to
if present, otherwise a mishap results.

All the labels specified, including elselab, may be either local labels
(somewhere in the current procedure) or non-local ones (somewhere in a
lexically-enclosing procedure).

3  See Also

    Forms of expression in Pop-11.

    Transferring control to a labelled instruction.

    Representation of labels in Pop-11.

    Summary of conditional statements in Pop-11.

    Syntax diagrams for Pop-11.

--- C.all/help/go_on
--- Copyright University of Sussex 1996. All rights reserved.