UNPKG

2.03 kBJavaScriptView Raw
1Prism.languages.elm = {
2 comment: /--.*|{-[\s\S]*?-}/,
3 char: {
4 pattern: /'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+))'/,
5 greedy: true
6 },
7 string: [
8 {
9 // Multiline strings are wrapped in triple ". Quotes may appear unescaped.
10 pattern: /"""[\s\S]*?"""/,
11 greedy: true
12 },
13 {
14 pattern: /"(?:[^\\"\r\n]|\\(?:[abfnrtv\\"]|\d+|x[0-9a-fA-F]+))*"/,
15 greedy: true
16 }
17 ],
18 import_statement: {
19 // The imported or hidden names are not included in this import
20 // statement. This is because we want to highlight those exactly like
21 // we do for the names in the program.
22 pattern: /^\s*import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+([A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m,
23 inside: {
24 keyword: /\b(?:import|as|exposing)\b/
25 }
26 },
27 keyword: /\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,
28 // These are builtin variables only. Constructors are highlighted later as a constant.
29 builtin: /\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/,
30 // decimal integers and floating point numbers | hexadecimal integers
31 number: /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,
32 // Most of this is needed because of the meaning of a single '.'.
33 // If it stands alone freely, it is the function composition.
34 // It may also be a separator between a module name and an identifier => no
35 // operator. If it comes together with other special characters it is an
36 // operator too.
37 // Valid operator characters in 0.18: +-/*=.$<>:&|^?%#@~!
38 // Ref: https://groups.google.com/forum/#!msg/elm-dev/0AHSnDdkSkQ/E0SVU70JEQAJ
39 operator: /\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,
40 // In Elm, nearly everything is a variable, do not highlight these.
41 hvariable: /\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,
42 constant: /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,
43 punctuation: /[{}[\]|(),.:]/
44};