comparison pygments_lexer_pseudocode2/algpseudocode.py @ 94:dc17b778a52b

Refactor \END variants
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 03 May 2026 15:13:43 +0200
parents 84c0f761c836
children 98cd0787f62f
comparison
equal deleted inserted replaced
93:84c0f761c836 94:dc17b778a52b
201 r"|(?:class)" 201 r"|(?:class)"
202 r")[ \t]*(\{)", 202 r")[ \t]*(\{)",
203 bygroups(op_translate(Keyword), 203 bygroups(op_translate(Keyword),
204 LexBase.op_fixed(Whitespace, " ")), 204 LexBase.op_fixed(Whitespace, " ")),
205 "entity-name"), 205 "entity-name"),
206 # ENDxxx keywords with optional entity name 206 # ENDxxx keywords with optional entity name in two parts:
207 # with name 207 # 1. with name
208 (r"(?i)\\end(?:_|-)?(" 208 (r"(?i)\\end(?:[_\-]|(?:[ \t]+))?("
209 r"(?:prog(?:ram)?)" 209 r"(?:prog(?:ram)?)"
210 r"|(?:algo(?:rithm)?)" 210 r"|(?:algo(?:rithm)?)"
211 r"|(?:proc(?:edure)?)" 211 r"|(?:proc(?:edure)?)"
212 r"|(?:func(?:tion)?)" 212 r"|(?:func(?:tion)?)"
213 r"|(?:class)" 213 r"|(?:class)"
214 r")(?:_|(?:[\t -]+))?(\{)", 214 r")(?:[_\-]|(?:[\t ]+))?(\{)",
215 bygroups(op_opt_end_translate(Keyword), 215 bygroups(op_opt_end_translate(Keyword),
216 op_opt_ignore_or_fixed(Whitespace, " ")), 216 op_opt_ignore_or_fixed(Whitespace, " ")),
217 "entity-name-end"), 217 "entity-name-end"),
218 # without name 218 # 2. without name
219 (r"(?i)\\end(?:_|-)?(" 219 # 3. AND keywords that do not allow a param (e.g. endif)
220 (r"(?i)\\end(?:[_\-]|(?:[ \t]+))?("
220 r"(?:prog(?:ram)?)" 221 r"(?:prog(?:ram)?)"
221 r"|(?:algo(?:rithm)?)" 222 r"|(?:algo(?:rithm)?)"
222 r"|(?:proc(?:edure)?)" 223 r"|(?:proc(?:edure)?)"
223 r"|(?:func(?:tion)?)" 224 r"|(?:func(?:tion)?)"
224 r"|(?:class)" 225 r"|(?:class)"