[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | module.exports = elm
|
---|
| 4 | elm.displayName = 'elm'
|
---|
| 5 | elm.aliases = []
|
---|
| 6 | function elm(Prism) {
|
---|
| 7 | Prism.languages.elm = {
|
---|
| 8 | comment: /--.*|\{-[\s\S]*?-\}/,
|
---|
| 9 | char: {
|
---|
| 10 | pattern:
|
---|
| 11 | /'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+|u\{[0-9a-fA-F]+\}))'/,
|
---|
| 12 | greedy: true
|
---|
| 13 | },
|
---|
| 14 | string: [
|
---|
| 15 | {
|
---|
| 16 | // Multiline strings are wrapped in triple ". Quotes may appear unescaped.
|
---|
| 17 | pattern: /"""[\s\S]*?"""/,
|
---|
| 18 | greedy: true
|
---|
| 19 | },
|
---|
| 20 | {
|
---|
| 21 | pattern: /"(?:[^\\"\r\n]|\\.)*"/,
|
---|
| 22 | greedy: true
|
---|
| 23 | }
|
---|
| 24 | ],
|
---|
| 25 | 'import-statement': {
|
---|
| 26 | // The imported or hidden names are not included in this import
|
---|
| 27 | // statement. This is because we want to highlight those exactly like
|
---|
| 28 | // we do for the names in the program.
|
---|
| 29 | pattern:
|
---|
| 30 | /(^[\t ]*)import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+(?:[A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m,
|
---|
| 31 | lookbehind: true,
|
---|
| 32 | inside: {
|
---|
| 33 | keyword: /\b(?:as|exposing|import)\b/
|
---|
| 34 | }
|
---|
| 35 | },
|
---|
| 36 | keyword:
|
---|
| 37 | /\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,
|
---|
| 38 | // These are builtin variables only. Constructors are highlighted later as a constant.
|
---|
| 39 | builtin:
|
---|
| 40 | /\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/,
|
---|
| 41 | // decimal integers and floating point numbers | hexadecimal integers
|
---|
| 42 | number: /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,
|
---|
| 43 | // Most of this is needed because of the meaning of a single '.'.
|
---|
| 44 | // If it stands alone freely, it is the function composition.
|
---|
| 45 | // It may also be a separator between a module name and an identifier => no
|
---|
| 46 | // operator. If it comes together with other special characters it is an
|
---|
| 47 | // operator too.
|
---|
| 48 | // Valid operator characters in 0.18: +-/*=.$<>:&|^?%#@~!
|
---|
| 49 | // Ref: https://groups.google.com/forum/#!msg/elm-dev/0AHSnDdkSkQ/E0SVU70JEQAJ
|
---|
| 50 | operator: /\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,
|
---|
| 51 | // In Elm, nearly everything is a variable, do not highlight these.
|
---|
| 52 | hvariable: /\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,
|
---|
| 53 | constant: /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,
|
---|
| 54 | punctuation: /[{}[\]|(),.:]/
|
---|
| 55 | }
|
---|
| 56 | }
|
---|