Skip to content

Commit 338d366

Browse files
authored
Merge pull request #2670 from Kodiologist/hylex
Improve Hy support
2 parents 4d1371b + a737674 commit 338d366

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

pygments/lexers/_mapping.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@
216216
'HtmlSmartyLexer': ('pygments.lexers.templates', 'HTML+Smarty', ('html+smarty',), (), ('text/html+smarty',)),
217217
'HttpLexer': ('pygments.lexers.textfmts', 'HTTP', ('http',), (), ()),
218218
'HxmlLexer': ('pygments.lexers.haxe', 'Hxml', ('haxeml', 'hxml'), ('*.hxml',), ()),
219-
'HyLexer': ('pygments.lexers.lisp', 'Hy', ('hylang',), ('*.hy',), ('text/x-hy', 'application/x-hy')),
220-
'HybrisLexer': ('pygments.lexers.scripting', 'Hybris', ('hybris', 'hy'), ('*.hy', '*.hyb'), ('text/x-hybris', 'application/x-hybris')),
219+
'HyLexer': ('pygments.lexers.lisp', 'Hy', ('hylang', 'hy'), ('*.hy',), ('text/x-hy', 'application/x-hy')),
220+
'HybrisLexer': ('pygments.lexers.scripting', 'Hybris', ('hybris',), ('*.hyb',), ('text/x-hybris', 'application/x-hybris')),
221221
'IDLLexer': ('pygments.lexers.idl', 'IDL', ('idl',), ('*.pro',), ('text/idl',)),
222222
'IconLexer': ('pygments.lexers.unicon', 'Icon', ('icon',), ('*.icon', '*.ICON'), ()),
223223
'IdrisLexer': ('pygments.lexers.haskell', 'Idris', ('idris', 'idr'), ('*.idr',), ('text/x-idris',)),

pygments/lexers/lisp.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class HyLexer(RegexLexer):
486486
"""
487487
name = 'Hy'
488488
url = 'http://hylang.org/'
489-
aliases = ['hylang']
489+
aliases = ['hylang', 'hy']
490490
filenames = ['*.hy']
491491
mimetypes = ['text/x-hy', 'application/x-hy']
492492
version_added = '2.0'
@@ -519,7 +519,7 @@ class HyLexer(RegexLexer):
519519
# valid names for identifiers
520520
# well, names can only not consist fully of numbers
521521
# but this should be good enough for now
522-
valid_name = r'(?!#)[\w!$%*+<=>?/.#:-]+'
522+
valid_name = r"[^ \t\n\r\f\v()[\]{};\"'`~]+"
523523

524524
def _multi_escape(entries):
525525
return words(entries, suffix=' ')
@@ -531,8 +531,7 @@ def _multi_escape(entries):
531531
(r';.*$', Comment.Single),
532532

533533
# whitespaces - usually not relevant
534-
(r',+', Text),
535-
(r'\s+', Whitespace),
534+
(r'[ \t\n\r\f\v]+', Whitespace),
536535

537536
# numbers
538537
(r'-?\d+\.\d+', Number.Float),

pygments/lexers/scripting.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,8 @@ class HybrisLexer(RegexLexer):
11791179
"""
11801180

11811181
name = 'Hybris'
1182-
aliases = ['hybris', 'hy']
1183-
filenames = ['*.hy', '*.hyb']
1182+
aliases = ['hybris']
1183+
filenames = ['*.hyb']
11841184
mimetypes = ['text/x-hybris', 'application/x-hybris']
11851185
url = 'https://github.com/evilsocket/hybris'
11861186
version_added = '1.4'

tests/examplefiles/hylang/language.hy

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
;;;;
44

55

6-
(defn _numeric-check [x]
7-
(if (not (numeric? x))
8-
(raise (TypeError (.format "{0!r} is not a number" x)))))
6+
(defn _numeric-check []
7+
(if (not (numeric? ))
8+
(raise (TypeError (.format "{0!r} (↻) is not a number" )))))
99

1010
(defn cycle [coll]
1111
"Yield an infinite repetition of the items in coll"

tests/examplefiles/hylang/language.hy.output

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)