kestrel picture


The Kestrel Programming Language

Part of the documentation for the Kestrel language
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science


Hello World

putstring( "Hello world" LF, output );

The semicolon above is optional, and the keyword end could be appended. The comma in the formal parameter list of putstr would be optional except that there is a string constant, and string constants will consume all successive expressions to extend the string.

Copy Input to Output

while ~eof( input )
    putchar( getchar[ input ], output )

The above code illustrates the use of different kinds of parentheses and brackets to help the reader see which parenthesis matches which. The square brackets could just as easily have been replaced with regular round parentheses, without changing the meaning of the code.

Clean Up File While Copying

-- strip non ASCII content and all control characters from the input,
-- except newline characters, while copying from input to output

ch: var char
while ~eof( input )
    ch = getchar[ input ], output )
    if ch < " " -- control characters
        if ch = LF
            putchar( ch, output )
    else        -- not a control character
        if ch < DEL -- printable
            putchar( ch, output )
    end -- if
end -- while

The above code illustrates the use of comments, variables, and if statements as well as a variety of simple expressions.

The putstring Routine

putstring: procedure( ref s:array uint16 of char, f:file )
    -- put the string s to file f
    for i in s.min .. s.max
        putchar( s(i), output )

This example illustrates the use of a for loop as well as the use an array parameter with bounds that may be a subrange of the bounds of the declared type.