1 /*! `nix` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
7 Author: Domen Kožar <domen@dev.si>
8 Description: Nix functional language
9 Website: http://nixos.org/nix
13 /** @type LanguageFn */
15 const regex
= hljs
.regex
;
60 match: regex
.either(...[
63 "addDrvOutputDependencies",
174 "unsafeDiscardOutputDependency",
175 "unsafeDiscardStringContext",
179 ].map(b
=> `builtins\\.${b}`)),
183 const IDENTIFIER_REGEX
= '[A-Za-z_][A-Za-z0-9_\'-]*';
185 const LOOKUP_PATH
= {
187 match: new RegExp(`<${IDENTIFIER_REGEX}(/${IDENTIFIER_REGEX})*>`),
190 const PATH_PIECE
= "[A-Za-z0-9_\\+\\.-]+";
193 match: new RegExp(`(\\.\\.|\\.|~)?/(${PATH_PIECE})?(/${PATH_PIECE})*(?=[\\s;])`),
196 const OPERATOR_WITHOUT_MINUS_REGEX
= regex
.either(...[
220 match: regex
.concat(OPERATOR_WITHOUT_MINUS_REGEX
, /(?!-)/),
224 // '-' is being handled by itself to ensure we are able to tell the difference
225 // between a dash in an identifier and a minus operator
228 match: new RegExp(`${hljs.NUMBER_RE}(?!-)`),
231 const MINUS_OPERATOR
= {
236 // The (?!>) is used to ensure this doesn't collide with the '->' operator
241 new RegExp(`${hljs.NUMBER_RE}`),
252 OPERATOR_WITHOUT_MINUS_REGEX
,
266 beforeMatch: /(^|\{|;)\s*/,
267 begin: new RegExp(`${IDENTIFIER_REGEX}(\\.${IDENTIFIER_REGEX})*\\s*=(?!=)`),
273 match: new RegExp(`${IDENTIFIER_REGEX}(\\.${IDENTIFIER_REGEX})*(?=\\s*=)`),
279 const NORMAL_ESCAPED_DOLLAR
= {
280 scope: 'char.escape',
283 const INDENTED_ESCAPED_DOLLAR
= {
284 scope: 'char.escape',
293 const ESCAPED_DOUBLEQUOTE
= {
294 scope: 'char.escape',
297 const ESCAPED_LITERAL
= {
298 scope: 'char.escape',
308 INDENTED_ESCAPED_DOLLAR
,
318 NORMAL_ESCAPED_DOLLAR
,
326 const FUNCTION_PARAMS
= {
328 match: new RegExp(`${IDENTIFIER_REGEX}\\s*:(?=\\s)`),
331 const EXPRESSIONS
= [
333 hljs
.HASH_COMMENT_MODE
,
334 hljs
.C_BLOCK_COMMENT_MODE
,
339 subLanguage: 'markdown',
353 ANTIQUOTE
.contains
= EXPRESSIONS
;
357 scope: 'meta.prompt',
358 match: /^nix-repl>(?=\s)/,
364 begin: /:([a-z]+|\?)/,
370 aliases: [ "nixos" ],
372 contains: EXPRESSIONS
.concat(REPL
),
380 export default hljsGrammar
;