annotate docs/examples/example-1.pseudocode @ 281:ee512932d603

Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 20 May 2026 17:23:41 +0200
parents 50bd1e91b822
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
107
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 // -*- coding: utf-8; indent-tabs-mode: nil -*-
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2 \PROGRAM {The Pseudocode Lexer} \IS
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4 /*
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5 * The program is here, but it also could be an \ALGORITHM
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 *
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 107
diff changeset
7 * /* YES! Nested multi-line comments work! */
107
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8 */
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 \PROC {A Procedure name} \IS
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 \TBLOCK {A text block 1}
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 107
diff changeset
12 \TBLOCK {A text block 2 with a nested expression: \expr{flag is FALSE}}
107
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13 \BLOCK {
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
14 \REMARK A remark on its own line within a "BLOCK"
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15 }
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16 \END-PROC {A Procedure name}
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18 \FUNCTION{A Function with {escaped\} text} \IS
233
d6b66d02fb86 A number sample with all digits in the synthetic example
Franz Glasner <fzglas.hg@dom66.de>
parents: 151
diff changeset
19 (1234567890 != what) or a and b xor (c in d) \rem this is another remark
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 233
diff changeset
20 \block {foo is not bar}
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 233
diff changeset
21 \block {2 + 6 = 1 (mod 7)}
107
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 \IF a is nil \THEN
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
24 \text{Set something}
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25 \ELSEIF
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
26 \text{Set some other thing}
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
27 \END-IF
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
28 \END FUNCTION{A Function with {escaped\} text}
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
29
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30 \CLASS{A Class} \IS
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
31 // This is a one-line comment
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
32 a and b xor (c in d) \rem this is another remark
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
33
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
34 # This is another one-line comment
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 107
diff changeset
35
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 107
diff changeset
36 (* Here is a "block" of expressions.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 107
diff changeset
37 A block has a leading symbol. *)
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 233
diff changeset
38 \block {foo ?= bar
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 233
diff changeset
39 Bär >= Maus
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 233
diff changeset
40 and Bär != Maus}
107
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
41 \block{a 1.2 {x in X\} c}
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 107
diff changeset
42 (* Analogous there is a variant that is in text-mode by default.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 107
diff changeset
43 It has an other leading symbol. *)
107
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
44 \tstate{We will compute next \expr{a xor b or (\text{set} X is Empty)} \rem without c!
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 233
diff changeset
45 or multiply it the \ttx-ges/other/ way.}
107
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
46
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
47 \tstate{foo bar \rem A remark within a text statement until LF!
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
48 nextfoo nextbar
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
49 nextnextfoo nextnextbar}
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
50 \ENDCLASS{A Class}
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
51
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
52 @A_XXX
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
53 FOO BAR
1c1985532139 A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
54 \ENDPROG