changeset 22:b42168cc9884

Use numbers from the Python lexer. This snippet has a BSD-2-Clause license; include a license file in LICENSES.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 20 Apr 2026 17:42:32 +0200
parents 5705ac8a4fd5
children bb2fd6d4ad69
files LICENSES/BSD-2-Clause.txt MANIFEST.in pygments_lexer_pseudocode2/__init__.py
diffstat 3 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSES/BSD-2-Clause.txt	Mon Apr 20 17:42:32 2026 +0200
@@ -0,0 +1,11 @@
+BSD 2-Clause "Simplified" License
+
+Copyright <YEAR> <COPYRIGHT HOLDER>
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- a/MANIFEST.in	Mon Apr 20 15:59:32 2026 +0200
+++ b/MANIFEST.in	Mon Apr 20 17:42:32 2026 +0200
@@ -1,3 +1,4 @@
 include .hg* *.txt
+graft LICENSES
 graft tests
 global-exclude *.pyc *.pyo
--- a/pygments_lexer_pseudocode2/__init__.py	Mon Apr 20 15:59:32 2026 +0200
+++ b/pygments_lexer_pseudocode2/__init__.py	Mon Apr 20 17:42:32 2026 +0200
@@ -75,7 +75,7 @@
                  include('strings'),
                  include('core'),
                  (r'[a-zéàùçèÉÀÙÇÈ][a-z0-9éàùçèÉÀÙÇÈ_]*', Name.Variable),
-                 include('nums'),
+                 include('numbers'),
                  (r'[\s]+', Text)
         ],
         'core':[ # Statements
@@ -113,10 +113,20 @@
                  (r'"([^"])*"', String.Double),
                  (r"'([^'])*'", String.Single),
                 ],
-
-        'nums': [
-                 (r'\d+(?![.Ee])', Number.Integer),
-                 (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
-                 (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float)
-                ],
+#        
+# This is stolen from the Pygment's Python lexer.
+#
+# SPDX-SnippetBegin
+# SPDX-License-Identifier: BSD-2-Clause
+# SPDX-SnippetCopyrightText: Copyright 2006-2023 by the Pygments team
+        'numbers': [
+            (r'(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)'
+             r'([eE][+-]?\d(?:_?\d)*)?', Number.Float),
+            (r'\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?', Number.Float),
+            (r'0[oO](?:_?[0-7])+', Number.Oct),
+            (r'0[bB](?:_?[01])+', Number.Bin),
+            (r'0[xX](?:_?[a-fA-F0-9])+', Number.Hex),
+            (r'\d(?:_?\d)*', Number.Integer),
+        ],
+# SPDX-SnippetEnd
         }