]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/elm.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / elm.js
1 /*! `elm` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Elm
7 Author: Janis Voigtlaender <janis.voigtlaender@gmail.com>
8 Website: https://elm-lang.org
9 Category: functional
10 */
11
12 /** @type LanguageFn */
13 function elm(hljs) {
14 const COMMENT = { variants: [
15 hljs.COMMENT('--', '$'),
16 hljs.COMMENT(
17 /\{-/,
18 /-\}/,
19 { contains: [ 'self' ] }
20 )
21 ] };
22
23 const CONSTRUCTOR = {
24 className: 'type',
25 begin: '\\b[A-Z][\\w\']*', // TODO: other constructors (built-in, infix).
26 relevance: 0
27 };
28
29 const LIST = {
30 begin: '\\(',
31 end: '\\)',
32 illegal: '"',
33 contains: [
34 {
35 className: 'type',
36 begin: '\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?'
37 },
38 COMMENT
39 ]
40 };
41
42 const RECORD = {
43 begin: /\{/,
44 end: /\}/,
45 contains: LIST.contains
46 };
47
48 const CHARACTER = {
49 className: 'string',
50 begin: '\'\\\\?.',
51 end: '\'',
52 illegal: '.'
53 };
54
55 const KEYWORDS = [
56 "let",
57 "in",
58 "if",
59 "then",
60 "else",
61 "case",
62 "of",
63 "where",
64 "module",
65 "import",
66 "exposing",
67 "type",
68 "alias",
69 "as",
70 "infix",
71 "infixl",
72 "infixr",
73 "port",
74 "effect",
75 "command",
76 "subscription"
77 ];
78
79 return {
80 name: 'Elm',
81 keywords: KEYWORDS,
82 contains: [
83
84 // Top-level constructions.
85
86 {
87 beginKeywords: 'port effect module',
88 end: 'exposing',
89 keywords: 'port effect module where command subscription exposing',
90 contains: [
91 LIST,
92 COMMENT
93 ],
94 illegal: '\\W\\.|;'
95 },
96 {
97 begin: 'import',
98 end: '$',
99 keywords: 'import as exposing',
100 contains: [
101 LIST,
102 COMMENT
103 ],
104 illegal: '\\W\\.|;'
105 },
106 {
107 begin: 'type',
108 end: '$',
109 keywords: 'type alias',
110 contains: [
111 CONSTRUCTOR,
112 LIST,
113 RECORD,
114 COMMENT
115 ]
116 },
117 {
118 beginKeywords: 'infix infixl infixr',
119 end: '$',
120 contains: [
121 hljs.C_NUMBER_MODE,
122 COMMENT
123 ]
124 },
125 {
126 begin: 'port',
127 end: '$',
128 keywords: 'port',
129 contains: [ COMMENT ]
130 },
131
132 // Literals and names.
133 CHARACTER,
134 hljs.QUOTE_STRING_MODE,
135 hljs.C_NUMBER_MODE,
136 CONSTRUCTOR,
137 hljs.inherit(hljs.TITLE_MODE, { begin: '^[_a-z][\\w\']*' }),
138 COMMENT,
139
140 { // No markup, relevance booster
141 begin: '->|<-' }
142 ],
143 illegal: /;/
144 };
145 }
146
147 return elm;
148
149 })();
150 ;
151 export default hljsGrammar;