comparison docs/lexer-algpseudocode.rst @ 186:95754197f5b3

Link to some source code of example pseudocode files
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 12 May 2026 20:22:47 +0200
parents ad80fcbf7b47
children 418846a2623c
comparison
equal deleted inserted replaced
185:b27557f6d393 186:95754197f5b3
7 7
8 These lexers are heavily heavily inspired by CTAN’s `Algpseudocodex`_. 8 These lexers are heavily heavily inspired by CTAN’s `Algpseudocodex`_.
9 They recogzize expressions and additionally all sorts of comments and 9 They recogzize expressions and additionally all sorts of comments and
10 commands that are inspired by `Algpseudocodex`_. 10 commands that are inspired by `Algpseudocodex`_.
11 11
12 They may be used in `Sphinx`_ by their aliases: 12 They may be used in `Sphinx`_ by their aliases.
13 The code-block:
13 14
14 .. code-block:: none 15 .. code-block:: none
15 16
16 .. code-block:: algpseudocode 17 .. code-block:: algpseudocode
17 18
18 \PROGRAM {The Pseudoprogram} \IS 19 \PROGRAM {The Pseudoprogram} \IS
19 20
20 \END PROGRAM {The Pseudoprogram} 21 \END PROGRAM {The Pseudoprogram}
21 22
22 It will be rendered as: 23 will be rendered as:
23 24
24 .. code-block:: algpseudocode 25 .. code-block:: algpseudocode
25 26
26 \PROGRAM {The Pseudoprogram} \IS 27 \PROGRAM {The Pseudoprogram} \IS
27 28
28 \END PROGRAM {The Pseudoprogram} 29 \END PROGRAM {The Pseudoprogram}
29 30
30 And the same with the german variant 31 And the same code-block with the german variant
31 (using ``.. code-block:: algpseudocode-de`` as language alias): 32 (using ``.. code-block:: algpseudocode-de`` as language alias):
32 33
33 .. code-block:: algpseudocode-de 34 .. code-block:: algpseudocode-de
34 35
35 \PROGRAM {The Pseudoprogram} \IS 36 \PROGRAM {The Pseudoprogram} \IS
537 538
538 539
539 Some Examples 540 Some Examples
540 ============= 541 =============
541 542
542 A synthetic example with many features: 543 A synthetic example with many features
544 (its source code is in :download:`examples/example-1.pseudocode`):
543 545
544 .. literalinclude:: examples/example-1.pseudocode 546 .. literalinclude:: examples/example-1.pseudocode
545 :language: algpseudocode 547 :language: algpseudocode
546 :lines: 2- 548 :lines: 2-
547 549
550 552
551 .. literalinclude:: examples/example-1.pseudocode 553 .. literalinclude:: examples/example-1.pseudocode
552 :language: NoEndAlgPseudocode 554 :language: NoEndAlgPseudocode
553 :lines: 2- 555 :lines: 2-
554 556
555 This is Wikipedia's description of *Dinic's Algorithm* 557 The second example is Wikipedia's description of *Dinic's Algorithm*
556 (see https://en.wikipedia.org/wiki/Dinic%27s_algorithm): 558 (see https://en.wikipedia.org/wiki/Dinic%27s_algorithm).
559 Its source code is in :download:`examples/algorithm-dinic.description`:
557 560
558 .. literalinclude:: examples/algorithm-dinic.description 561 .. literalinclude:: examples/algorithm-dinic.description
559 :language: algpseudocode 562 :language: algpseudocode
560 :lines: 2- 563 :lines: 2-
561 564
562 This is Wikipedia's pseudocode of the *Ford–Fulkerson Algorithm* 565 The third example is Wikipedia's pseudocode of the *Ford–Fulkerson Algorithm*
563 (see https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm): 566 (see https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm).
567 Its source code is in :download:`examples/algorithm-ford-fulkerson.pseudocode`:
564 568
565 .. literalinclude:: examples/algorithm-ford-fulkerson.pseudocode 569 .. literalinclude:: examples/algorithm-ford-fulkerson.pseudocode
566 :language: algpseudocode 570 :language: algpseudocode
567 :lines: 2- 571 :lines: 2-
568 572
569 This is Wikipedia's pseudocode of the *Edmonds–Karp Algorithm* 573 The fourth example is Wikipedia's pseudocode of the *Edmonds–Karp Algorithm*
570 (see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm) 574 (see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm)
571 with a custom lexer that skip all ``ENDxxx`` keywords: 575 with a custom lexer that skip all ``ENDxxx`` keywords.
576 Its source code is in :download:`examples/algorithm-edmonds-karp.pseudocode`:
572 577
573 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode 578 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
574 :language: NoEndAlgPseudocode 579 :language: NoEndAlgPseudocode
575 :lines: 2- 580 :lines: 2-
576 581
577 And now the *Edmonds–Karp Algorithm* with french keywords: 582 And now the *Edmonds–Karp Algorithm* with **french** keywords:
578 583
579 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode 584 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
580 :language: algpseudocode-fr 585 :language: algpseudocode-fr
581 :lines: 2- 586 :lines: 2-
582 587
583 And again the *Edmonds–Karp Algorithm* with german keywords: 588 And again the *Edmonds–Karp Algorithm* with **german** keywords:
584 589
585 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode 590 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
586 :language: algpseudocode-de 591 :language: algpseudocode-de
587 :lines: 2- 592 :lines: 2-