Skip to content

Commit

Permalink
fixes #1625: infinite loop in SML lexer
Browse files Browse the repository at this point in the history
Reason was a lookahead-only pattern which was included in the state
where the lookahead was transitioning to.
  • Loading branch information
birkenfeld committed Dec 10, 2020
1 parent ccd14b9 commit f91804f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Expand Up @@ -11,6 +11,14 @@ Version 2.8.0
-------------
(not released yet)


Version 2.7.4
-------------
(not released yet)

- Fixed infinite loop in SML lexer (#1625)


Version 2.7.3
-------------
(released December 6, 2020)
Expand Down
12 changes: 6 additions & 6 deletions pygments/lexers/ml.py
Expand Up @@ -142,7 +142,7 @@ def id_callback(self, match):
(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'),
Expand Down Expand Up @@ -315,15 +315,14 @@ def id_callback(self, match):
'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': [
Expand Down Expand Up @@ -445,6 +444,7 @@ class OcamlLexer(RegexLexer):
],
}


class OpaLexer(RegexLexer):
"""
Lexer for the Opa language (http://opalang.org).
Expand Down

0 comments on commit f91804f

Please sign in to comment.