ExamplesThe Falcon Programming Language
Part of
the documentation for the Falcon language
|
putstr( "Hello world\LF\", output );
The semicolon above is optional.
while ~eof( input )
putchar( getchar[ input ], output )
end
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.
-- strip non ASCII content and all control characters from the input,
-- except newline characters, while copying from input to output
var
ch char
code
while ~eof( input )
ch = getchar[ input ], output )
if ch < " " -- control characters
if ch = '\LF\'
putchar( ch, output )
end
else -- not a control character
if ch < '\DEL\' -- printable
putchar( ch, output )
end
end
end
end
The above code illustrates the use of comments, variables, and if statements as well as a variety of simple expressions.