]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/hy.js
Initial commit.
[flow-web.git] / static / highlight / languages / hy.js
1 /*! `hy` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Hy
8 Description: Hy is a wonderful dialect of Lisp that’s embedded in Python.
9 Author: Sergey Sobko <s.sobko@profitware.ru>
10 Website: http://docs.hylang.org/en/stable/
11 Category: lisp
12 */
13
14 function hy(hljs) {
15 const SYMBOLSTART = 'a-zA-Z_\\-!.?+*=<>&#\'';
16 const SYMBOL_RE = '[' + SYMBOLSTART + '][' + SYMBOLSTART + '0-9/;:]*';
17 const keywords = {
18 $pattern: SYMBOL_RE,
19 built_in:
20 // keywords
21 '!= % %= & &= * ** **= *= *map '
22 + '+ += , --build-class-- --import-- -= . / // //= '
23 + '/= < << <<= <= = > >= >> >>= '
24 + '@ @= ^ ^= abs accumulate all and any ap-compose '
25 + 'ap-dotimes ap-each ap-each-while ap-filter ap-first ap-if ap-last ap-map ap-map-when ap-pipe '
26 + 'ap-reduce ap-reject apply as-> ascii assert assoc bin break butlast '
27 + 'callable calling-module-name car case cdr chain chr coll? combinations compile '
28 + 'compress cond cons cons? continue count curry cut cycle dec '
29 + 'def default-method defclass defmacro defmacro-alias defmacro/g! defmain defmethod defmulti defn '
30 + 'defn-alias defnc defnr defreader defseq del delattr delete-route dict-comp dir '
31 + 'disassemble dispatch-reader-macro distinct divmod do doto drop drop-last drop-while empty? '
32 + 'end-sequence eval eval-and-compile eval-when-compile even? every? except exec filter first '
33 + 'flatten float? fn fnc fnr for for* format fraction genexpr '
34 + 'gensym get getattr global globals group-by hasattr hash hex id '
35 + 'identity if if* if-not if-python2 import in inc input instance? '
36 + 'integer integer-char? integer? interleave interpose is is-coll is-cons is-empty is-even '
37 + 'is-every is-float is-instance is-integer is-integer-char is-iterable is-iterator is-keyword is-neg is-none '
38 + 'is-not is-numeric is-odd is-pos is-string is-symbol is-zero isinstance islice issubclass '
39 + 'iter iterable? iterate iterator? keyword keyword? lambda last len let '
40 + 'lif lif-not list* list-comp locals loop macro-error macroexpand macroexpand-1 macroexpand-all '
41 + 'map max merge-with method-decorator min multi-decorator multicombinations name neg? next '
42 + 'none? nonlocal not not-in not? nth numeric? oct odd? open '
43 + 'or ord partition permutations pos? post-route postwalk pow prewalk print '
44 + 'product profile/calls profile/cpu put-route quasiquote quote raise range read read-str '
45 + 'recursive-replace reduce remove repeat repeatedly repr require rest round route '
46 + 'route-with-methods rwm second seq set-comp setattr setv some sorted string '
47 + 'string? sum switch symbol? take take-nth take-while tee try unless '
48 + 'unquote unquote-splicing vars walk when while with with* with-decorator with-gensyms '
49 + 'xi xor yield yield-from zero? zip zip-longest | |= ~'
50 };
51
52 const SIMPLE_NUMBER_RE = '[-+]?\\d+(\\.\\d+)?';
53
54 const SYMBOL = {
55 begin: SYMBOL_RE,
56 relevance: 0
57 };
58 const NUMBER = {
59 className: 'number',
60 begin: SIMPLE_NUMBER_RE,
61 relevance: 0
62 };
63 const STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null });
64 const COMMENT = hljs.COMMENT(
65 ';',
66 '$',
67 { relevance: 0 }
68 );
69 const LITERAL = {
70 className: 'literal',
71 begin: /\b([Tt]rue|[Ff]alse|nil|None)\b/
72 };
73 const COLLECTION = {
74 begin: '[\\[\\{]',
75 end: '[\\]\\}]',
76 relevance: 0
77 };
78 const HINT = {
79 className: 'comment',
80 begin: '\\^' + SYMBOL_RE
81 };
82 const HINT_COL = hljs.COMMENT('\\^\\{', '\\}');
83 const KEY = {
84 className: 'symbol',
85 begin: '[:]{1,2}' + SYMBOL_RE
86 };
87 const LIST = {
88 begin: '\\(',
89 end: '\\)'
90 };
91 const BODY = {
92 endsWithParent: true,
93 relevance: 0
94 };
95 const NAME = {
96 className: 'name',
97 relevance: 0,
98 keywords: keywords,
99 begin: SYMBOL_RE,
100 starts: BODY
101 };
102 const DEFAULT_CONTAINS = [
103 LIST,
104 STRING,
105 HINT,
106 HINT_COL,
107 COMMENT,
108 KEY,
109 COLLECTION,
110 NUMBER,
111 LITERAL,
112 SYMBOL
113 ];
114
115 LIST.contains = [
116 hljs.COMMENT('comment', ''),
117 NAME,
118 BODY
119 ];
120 BODY.contains = DEFAULT_CONTAINS;
121 COLLECTION.contains = DEFAULT_CONTAINS;
122
123 return {
124 name: 'Hy',
125 aliases: [ 'hylang' ],
126 illegal: /\S/,
127 contains: [
128 hljs.SHEBANG(),
129 LIST,
130 STRING,
131 HINT,
132 HINT_COL,
133 COMMENT,
134 KEY,
135 COLLECTION,
136 NUMBER,
137 LITERAL
138 ]
139 };
140 }
141
142 return hy;
143
144 })();
145
146 hljs.registerLanguage('hy', hljsGrammar);
147 })();