annotate docs/lexer-algpseudocode.rst @ 263:2e78e255b54e

Make a link to the reST source where appropriate to learn about the lexer syntax
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 19 May 2026 18:03:48 +0200
parents 7df1fd3bab87
children e5ea2f955986
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 .. -*- coding: utf-8; indent-tabs-mode: nil; -*-
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
4 *************************************
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
5 AlgPseudocode and Language Variants
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
6 *************************************
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
7
263
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
8 .. only:: html
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
9
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
10 .. hint::
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
11 The reST source of this documentation page can be found
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
12 `here <_sources/lexer-algpseudocode.rst.txt>`_.
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
13
192
156bcd310596 FIX: duplicate word
Franz Glasner <fzglas.hg@dom66.de>
parents: 187
diff changeset
14 These lexers are heavily inspired by CTAN’s `Algpseudocodex`_.
201
b6a959c31bed Wording
Franz Glasner <fzglas.hg@dom66.de>
parents: 194
diff changeset
15 They recognize all sorts of single- and multi-line comments in addition to
b6a959c31bed Wording
Franz Glasner <fzglas.hg@dom66.de>
parents: 194
diff changeset
16 expressions and commands that are inspired by `Algpseudocodex`_.
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
17
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
18 They may be used in `Sphinx`_ by their aliases.
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
19 The code-block:
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
20
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
21 .. code-block:: none
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
22
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
23 .. code-block:: algpseudocode
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
24
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
25 \PROGRAM {The Pseudoprogram} \IS
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
26
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
27 \END PROGRAM {The Pseudoprogram}
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
28
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
29 will be rendered as:
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
30
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
31 .. code-block:: algpseudocode
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
32
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
33 \PROGRAM {The Pseudoprogram} \IS
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
34
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
35 \END PROGRAM {The Pseudoprogram}
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
36
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
37 And the same code-block with the german variant
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
38 (using ``.. code-block:: algpseudocode-de`` as language alias):
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
39
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
40 .. code-block:: algpseudocode-de
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
41
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
42 \PROGRAM {The Pseudoprogram} \IS
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
43
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
44 \END PROGRAM {The Pseudoprogram}
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
45
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
46
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
47 States
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
48 ======
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
49
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
50 The AlgPseudocode lexer and its language variants AlgPseudocodeDE and
208
de7118d299e9 Aliases for states: context or mode
Franz Glasner <fzglas.hg@dom66.de>
parents: 207
diff changeset
51 AlgPseudocodeFR basically work in three states (aka modes or contexts):
de7118d299e9 Aliases for states: context or mode
Franz Glasner <fzglas.hg@dom66.de>
parents: 207
diff changeset
52 `default`, `expression` and `text`.
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
53
208
de7118d299e9 Aliases for states: context or mode
Franz Glasner <fzglas.hg@dom66.de>
parents: 207
diff changeset
54 In `expressions` it automatically recognizes:
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
55
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
56 - Strings (single-quote, double-quote, triple-single-quote,
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
57 triple-double-quote, `Python`_ style)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
58 - Numbers (also `Python`_ style)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
59 - (Mathematical) operators and symbols
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
60 - ``\TEXT{...}``
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
61
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
62 To switch in a text-mode that prohibits automatic expression
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
63 highlighting.
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
64
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
65 A closing curly brace can be quoted with ``\}`` to not end the
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
66 text mode prematurely.
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
67
212
18553f595b34 Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents: 209
diff changeset
68 - ``\EXPR`` or ``\EXPRESSION`` as nested construct
18553f595b34 Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents: 209
diff changeset
69
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
70 - ``\NAME``, ``\CALL`` and ``\GETS``
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
71
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
72 - ``\REM`` and ``\REMARK`` for remarks (aka comments)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
73
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
74 - Names (`Name.Entity`)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
75
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
76 - :ref:`explicit-token-types`
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
77
208
de7118d299e9 Aliases for states: context or mode
Franz Glasner <fzglas.hg@dom66.de>
parents: 207
diff changeset
78 In the `default`-mode it recognizes all sorts of single- and multi-line
201
b6a959c31bed Wording
Franz Glasner <fzglas.hg@dom66.de>
parents: 194
diff changeset
79 comments in addition to expressions and commands that are inspired by
b6a959c31bed Wording
Franz Glasner <fzglas.hg@dom66.de>
parents: 194
diff changeset
80 `Algpseudocodex`_.
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
81
208
de7118d299e9 Aliases for states: context or mode
Franz Glasner <fzglas.hg@dom66.de>
parents: 207
diff changeset
82 In `texts` it recognizes:
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
83
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
84 - ``\EXPR`` or ``\EXPRESSION``
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
85
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
86 To switch to expression-mode.
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
87
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
88 A closing curly brace can be quoted with ``\}`` to not end the expression
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
89 mode prematurely.
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
90
212
18553f595b34 Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents: 209
diff changeset
91 - ``\TEXT`` as nested construct
18553f595b34 Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents: 209
diff changeset
92
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
93 - ``\REM`` and ``\REMARK`` for remarks (aka comments)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
94
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
95 - :ref:`explicit-token-types`
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
96
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
97
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
98 Lexer Options
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
99 =============
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
100
160
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
101 .. describe:: prohibit_raiseonerror_filter
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
102
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
103 **Type:** :py:class:`bool`
160
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
104
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
105 **Default:** :py:obj:`None`
160
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
106
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
107 If :py:obj:`True` the `raiseonerror` filter is not allowed to be
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
108 applied by `Sphinx`_ when :py:meth:`Lexer.add_filter` is called.
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
109
160
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
110 This setting does not apply to filters that are set by the standard
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
111 lexer option `filters`.
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
112
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
113 .. describe:: no_end
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
114
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
115 **Type:** :py:class:`bool`
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
116
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
117 **Default:** :py:obj:`False`
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
118
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
119 If :py:obj:`True` all the ``\ENDxxx`` commands will be skipped and yield
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
120 no output.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
121
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
122 .. describe:: gets
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
123
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
124 **Type:** :py:class:`str` or :py:obj:`None`
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
125
212
18553f595b34 Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents: 209
diff changeset
126 **Default:** :py:obj:`None` (yields ``⟵``)
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
127
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
128 The operator symbol to be printed by the command ``\GETS``.
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
129
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
130 An often used alternative is ``:=``.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
131
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
132 .. describe:: remark
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
133
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
134 **Type:** :py:class:`str` or :py:obj:`None`
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
135
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
136 **Default:** :py:obj:`None` (yields ``▷``)
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
137
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
138 The symbol to be printed as when starting comments with
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
139 ``\REMARK`` or ``\REM``.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
140
144
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
141 To use a lexer with non-default options in `Sphinx`_ see section
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
142 :ref:`customized-sphinx-lexers`.
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
143
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
144
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
145 Comments
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
146 ========
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
147
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
148 - with the ``\REMARK`` or ``\REM`` keywords (this includes a leading symbol)
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
149 - multi-line comments with ``/* ... */``; they can be **nested**
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
150 - multi-line comments with ``(* ... *)``; they can be **nested**
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
151 - single-line comments with ``//`` or ``#`` (until the end of the line)
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
152
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
153 .. code-block:: algpseudocode
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
154
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
155 /*
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
156 * A single multiline comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
157 */
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
158
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
159 /*
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
160 * A multiline comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
161 *
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
162 * /* This is a nested multi-line comment */
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
163 *
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
164 */
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
165
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
166 (*
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
167 * A multiline comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
168 *
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
169 * (* This is a nested multi-line comment *)
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
170 *
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
171 *)
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
172
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
173 // A single-line comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
174
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
175 # A single-line comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
176
213
d470250f8451 Title/metadata of PDF documentation builds:
Franz Glasner <fzglas.hg@dom66.de>
parents: 212
diff changeset
177 \REM A remark is a single-line comment with a leading symbol
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
178
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
179
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
180 Literals
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
181 ========
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
182
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
183 Strings and numbers as in `Python`_. String prefixes ``r``, ``f`` and ``t``
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
184 are not supported -- ``u`` and ``b`` are.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
185
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
186 To yield non-string-delimiting single- and double-quotes you have to escape them
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
187 using ``\'`` or ``\"``. This must be used to typeset something as
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
188 :algpseudocode:`f\\'(x) = 0`.
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
189
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
190 .. code-block:: algpseudocode
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
191
241
7df1fd3bab87 In the number example use 1234567890 also
Franz Glasner <fzglas.hg@dom66.de>
parents: 237
diff changeset
192 0 1234567890 0xdead 0b100001 0o720 2.7 2.7e-54
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
193
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
194 "A string with an escaped double-quote \" "
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
195
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
196 'Another string with an escaped single-quote \' '
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
197
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
198 """A multiline
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
199 string
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
200 """
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
201
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
202 '''Another multiline string
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
203
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
204 '''
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
205
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
206 b"A \x20 byte string"
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
207
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
208 u'An explicit Unicode \u1234 string'
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
209
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
210 \" a non string
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
211
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
212 \' a non string also
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
213
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
214
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
215 (Mathematical) Symbols and Operators
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
216 ====================================
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
217
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
218 Some ASCII symbol combinations are recognized and replaced by a
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
219 Unicode symbol:
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
220
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
221 .. code-block:: algpseudocode
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
222
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
223 \TEXT{<=>} <=>
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
224 \TEXT{<->} <->
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
225 \TEXT{<-} <-
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
226 \TEXT{->} ->
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
227 \TEXT{=>} =>
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
228 \TEXT{<=} <=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
229 \TEXT{>=} >=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
230 \TEXT{<>} <>
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
231 \TEXT{!=} !=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
232 \TEXT{:=} :=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
233 \TEXT{=:} =:
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
234 \TEXT{?=} ?=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
235
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
236 Unicode codepoints with property ``Sm`` are recognized as mathematical symbol
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
237 and highlighted accordingly.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
238
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
239
159
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
240 Punctuation
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
241 ===========
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
242
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
243 Runs of dots ``.``, ``..``, ``...``, ``....``, ... are handled
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
244 properly in expressions and yield a punctuation token.
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
245 They are not replaced by corresponding Unicode symbols.
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
246
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
247
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
248 Commands
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
249 ========
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
250
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
251 - Start with a backslash character ``\``
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
252 - Case-insensitive
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
253 - Yield mostly to :py:class:`pygments.Token.Keyword`
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
254 - Translated if a translation is found
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
255 - Depending on the command---may have required or optional parameters
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
256
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
257 Parameter handling is as follows:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
258
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
259 * Parameters are enclosed in curly braces ``{`` and ``}``
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
260 * Escaping within the braces is possible using the backslash ``\`` as
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
261 escape character
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
262 * Parameters are separated from the keyword/command by a (possibly empty) run
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
263 of space or TAB characters.
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
264 This is true for required and optional parameters.
209
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
265 - Unrecognized commands typically result in a
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
266 :py:class:`pygments.token.Token.Error` token.
162
11ce0903ff8b Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents: 160
diff changeset
267
209
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
268 More on escaping rules you can find in :ref:`this chapter <escaping-rules>`.
162
11ce0903ff8b Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents: 160
diff changeset
269
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
270
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
271 Commands With Required Parameters
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
272 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
273
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
274 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
275
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
276 \TEXT{\PROGRAM {A Program\} or \PROG {A Program\}} \PROGRAM {A Program}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
277 \TEXT{\ALGORITHM{An Algorithm\} or \ALGO{An Algorithm\}} \ALGORITHM{An Algorithm}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
278 \TEXT{\PROCEDURE{A Procedure\} or \PROC{A Procedure\}} \PROCEDURE{A Procedure}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
279 \TEXT{\FUNCTION{A Function\} or \FUNC{A Function\} or \FN{A Function\}} \FUNCTION{A Function}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
280 \TEXT{\CLASS{A Class\}} \CLASS{A Class}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
281
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
282 \TEXT{\STATEMENT{the expression\} \STATE{the expression\} \BLOCK{the expression\}} \STATEMENT{the expression}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
283
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
284 \TEXT{expr1: \\EXPRESSION{expression a in b\} expr2: \\EXPR{expression b in a\}} \TEXT{expr1: \EXPRESSION{expression a in b} expr2: \EXPR{expression b in a}}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
285
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
286 \TEXT{\TEXTSTATEMENT{the text\} \TEXTSTATE{the text\} \TSTATEMENT{the text\} \TSTATE{the text\} \TEXTBLOCK{the text\} \TBLOCK{the text\}} \TEXTSTATEMENT{the text}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
287
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
288 \TEXT{\INPUT{Input 1\}} \INPUT{Input 1}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
289 \TEXT{\INPUTS{Input 2\}} \INPUTS{Input 2}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
290
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
291 \TEXT{\OUTPUT{Output 1\}} \OUTPUT{Output 1}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
292 \TEXT{\OUTPUTS{Output 2\}} \OUTPUTS{Output 2}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
293
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
294 \TEXT{\ENSURE{Whatever should be ensured!\}} \ENSURE{Whatever should be ensured!}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
295
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
296 \TEXT{\REQUIRE{Whatever should be required.\}} \REQUIRE{Whatever should be required.}
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
297
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
298 \TEXT{\RETURNS{Return 2\}} \RETURNS{Return 2}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
299
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
300 \TEXT{\CALL{a function\}(p1, p2)} \CALL{a function}(p1, p2)
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
301
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
302 \TEXT{\NAME{an entity name\}} \NAME{an entity name}
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
303
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
304
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
305 Commands With Optional Parameters
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
306 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
307
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
308 Some ``END``-commands have optional parameters:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
309
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
310 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
311
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
312 \TEXT{\ENDPROGRAM \ENDPROG} \ENDPROGRAM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
313 \TEXT{\ENDALGORITHM \ENDALGO} \ENDALGORITHM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
314 \TEXT{\ENDPROCEDURE \ENDPROC} \ENDPROCEDURE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
315 \TEXT{\ENDFUNCTION \ENDFUNC \ENDFN} \ENDFUNCTION
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
316 \TEXT{\ENDCLASS} \ENDCLASS
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
317
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
318 They are used like this:
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
319
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
320 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
321
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
322 \TEXT{\CLASS{Foo Bar Class\} ... \END CLASS {Foo Bar Class\}} \TEXT{yields} \CLASS{Foo Bar Class} ... \END CLASS {Foo Bar Class}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
323
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
324 \TEXT{\CLASS{Foo Bar Class\} ... \END CLASS} \TEXT{yields} \CLASS{Foo Bar Class} ... \END CLASS
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
325
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
326 .. seealso:: For other syntax variants concerning `END` see also section
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
327 `END-Commands`_.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
328
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
329
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
330 Commands Without Parameters
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
331 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
332
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
333 "Normal" Commands
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
334 '''''''''''''''''
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
335
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
336 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
337
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
338 \TEXT{\IF} \IF
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
339 \TEXT{\THEN} \THEN
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
340 \TEXT{\ELSE} \ELSE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
341 \TEXT{\ELSEIF or \ELSIF or \ELIF} \ELSEIF \text{or} \ELSIF \text{or} \ELIF
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
342 \TEXT{\DO} \DO
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
343 \TEXT{\WHILE} \WHILE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
344 \TEXT{\FORALL} \FORALL
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
345 \TEXT{\FOR} \FOR
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
346 \TEXT{\FROM} \FROM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
347 \TEXT{\TO} \TO
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
348 \TEXT{\STEP} \STEP
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
349 \TEXT{\IN} \IN
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
350 \TEXT{\LOOP} \LOOP
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
351 \TEXT{\REPEAT} \REPEAT
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
352 \TEXT{\UNTIL} \UNTIL
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
353
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
354 \TEXT{\RETURN} \RETURN
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
355
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
356 \TEXT{\BEGIN} \BEGIN
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
357 \TEXT{\END} \END
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
358
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
359 \TEXT{\IS} \IS
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
360 \TEXT{\WITH} \WITH
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
361
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
362 \TEXT{\GETS} \GETS
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
363
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
364 \TEXT{\\REMARK or \\REM} \REMARK A comment with a leading symbol
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
365
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
366 ``\REMARK`` or ``\REM`` is special: all characters to the end of the
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
367 line are taken as comment; curly braces are not needed---in fact:
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
368 they are interpreted to be part of the comment.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
369
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
370
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
371 END-Commands
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
372 ''''''''''''
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
373
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
374 The separator character can be empty, a run of ASCII spaces, a run of
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
375 TAB characters, a single underscore ``_`` or a single hyphen ``-``
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
376 like:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
377
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
378 ``\ENDIF``, ``\END IF``, ``\END-IF``, ``\END_IF`` or ``\END IF``
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
379
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
380
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
381 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
382
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
383 \text{\ENDIF} \ENDIF \rem empty
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
384
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
385 \text{\END IF} \END IF \rem a single space
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
386
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
387 \text{\END IF} \END IF \rem two spaces
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
388
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
389 \text{\END-IF} \END-IF \rem a single hyphen
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
390
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
391 \text{\END_IF} \END_IF \rem a single underscore
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
392
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
393 \text{\END IF} \END IF \rem a single TAB character
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
394
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
395 The list of END-commands (here always just with ``-`` as separator):
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
396
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
397 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
398
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
399 \text{\END-PROGRAM \END-PROG} \END-PROGRAM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
400 \text{\END-ALGORITHM \END-ALGO} \END-ALGORITHM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
401 \text{\END-PROCEDURE \END-PROC} \END-PROCEDURE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
402 \text{\END-FUNCTION \END-FUNC \END-FN} \END-FUNCTION
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
403 \text{\END-CLASS} \END-CLASS
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
404 \text{\END-IF} \END-IF
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
405 \text{\END-WHILE} \END-WHILE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
406 \text{\END-FOR} \END-FOR
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
407 \text{\END-FORALL} \END-FORALL
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
408 \text{\END-LOOP} \END-LOOP
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
409
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
410 .. note:: The output of END-commands can be suppressed by setting the
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
411 lexer option ``no_end`` to :py:obj:`True`.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
412
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
413
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
414 Names and Entities
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
415 ==================
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
416
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
417 In an expression context all other words are interpreted as entity
156
123aeb2de8aa Explicitely call all markup with the domain
Franz Glasner <fzglas.hg@dom66.de>
parents: 154
diff changeset
418 names (token type :py:class:`pygments.token.Token.Name.Entity`).
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
419
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
420 Allowed characters in the words follow the corresponding `Python`_ rules.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
421 As such, many Unicode characters are allowed.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
422
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
423 To highlight entity names with whitespace or other "special" characters in it
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
424 use the ``NAME`` command.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
425
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
426 .. code-block:: algpseudocode
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
427
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
428 \TEXT{entity_name_1} entity_name_1
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
429
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
430 \TEXT{entity_name_2} entity_name_2
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
431
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
432 \TEXT{\NAME{entity-name 3\}} \NAME{entity-name 3}
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
433
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
434 \TEXT{München} München
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
435
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
436 \TEXT{Genève} Genève
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
437
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
438
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
439 .. _explicit-token-types:
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
440
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
441 Explicit Token Types
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
442 ====================
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
443
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
444 Handle keywords and operators that are not handled by default or change
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
445 the default handling of some expressions.
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
446
156
123aeb2de8aa Explicitely call all markup with the domain
Franz Glasner <fzglas.hg@dom66.de>
parents: 154
diff changeset
447 `XX` represents a `value` in the :py:data:`pygments.token.STANDARD_TYPES`
123aeb2de8aa Explicitely call all markup with the domain
Franz Glasner <fzglas.hg@dom66.de>
parents: 154
diff changeset
448 dict.
123aeb2de8aa Explicitely call all markup with the domain
Franz Glasner <fzglas.hg@dom66.de>
parents: 154
diff changeset
449 Its corresponding token type (the associated `key` in this `dict`) is
123aeb2de8aa Explicitely call all markup with the domain
Franz Glasner <fzglas.hg@dom66.de>
parents: 154
diff changeset
450 used as token type.
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
451
237
c4e8c7010ca0 FIX: Syntax description of "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 213
diff changeset
452 ``\tt-XX/SINGLE-CHAR``
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
453
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
454 no escaping needed
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
455
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
456 `SINGLE-CHAR` is a single character and can be *every* character
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
457 (including a carriage-return or line-feed)
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
458
237
c4e8c7010ca0 FIX: Syntax description of "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 213
diff changeset
459 ``\ttx-XX{CHARACTERS}``
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
460
237
c4e8c7010ca0 FIX: Syntax description of "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 213
diff changeset
461 ``\ttx-XX(CHARACTERS)``
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
462
237
c4e8c7010ca0 FIX: Syntax description of "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 213
diff changeset
463 ``\ttx-XX[CHARACTERS]``
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
464
237
c4e8c7010ca0 FIX: Syntax description of "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 213
diff changeset
465 ``\ttx-XX<CHARACTERS>``
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
466
237
c4e8c7010ca0 FIX: Syntax description of "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 213
diff changeset
467 ``\ttx-XX<SEP>CHARACTERS<SEP>``
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
468
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
469 No escaping possible! There are enough alternatives available!
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
470
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
471 `SEP` is one of ``/:|=*+!\$~``.
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
472
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
473
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
474 Examples:
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
475
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
476 .. code-block:: algpseudocode
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
477
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
478 \text{• \\tt-kc/C} \tt-kc/C \rem C as Keyword.Constant
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
479 \text{• \\tt-ow/∈} \tt-ow/∈ \rem ∈ as Operator.Word
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
480 \text{• \\ttx-kc{A New Constant Keyword\}} \ttx-kc{A New Constant Keyword} \rem As a new Keyword.Constant
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
481 \text{• \\ttx-nv{A New Variable Name\}} \ttx-nv{A New Variable Name} \rem An explicit Name.Variable
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
482 \text{• \\ttx-k(∈ ∌)} \ttx-k(∈ ∌) \rem ∈ and ∌ as (ordinary) Keywords
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
483 \text{• \\ttx-o<∈ ∌>} \ttx-o<∈ ∌> \rem ∈ and ∌ as (ordinary) Operators
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
484 /*
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
485 * The line below has ∈_∌ as (peculiar) function name.
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
486 * Their params are automatic (i.e. a normal expression).
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
487 */
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
488 \text{• \\ttx-nf<∈_∌>(p1, p2)} \ttx-nf<∈_∌>(p1, p2)
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
489 /*
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
490 * The line below has ∈_∌ as (peculiar) decorator name (as used in Python).
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
491 * Their params are automatic (i.e. a normal expression).
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
492 */
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
493 \text{• \\ttx-nd[∈_∌](p1, p2)} \ttx-nd[∈_∌](p1, p2)
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
494 /*
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
495 * This is a non-existing token type: you get some generic error marking
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
496 * with a Generic.Error token and no expansion.
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
497 */
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
498 \text{• \\ttx-NON-EXISTING[∈_∌](p1, p2)} \ttx-NON_EXISTING[∈_∌](p1, p2)
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
499
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
500 .. note:: Explicit token types are **case-sensitive**.
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
501
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
502
209
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
503 .. _escaping-rules:
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
504
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
505 Escaping Rules
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
506 ==============
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
507
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
508 The escape character is a backslash ``\``.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
509
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
510 A backslash can be escaped with ``\\`` and yields a single backslash token.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
511
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
512 Within parameters a closing curly brace ``}`` ends the current
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
513 parameters environment.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
514 It must be escaped using ``\}`` if a closing curly brace is part of the
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
515 argument content.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
516
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
517 A single backslash yields a :py:class:`pygments.token.Token.Generic.Error`
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
518 token when in `default` and `expression` states.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
519 Contrary---in `text` contexts a single backslash character that does not
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
520 introduce a command yields a normal text token.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
521
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
522 In all contexts a backslash that would normally introduce a known command
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
523 must be escaped if the content should not recognized as a command.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
524
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
525 Single- and double-quotes must be escaped also (``\"`` or ``\'``) in
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
526 `default` and `expression` contexts when they should not introduce a
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
527 string token.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
528
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
529
144
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
530 .. _customized-sphinx-lexers:
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
531
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
532 Customized Lexers in Sphinx
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
533 ===========================
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
534
144
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
535 Defining lexers with non-default options in `Sphinx`_ can be done in its
153
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
536 configuration file :file:`conf.py`.
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
537
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
538 The first option is to apply the Sphinx config value ``highlight_options``
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
539 properly. An existing lexer can be customized by options.
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
540
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
541 A more flexible alternative is to define a new lexer in the Sphinx
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
542 application. The very same lexer class can be used with different options:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
543
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
544 .. code-block:: python
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
545
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
546 from functools import partial
164
a4317957148b Move all lexers into a subpackage pygments_lexer_pseudocode2.lexers.
Franz Glasner <fzglas.hg@dom66.de>
parents: 162
diff changeset
547 from pygments_lexer_pseudocode2.lexers.algpseudocode import AlgPseudocodeLexer
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
548
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
549 def setup(app):
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
550
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
551 #
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
552 # Add a custom lexer: AlgPseudocodeLexer with custom init
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
553 # option "no_end".
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
554 #
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
555 # In modern Sphinx versions given lexer must be callable and may
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
556 # not be a lexer instance. So use an indirection with "partial"
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
557 # here.
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
558 #
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
559 app.add_lexer("noend-algpseudocode",
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
560 partial(AlgPseudocodeLexer, no_end=True))
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
561
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
562 Similarily it works for custom styles and filters.
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
563
158
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
564 .. note:: Lexers in Sphinx are instantiated with the `raiseonerror` filter
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
565 applied by default.
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
566 This is also true for custom lexers that are added by
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
567 :py:meth:`Sphinx.add_lexer`.
207
76053daf813e Extend the note in "Customized Lexers in Sphinx" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 201
diff changeset
568 Using the `filters` option the user can associate custom filters
76053daf813e Extend the note in "Customized Lexers in Sphinx" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 201
diff changeset
569 with a lexer.
76053daf813e Extend the note in "Customized Lexers in Sphinx" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 201
diff changeset
570 These filters have precedence over the default `raiseonerror`
76053daf813e Extend the note in "Customized Lexers in Sphinx" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 201
diff changeset
571 filter.
158
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
572
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
573 Lexer *instances* that are added to
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
574 :py:data:`sphinx.highlighting.lexers` somehow are taken as is by
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
575 Sphinx and are not augmented with any default filters.
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
576
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
577 For older Sphinx versions your mileage may vary.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
578
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
579
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
580 Some Examples
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
581 =============
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
582
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
583 A synthetic example with many features.
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
584
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
585 .. only:: builder_html
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
586
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
587 Its source code is in :download:`examples/example-1.pseudocode`.
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
588
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
589 .. raw:: latex
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
590
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
591 Its source code can be found at \url{example-1.pseudocode}.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
592
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
593 .. literalinclude:: examples/example-1.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
594 :language: algpseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
595 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
596
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
597 With a customized `AlgPseudocodeLexer` and its `no_end`
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
598 option set to :py:obj:`True`.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
599
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
600 .. literalinclude:: examples/example-1.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
601 :language: NoEndAlgPseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
602 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
603
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
604 The second example is Wikipedia's description of *Dinic's Algorithm*
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
605 (see https://en.wikipedia.org/wiki/Dinic%27s_algorithm).
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
606
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
607 .. only:: builder_html
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
608
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
609 Its source code is in :download:`examples/algorithm-dinic.pseudocode`.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
610
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
611 .. raw:: latex
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
612
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
613 Its source code can be found at \url{algorithm-dinic.pseudocode}
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
614
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
615 .. literalinclude:: examples/algorithm-dinic.pseudocode
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
616 :language: algpseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
617 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
618
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
619 The third example is Wikipedia's pseudocode of the *Ford–Fulkerson Algorithm*
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
620 (see https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm).
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
621
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
622 .. only:: builder_html
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
623
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
624 Its source code is in
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
625 :download:`examples/algorithm-ford-fulkerson.pseudocode`.
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
626
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
627 .. raw:: latex
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
628
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
629 Its source code can be found at \url{algorithm-ford-fulkerson.pseudocode}.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
630
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
631 .. literalinclude:: examples/algorithm-ford-fulkerson.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
632 :language: algpseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
633 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
634
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
635 The fourth example is Wikipedia's pseudocode of the *Edmonds–Karp Algorithm*
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
636 (see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm)
194
403b500e0ed4 FIX: Syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 193
diff changeset
637 with a custom lexer which skips all ``ENDxxx`` keywords.
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
638
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
639 .. only:: builder_html
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
640
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
641 Its source code is in
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
642 :download:`examples/algorithm-edmonds-karp.pseudocode`.
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
643
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
644 .. raw:: latex
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
645
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
646 Its source code can be found at \url{algorithm-edmonds-karp.pseudocode}.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
647
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
648 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
649 :language: NoEndAlgPseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
650 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
651
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
652 And now the *Edmonds–Karp Algorithm* with **french** keywords:
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
653
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
654 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
655 :language: algpseudocode-fr
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
656 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
657
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
658 And again the *Edmonds–Karp Algorithm* with **german** keywords:
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
659
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
660 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
661 :language: algpseudocode-de
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
662 :lines: 2-