Skip to content

Commit

Permalink
Update Fennel lexer to include forms from latest version.
Browse files Browse the repository at this point in the history
Also separate out declarations from other special forms and macros.
  • Loading branch information
technomancy committed Jul 14, 2021
1 parent 1ea5fc3 commit 092a120
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions pygments/lexers/lisp.py
Expand Up @@ -2631,23 +2631,22 @@ class FennelLexer(RegexLexer):
aliases = ['fennel', 'fnl']
filenames = ['*.fnl']

# these two lists are taken from fennel-mode.el:
# https://gitlab.com/technomancy/fennel-mode
# this list is current as of Fennel version 0.6.0.
# this list is current as of Fennel version 0.10.0.
special_forms = (
'require-macros', 'eval-compiler', 'doc', 'lua', 'hashfn',
'macro', 'macros', 'import-macros', 'pick-args', 'pick-values',
'macroexpand', 'macrodebug', 'do', 'values', 'if', 'when',
'each', 'for', 'fn', 'lambda', 'λ', 'partial', 'while',
'set', 'global', 'var', 'local', 'let', 'tset', 'set-forcibly!',
'doto', 'match', 'or', 'and', 'true', 'false', 'nil', 'not',
'not=', '.', '+', '..', '^', '-', '*', '%', '/', '>',
'<', '>=', '<=', '=', '...', ':', '->', '->>', '-?>',
'-?>>', 'rshift', 'lshift', 'bor', 'band', 'bnot', 'bxor',
'with-open', 'length'
'#', '%', '*', '+', '-', '->', '->>', '-?>', '-?>>', '.', '..',
'/', '//', ':', '<', '<=', '=', '>', '>=', '?.', '^', 'accumulate',
'and', 'band', 'bnot', 'bor', 'bxor', 'collect', 'comment', 'do', 'doc',
'doto', 'each', 'eval-compiler', 'for', 'hashfn', 'icollect', 'if',
'import-macros', 'include', 'length', 'let', 'lshift', 'lua',
'macrodebug', 'match', 'not', 'not=', 'or', 'partial', 'pick-args',
'pick-values', 'quote', 'require-macros', 'rshift', 'set',
'set-forcibly!', 'tset', 'values', 'when', 'while', 'with-open', '~='
)

declarations = (
'fn', 'global', 'lambda', 'local', 'macro', 'macros', 'var', 'λ'
)

# Might be nicer to use the list from _lua_builtins.py but it's unclear how?
builtins = (
'_G', '_VERSION', 'arg', 'assert', 'bit32', 'collectgarbage',
'coroutine', 'debug', 'dofile', 'error', 'getfenv',
Expand Down Expand Up @@ -2680,6 +2679,8 @@ class FennelLexer(RegexLexer):

# special forms are keywords
(words(special_forms, suffix=' '), Keyword),
# these are ... even more special!
(words(declarations, suffix=' '), Keyword.Declaration),
# lua standard library are builtins
(words(builtins, suffix=' '), Name.Builtin),
# special-case the vararg symbol
Expand Down

0 comments on commit 092a120

Please sign in to comment.