Skip to content

Commit

Permalink
Merge pull request #47 from e-kayrakli/new-keywords
Browse files Browse the repository at this point in the history
Add new keywords and : operator to the pygments lexer

The new keywords in Chapel 1.24: `operator`, `foreach`, `implements`, `interface`
We also accept `:` as operator, now.

While there, also adds `primitive` as a keyword to the lexer.

[Reviewed by @lydia-duncan]
  • Loading branch information
e-kayrakli committed Mar 9, 2021
2 parents 61a95ad + bbc6b9f commit b8d69d5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sphinxcontrib/chapeldomain/chapel.py
Expand Up @@ -5,7 +5,7 @@
Lexer for the Chapel language.
:copyright: Copyright 2006-2020 by the Pygments team, Thomas van Doren
:copyright: Copyright 2006-2021 by the Pygments team, Thomas van Doren
:license: BSD, see LICENSE for details.
"""

Expand Down Expand Up @@ -45,12 +45,12 @@ class ChapelLexer(RegexLexer):
'catch', 'cobegin', 'coforall', 'continue',
'defer', 'delete', 'dmapped', 'do', 'domain',
'else', 'enum', 'except', 'export', 'extern',
'for', 'forall', 'forwarding',
'if', 'import', 'index', 'init', 'inline',
'for', 'forall', 'foreach', 'forwarding',
'if', 'implements', 'import', 'index', 'init', 'inline',
'label', 'lambda', 'let', 'lifetime', 'local',
'new', 'noinit',
'on', 'only', 'otherwise', 'override',
'pragma', 'private', 'prototype', 'public',
'pragma', 'primitive', 'private', 'prototype', 'public',
'reduce', 'require', 'return',
'scan', 'select', 'serial', 'sparse', 'subdomain',
'then', 'this', 'throw', 'throws', 'try',
Expand All @@ -75,8 +75,10 @@ class ChapelLexer(RegexLexer):

(r'(iter)((?:\s)+)', bygroups(Keyword, Text), 'procname'),
(r'(proc)((?:\s)+)', bygroups(Keyword, Text), 'procname'),
(r'(class|module|record|union)(\s+)', bygroups(Keyword, Text),
'classname'),
(r'(operator)((?:\s)+)', bygroups(Keyword, Text), 'procname'),
(r'(class|interface|module|record|union)(\s+)',
bygroups(Keyword, Text),
'classname'),

# imaginary integers
(r'\d+i', Number),
Expand Down Expand Up @@ -120,7 +122,7 @@ class ChapelLexer(RegexLexer):
'procname': [
(r'([a-zA-Z_][.\w$]*|' # regular function name, including 2ndary
r'\~[a-zA-Z_][.\w$]*|' # support for legacy destructors?
r'[+*/!~%<>=&^|\-]{1,2})', # operators
r'[+*/!~%<>=&^|\-:]{1,2})', # operators
Name.Function, '#pop'),

# allow `proc (atomic T).foo`
Expand Down

0 comments on commit b8d69d5

Please sign in to comment.