comparison docs/example-1.pseudocode @ 107:1c1985532139

A couple of real pseudocode examples. Examples are from the Wikipedia.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 04 May 2026 16:57:17 +0200
parents
children 4acf578ae93f
comparison
equal deleted inserted replaced
106:f6b46a379aba 107:1c1985532139
1 // -*- coding: utf-8; indent-tabs-mode: nil -*-
2 \PROGRAM {The Pseudocode Lexer} \IS
3
4 /*
5 * The program is here, but it also could be an \ALGORITHM
6 *
7 * /* YES! Nested multiline comments work! */
8 */
9
10 \PROC {A Procedure name} \IS
11 \TBLOCK {A text block 1}
12 \TBLOCK {A text block 2 with an expression: \expr{flag is FALSE}}
13 \BLOCK {
14 \REMARK A remark on its own line within a "BLOCK"
15 }
16 \END-PROC {A Procedure name}
17
18 \FUNCTION{A Function with {escaped\} text} \IS
19 a and b xor (c in d) \rem this is another remark
20 \block {foo bar}
21
22 \IF a is nil \THEN
23 \text{Set something}
24 \ELSEIF
25 \text{Set some other thing}
26 \END-IF
27 \END FUNCTION{A Function with {escaped\} text}
28
29 \CLASS{A Class} \IS
30 // This is a one-line comment
31 a and b xor (c in d) \rem this is another remark
32
33 # This is another one-line comment
34 \block {foo
35 bar}
36 \block{a 1.2 {x in X\} c}
37 \tstate{We will compute next \expr{a xor b or (\text{set} X is Empty)} \rem without c!
38 or multiply it the other way round}
39
40 \tstate{foo bar \rem A remark within a text statement until LF!
41 nextfoo nextbar
42 nextnextfoo nextnextbar}
43 \ENDCLASS{A Class}
44
45 @A_XXX
46 FOO BAR
47 \ENDPROG