From f91804ff4772e3ab41f46e28d370f57898700333 Mon Sep 17 00:00:00 2001
From: Georg Brandl <georg@python.org>
Date: Thu, 10 Dec 2020 08:19:21 +0100
Subject: [PATCH] fixes #1625: infinite loop in SML lexer

https://github.com/pygments/pygments/commit/f91804ff4772e3ab41f46e28d370f57898700333

Reason was a lookahead-only pattern which was included in the state
where the lookahead was transitioning to.
---
 pygments/lexers/ml.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/pygments/lexers/ml.py b/pygments/lexers/ml.py
index 461af88..b8d78f5 100644
--- a/pygments/lexers/ml.py
+++ b/pygments/lexers/ml.py
@@ -142,7 +142,7 @@ class SMLLexer(RegexLexer):
             (r'#\s+(%s)' % symbolicid_re, Name.Label),
             # Some reserved words trigger a special, local lexer state change
             (r'\b(datatype|abstype)\b(?!\')', Keyword.Reserved, 'dname'),
-            (r'(?=\b(exception)\b(?!\'))', Text, ('ename')),
+            (r'\b(exception)\b(?!\')', Keyword.Reserved, 'ename'),
             (r'\b(functor|include|open|signature|structure)\b(?!\')',
              Keyword.Reserved, 'sname'),
             (r'\b(type|eqtype)\b(?!\')', Keyword.Reserved, 'tname'),
@@ -315,15 +315,14 @@ class SMLLexer(RegexLexer):
         'ename': [
             include('whitespace'),
 
-            (r'(exception|and)\b(\s+)(%s)' % alphanumid_re,
+            (r'(and\b)(\s+)(%s)' % alphanumid_re,
              bygroups(Keyword.Reserved, Text, Name.Class)),
-            (r'(exception|and)\b(\s*)(%s)' % symbolicid_re,
+            (r'(and\b)(\s*)(%s)' % symbolicid_re,
              bygroups(Keyword.Reserved, Text, Name.Class)),
             (r'\b(of)\b(?!\')', Keyword.Reserved),
+            (r'(%s)|(%s)' % (alphanumid_re, symbolicid_re), Name.Class),
 
-            include('breakout'),
-            include('core'),
-            (r'\S+', Error),
+            default('#pop'),
         ],
 
         'datcon': [
@@ -446,6 +445,7 @@ class OcamlLexer(RegexLexer):
     }
 
 
+
 class OpaLexer(RegexLexer):
     """
     Lexer for the Opa language (http://opalang.org).
-- 
2.13.7

