]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/vhdl.js
Initial commit.
[flow-web.git] / static / highlight / languages / vhdl.js
1 /*! `vhdl` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: VHDL
8 Author: Igor Kalnitsky <igor@kalnitsky.org>
9 Contributors: Daniel C.K. Kho <daniel.kho@tauhop.com>, Guillaume Savaton <guillaume.savaton@eseo.fr>
10 Description: VHDL is a hardware description language used in electronic design automation to describe digital and mixed-signal systems.
11 Website: https://en.wikipedia.org/wiki/VHDL
12 Category: hardware
13 */
14
15 function vhdl(hljs) {
16 // Regular expression for VHDL numeric literals.
17
18 // Decimal literal:
19 const INTEGER_RE = '\\d(_|\\d)*';
20 const EXPONENT_RE = '[eE][-+]?' + INTEGER_RE;
21 const DECIMAL_LITERAL_RE = INTEGER_RE + '(\\.' + INTEGER_RE + ')?' + '(' + EXPONENT_RE + ')?';
22 // Based literal:
23 const BASED_INTEGER_RE = '\\w+';
24 const BASED_LITERAL_RE = INTEGER_RE + '#' + BASED_INTEGER_RE + '(\\.' + BASED_INTEGER_RE + ')?' + '#' + '(' + EXPONENT_RE + ')?';
25
26 const NUMBER_RE = '\\b(' + BASED_LITERAL_RE + '|' + DECIMAL_LITERAL_RE + ')';
27
28 const KEYWORDS = [
29 "abs",
30 "access",
31 "after",
32 "alias",
33 "all",
34 "and",
35 "architecture",
36 "array",
37 "assert",
38 "assume",
39 "assume_guarantee",
40 "attribute",
41 "begin",
42 "block",
43 "body",
44 "buffer",
45 "bus",
46 "case",
47 "component",
48 "configuration",
49 "constant",
50 "context",
51 "cover",
52 "disconnect",
53 "downto",
54 "default",
55 "else",
56 "elsif",
57 "end",
58 "entity",
59 "exit",
60 "fairness",
61 "file",
62 "for",
63 "force",
64 "function",
65 "generate",
66 "generic",
67 "group",
68 "guarded",
69 "if",
70 "impure",
71 "in",
72 "inertial",
73 "inout",
74 "is",
75 "label",
76 "library",
77 "linkage",
78 "literal",
79 "loop",
80 "map",
81 "mod",
82 "nand",
83 "new",
84 "next",
85 "nor",
86 "not",
87 "null",
88 "of",
89 "on",
90 "open",
91 "or",
92 "others",
93 "out",
94 "package",
95 "parameter",
96 "port",
97 "postponed",
98 "procedure",
99 "process",
100 "property",
101 "protected",
102 "pure",
103 "range",
104 "record",
105 "register",
106 "reject",
107 "release",
108 "rem",
109 "report",
110 "restrict",
111 "restrict_guarantee",
112 "return",
113 "rol",
114 "ror",
115 "select",
116 "sequence",
117 "severity",
118 "shared",
119 "signal",
120 "sla",
121 "sll",
122 "sra",
123 "srl",
124 "strong",
125 "subtype",
126 "then",
127 "to",
128 "transport",
129 "type",
130 "unaffected",
131 "units",
132 "until",
133 "use",
134 "variable",
135 "view",
136 "vmode",
137 "vprop",
138 "vunit",
139 "wait",
140 "when",
141 "while",
142 "with",
143 "xnor",
144 "xor"
145 ];
146 const BUILT_INS = [
147 "boolean",
148 "bit",
149 "character",
150 "integer",
151 "time",
152 "delay_length",
153 "natural",
154 "positive",
155 "string",
156 "bit_vector",
157 "file_open_kind",
158 "file_open_status",
159 "std_logic",
160 "std_logic_vector",
161 "unsigned",
162 "signed",
163 "boolean_vector",
164 "integer_vector",
165 "std_ulogic",
166 "std_ulogic_vector",
167 "unresolved_unsigned",
168 "u_unsigned",
169 "unresolved_signed",
170 "u_signed",
171 "real_vector",
172 "time_vector"
173 ];
174 const LITERALS = [
175 // severity_level
176 "false",
177 "true",
178 "note",
179 "warning",
180 "error",
181 "failure",
182 // textio
183 "line",
184 "text",
185 "side",
186 "width"
187 ];
188
189 return {
190 name: 'VHDL',
191 case_insensitive: true,
192 keywords: {
193 keyword: KEYWORDS,
194 built_in: BUILT_INS,
195 literal: LITERALS
196 },
197 illegal: /\{/,
198 contains: [
199 hljs.C_BLOCK_COMMENT_MODE, // VHDL-2008 block commenting.
200 hljs.COMMENT('--', '$'),
201 hljs.QUOTE_STRING_MODE,
202 {
203 className: 'number',
204 begin: NUMBER_RE,
205 relevance: 0
206 },
207 {
208 className: 'string',
209 begin: '\'(U|X|0|1|Z|W|L|H|-)\'',
210 contains: [ hljs.BACKSLASH_ESCAPE ]
211 },
212 {
213 className: 'symbol',
214 begin: '\'[A-Za-z](_?[A-Za-z0-9])*',
215 contains: [ hljs.BACKSLASH_ESCAPE ]
216 }
217 ]
218 };
219 }
220
221 return vhdl;
222
223 })();
224
225 hljs.registerLanguage('vhdl', hljsGrammar);
226 })();