site/node_modules/shiki/dist/langs/haskell.mjs

34 lines
45 KiB
JavaScript
Raw Normal View History

2024-10-14 06:09:33 +00:00
const lang = Object.freeze({ "displayName": "Haskell", "fileTypes": ["hs", "hs-boot", "hsig"], "name": "haskell", "patterns": [{ "include": "#liquid_haskell" }, { "include": "#comment_like" }, { "include": "#numeric_literals" }, { "include": "#string_literal" }, { "include": "#char_literal" }, { "match": "(?<!@|#)-\\}", "name": "invalid" }, { "captures": { "1": { "name": "punctuation.paren.haskell" }, "2": { "name": "punctuation.paren.haskell" } }, "match": "(\\()\\s*(\\))", "name": "constant.language.unit.haskell" }, { "captures": { "1": { "name": "punctuation.paren.haskell" }, "2": { "name": "keyword.operator.hash.haskell" }, "3": { "name": "keyword.operator.hash.haskell" }, "4": { "name": "punctuation.paren.haskell" } }, "match": "(\\()(#)\\s*(#)(\\))", "name": "constant.language.unit.unboxed.haskell" }, { "captures": { "1": { "name": "punctuation.paren.haskell" }, "2": { "name": "punctuation.paren.haskell" } }, "match": "(\\()\\s*,[\\s,]*(\\))", "name": "support.constant.tuple.haskell" }, { "captures": { "1": { "name": "punctuation.paren.haskell" }, "2": { "name": "keyword.operator.hash.haskell" }, "3": { "name": "keyword.operator.hash.haskell" }, "4": { "name": "punctuation.paren.haskell" } }, "match": "(\\()(#)\\s*,[\\s,]*(#)(\\))", "name": "support.constant.tuple.unboxed.haskell" }, { "captures": { "1": { "name": "punctuation.bracket.haskell" }, "2": { "name": "punctuation.bracket.haskell" } }, "match": "(\\[)\\s*(\\])", "name": "constant.language.empty-list.haskell" }, { "begin": "(\\b(?<!')(module)|^(signature))(\\b(?!'))", "beginCaptures": { "2": { "name": "keyword.other.module.haskell" }, "3": { "name": "keyword.other.signature.haskell" } }, "end": "(?=\\b(?<!')where\\b(?!'))", "name": "meta.declaration.module.haskell", "patterns": [{ "include": "#comment_like" }, { "include": "#module_name" }, { "include": "#module_exports" }, { "match": "[a-z]+", "name": "invalid" }] }, { "include": "#ffi" }, { "begin": "^(\\s*)(class)(\\b(?!'))", "beginCaptures": { "2": { "name": "keyword.other.class.haskell" } }, "end": "(?x)\n\n(?=(?<!')\\bwhere\\b(?!'))\n\n|(?=\\}|;)\n|^(?!\n\\1\\s+\\S\n| \\s*\n(?: $\n|\\{-[^@]\n|--+\n(?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_\"']]).*$)\n\n\n)", "name": "meta.declaration.class.haskell", "patterns": [{ "include": "#comment_like" }, { "include": "#where" }, { "include": "#type_signature" }] }, { "begin": "(?x)\n^(\\s*)(data|newtype)(?:\\s+(instance))?\\s+\n\n((?:(?!\n\n(?:\n(?<![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])\n(?:=|--+)\n(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])\n)\n\n| (?:\\b(?<!')(?:where|deriving)\\b(?!'))\n\n| {-\n\n).)*)\n(?=\\b(?<!'')where\\b(?!''))", "beginCaptures": { "2": { "name": "keyword.other.$2.haskell" }, "3": { "name": "keyword.other.instance.haskell" }, "4": { "patterns": [{ "include": "#type_signature" }] } }, "end": "(?x)\n\n(?=(?<!')\\bderiving\\b(?!'))\n\n|(?=\\}|;)\n|^(?!\n\\1\\s+\\S\n| \\s*\n(?: $\n|\\{-[^@]\n|--+\n(?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_\"']]).*$)\n\n\n)\n", "name": "meta.declaration.$2.generalized.haskell", "patterns": [{ "include": "#comment_like" }, { "begin": "(?x)\n(?<!')\\b(where)\n\\s*(\\{)(?!-)", "beginCaptures": { "1": { "name": "keyword.other.where.haskell" }, "2": { "name": "punctuation.brace.haskell" } }, "end": "(\\})", "endCaptures": { "1": { "name": "punctuation.brace.haskell" } }, "patterns": [{ "include": "#comment_like" }, { "include": "#gadt_constructor" }, { "match": ";", "name": "punctuation.semicolon.haskell" }] }, { "match": "\\b(?<!')(where)\\b(?!')", "name": "keyword.other.where.haskell" }, { "include": "#deriving" }, { "include": "#gadt_constructor" }] }, { "include": "#role_annotation" }, { "begin": "^(\\s*)(pattern)\\s+(.*?)\\s+(::|\u2237)(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])", "beginCaptures": { "2": { "name": "keyword.other.pattern.haskell" }, "3": { "patterns": [{ "include": "#comma" }, { "include": "#data_constructor" }] }, "4": { "name": "keyword.operator.double-colon.haskell" } }, "end": "(?x)\n(?=\\}|;)\n|^(?!\n\\1\\s+\\S\n| \\s*\n(?: $\n|\\{-[^@]\n|--+\n(?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_\"']]).*$)\n\n\n)\n", "name": "m
(?<![\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}'])
(')
(?:
[\\ -\\[\\]-~]
| (\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE
|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS
|US|SP|DEL|[abfnrtv\\\\\\"'\\\\&]))
| (\\\\o[0-7]+)
| (\\\\x[0-9A-Fa-f]+)
| (\\\\\\^[A-Z@\\[\\]\\\\\\^_])
)
(')
`, "name": "string.quoted.single.haskell" }, "comma": { "match": ",", "name": "punctuation.separator.comma.haskell" }, "comment_like": { "patterns": [{ "include": "#cpp" }, { "include": "#pragma" }, { "include": "#comments" }] }, "comments": { "patterns": [{ "begin": "^(\\s*)(--\\s[\\|\\$])", "beginCaptures": { "2": { "name": "punctuation.whitespace.comment.leading.haskell" } }, "end": "(?=^(?!\\1--+(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])))", "name": "comment.block.documentation.haskell" }, { "begin": "(^[ \\t]+)?(--\\s[\\^\\*])", "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.haskell" } }, "end": "\\n", "name": "comment.line.documentation.haskell" }, { "applyEndPatternLast": 1, "begin": "\\{-\\s?[\\|\\$\\*\\^]", "captures": { "0": { "name": "punctuation.definition.comment.haskell" } }, "end": "-\\}", "name": "comment.block.documentation.haskell", "patterns": [{ "include": "#block_comment" }] }, { "begin": "(^[ \\t]+)?(?=--+(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']]))", "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.haskell" } }, "comment": "Operators may begin with '--' as long as they are not entirely composed of '-' characters. This means comments can't be immediately followed by an allowable operator character.", "end": "(?!\\G)", "patterns": [{ "begin": "--", "beginCaptures": { "0": { "name": "punctuation.definition.comment.haskell" } }, "end": "\\n", "name": "comment.line.double-dash.haskell" }] }, { "include": "#block_comment" }] }, "context": { "captures": { "1": { "patterns": [{ "include": "#comment_like" }, { "include": "#type_signature" }] }, "2": { "name": "keyword.operator.big-arrow.haskell" } }, "match": "(?x)\n(.*)\n(?<![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])\n(=>|\u21D2)\n(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])\n" }, "cpp": { "captures": { "1": { "name": "punctuation.definition.preprocessor.c" } }, "comment": `In addition to Haskell's "native" syntax, GHC permits the C preprocessor to be run on a source file.`, "match": "^(#).*$", "name": "meta.preprocessor.c" }, "data_constructor": { "match": "\\b(?<!')[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*(?![\\.'\\w])", "name": "constant.other.haskell" }, "deriving": { "patterns": [{ "begin": "^(\\s*)(deriving)\\s+(?:(via|stock|newtype|anyclass)\\s+)?", "beginCaptures": { "2": { "name": "keyword.other.deriving.haskell" }, "3": { "name": "keyword.other.deriving.strategy.$3.haskell" } }, "end": "(?x)\n\n(?=\\}|;)\n|^(?!\n\\1\\s+\\S\n| \\s*\n(?: $\n|\\{-[^@]\n|--+\n(?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_\"']]).*$)\n\n\n)", "name": "meta.deriving.haskell", "patterns": [{ "include": "#comment_like" }, { "match": "(?<!')\\b(instance)\\b(?!')", "name": "keyword.other.instance.haskell" }, { "captures": { "1": { "name": "keyword.other.deriving.strategy.$1.haskell" } }, "match": "(?<!')\\b(via|stock|newtype|anyclass)\\b(?!')" }, { "include": "#type_signature" }] }, { "begin": "(deriving)(?:\\s+(stock|newtype|anyclass))?\\s*(\\()", "beginCaptures": { "1": { "name": "keyword.other.deriving.haskell" }, "2": { "name": "keyword.other.deriving.strategy.$2.haskell" }, "3": { "name": "punctuation.paren.haskell" } }, "end": "(\\))", "endCaptures": { "1": { "name": "punctuation.paren.haskell" } }, "name": "meta.deriving.haskell", "patterns": [{ "include": "#type_signature" }] }, { "captures": { "1": { "name": "keyword.other.deriving.haskell" }, "2": { "name": "keyword.other.deriving.strategy.$2.haskell" }, "3": { "patterns": [{ "include": "#type_signature" }] }, "5": { "name": "keyword.other.deriving.strategy.via.haskell" }, "6": { "patterns": [{ "include": "#type_signature" }] } }, "match": "(?x)\n(deriving)(?:\\s+(stock|newtype|anyclass))?\\s+\n([\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*)\n(\\s+(via)\\s+(.*)$)?\n", "name": "meta.deriving.haskell" }, { "match": "(?<!')\\b(via)\\b(?!')", "name": "keyword.other.deriving.strategy.via.haskell" }] }, "double_colon": { "captures": { "1": { "name": "keyword.operator.double-colon.haskell" } }, "match": "\\s*(::|\u2237)(?![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])\\s*" }, "export_constru
\\b(?<!')(safe|unsafe|interruptible)\\b(?!')
\\s*
("(?:\\\\"|[^"])*")?
\\s*
(?:
(?:\\b(?<!'')([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*)\\b(?!'))
|(?:\\(\\s*(?!--+\\))([\\p{S}\\p{P}&&[^(),;\\[\\]\`{}_"']]+)\\s*\\))
)
` }, { "captures": { "1": { "name": "keyword.other.safety.$1.haskell" }, "2": { "name": "entity.name.foreign.haskell", "patterns": [{ "include": "#string_literal" }] } }, "match": `(?x)
\\b(?<!')(safe|unsafe|interruptible)\\b(?!')
\\s*
("(?:\\\\"|[^"])*")?
\\s*$
` }, { "captures": { "0": { "name": "entity.name.foreign.haskell", "patterns": [{ "include": "#string_literal" }] } }, "match": '(?x)\n"(?:\\\\"|[^"])*"' }, { "captures": { "1": { "name": "entity.name.function.haskell" }, "2": { "name": "punctuation.paren.haskell" }, "3": { "name": "entity.name.function.infix.haskell" }, "4": { "name": "punctuation.paren.haskell" } }, "match": "(?x)\n(?:\\b(?<!'')([\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*)\\b(?!'))\n|(?:(\\()\\s*(?!--+\\))([\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']]+)\\s*(\\)))\n" }] }, { "include": "#double_colon" }, { "include": "#type_signature" }] }, "float_literals": { "captures": { "1": { "name": "constant.numeric.floating.decimal.haskell" }, "2": { "name": "constant.numeric.floating.hexadecimal.haskell" } }, "comment": "Floats are decimal or hexadecimal", "match": "(?x)\n\\b(?<!')\n(?:\n([0-9][_0-9]*\\.[0-9][_0-9]*(?:[eE][-+]?[0-9][_0-9]*)?\n|[0-9][_0-9]*[eE][-+]?[0-9][_0-9]*\n)\n|\n(0[xX]_*[0-9a-fA-F][_0-9a-fA-F]*\\.[0-9a-fA-F][_0-9a-fA-F]*(?:[pP][-+]?[0-9][_0-9]*)?\n|0[xX]_*[0-9a-fA-F][_0-9a-fA-F]*[pP][-+]?[0-9][_0-9]*\n)\n)\\b(?!')" }, "forall": { "begin": "\\b(?<!')(forall|\u2200)\\b(?!')", "beginCaptures": { "1": { "name": "keyword.other.forall.haskell" } }, "end": "(\\.)|(->|\u2192)", "endCaptures": { "1": { "name": "keyword.operator.period.haskell" }, "2": { "name": "keyword.operator.arrow.haskell" } }, "patterns": [{ "include": "#comment_like" }, { "include": "#type_variable" }, { "include": "#type_signature" }] }, "fun_decl": { "begin": "(?x)^(\\s*)\n(?<fn>\n(?:\n[\\p{Ll}_][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*\\#*\n| \\(\\s*\n(?!--+\\))\n[\\p{S}\\p{P}&&[^(),:;\\[\\]`{}_\"']]\n[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']]*\n\\s*\\)\n)\n(?:\\s*,\\s*\\g<fn>)?\n)\n\\s*(?<![\\p{S}\\p{P}&&[^\\),;\\]`}_\"']])(::|\u2237)(?![\\p{S}\\p{P}&&[^\\(,;\\[`{_\"']])\n", "beginCaptures": { "2": { "name": "entity.name.function.haskell", "patterns": [{ "include": "#reserved_symbol" }, { "include": "#prefix_op" }] }, "3": { "name": "keyword.operator.double-colon.haskell" } }, "end": "(?x)\n\n\n(?=\n\n(?<![\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']])\n\n((<-|\u2190)|(=)|(-<|\u21A2)|(-<<|\u291B))\n\n([(),;\\[\\]`{}_\"']|[^\\p{S}\\p{P}])\n)\n\n|(?=\\}|;)\n|^(?!\n\\1\\s+\\S\n| \\s*\n(?: $\n|\\{-[^@]\n|--+\n(?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_\"']]).*$)\n\n\n)\n", "name": "meta.function.type-declaration.haskell", "patterns": [{ "include": "#type_signature" }] }, "gadt_constructor": { "patterns": [{ "begin": "(?x)\n^(\\s*)\n(?:\n(\\b(?<!')[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}']*)\n|(\\()\\s*(:[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']]*)\\s*(\\))\n)", "beginCaptures": { "2": { "name": "constant.other.haskell" }, "3": { "name": "punctuation.paren.haskell" }, "4": { "name": "constant.other.operator.haskell" }, "5": { "name": "punctuation.paren.haskell" } }, "end": "(?x)\n\n(?=\\b(?<!'')deriving\\b(?!'))\n\n|(?=\\}|;)\n|^(?!\n\\1\\s+\\S\n| \\s*\n(?: $\n|\\{-[^@]\n|--+\n(?![\\p{S}\\p{P}&&[^(),;\\[\\]{}`_\"']]).*$)\n\n\n)\n", "patterns": [{ "include": "#comment_like" }, { "include": "#deriving" }, { "include": "#double_colon" }, { "include": "#record_decl" }, { "include": "#type_signature" }] }, { "begin": "(?x)\n(\\b(?<!')[\\p{Lu}\\p{Lt}][\\p{Ll}_\\p{Lu}\\p{Lt}\\p{Nd}]*)\n|(\\()\\s*(:[\\p{S}\\p{P}&&[^(),;\\[\\]`{}_\"']]*)\\s*(\\))", "beginCaptures": { "1": { "name": "constant.other.haskell" }, "2": { "name": "punctuation.paren.haskell" }, "3": { "name": "constant.other.operator.haskell" }, "4": { "name": "punctuation.paren.haskell" } }, "end": "$", "patterns": [{ "include": "#comment_like" }, { "include": "#deriving" }, { "include": "#double_colon" }, { "include": "#record_decl" }, { "include": "#type_signature" }] }] }, "infix_op": { "patterns": [{ "captures": { "1": { "name": "keyword.operator.promotion.haskell" }, "2": { "name": "entity.name.namespace.haskell" }, "3": { "name": "keyword.operator.infix.haskell" } }, "comment": "In case this regex seems overly general, note that Haskell permits the definition of new operators which can be nearly any string of punctuation characters, such as $%^&*.\n", "matc
var haskell = [
lang
];
export { haskell as default };