elm.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. Language: Elm
  3. Author: Janis Voigtlaender <[email protected]>
  4. Category: functional
  5. */
  6. function(hljs) {
  7. var COMMENT = {
  8. variants: [
  9. hljs.COMMENT('--', '$'),
  10. hljs.COMMENT(
  11. '{-',
  12. '-}',
  13. {
  14. contains: ['self']
  15. }
  16. )
  17. ]
  18. };
  19. var CONSTRUCTOR = {
  20. className: 'type',
  21. begin: '\\b[A-Z][\\w\']*', // TODO: other constructors (built-in, infix).
  22. relevance: 0
  23. };
  24. var LIST = {
  25. begin: '\\(', end: '\\)',
  26. illegal: '"',
  27. contains: [
  28. {className: 'type', begin: '\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?'},
  29. COMMENT
  30. ]
  31. };
  32. var RECORD = {
  33. begin: '{', end: '}',
  34. contains: LIST.contains
  35. };
  36. return {
  37. keywords:
  38. 'let in if then else case of where module import exposing ' +
  39. 'type alias as infix infixl infixr port effect command subscription',
  40. contains: [
  41. // Top-level constructions.
  42. {
  43. beginKeywords: 'port effect module', end: 'exposing',
  44. keywords: 'port effect module where command subscription exposing',
  45. contains: [LIST, COMMENT],
  46. illegal: '\\W\\.|;'
  47. },
  48. {
  49. begin: 'import', end: '$',
  50. keywords: 'import as exposing',
  51. contains: [LIST, COMMENT],
  52. illegal: '\\W\\.|;'
  53. },
  54. {
  55. begin: 'type', end: '$',
  56. keywords: 'type alias',
  57. contains: [CONSTRUCTOR, LIST, RECORD, COMMENT]
  58. },
  59. {
  60. beginKeywords: 'infix infixl infixr', end: '$',
  61. contains: [hljs.C_NUMBER_MODE, COMMENT]
  62. },
  63. {
  64. begin: 'port', end: '$',
  65. keywords: 'port',
  66. contains: [COMMENT]
  67. },
  68. // Literals and names.
  69. // TODO: characters.
  70. hljs.QUOTE_STRING_MODE,
  71. hljs.C_NUMBER_MODE,
  72. CONSTRUCTOR,
  73. hljs.inherit(hljs.TITLE_MODE, {begin: '^[_a-z][\\w\']*'}),
  74. COMMENT,
  75. {begin: '->|<-'} // No markup, relevance booster
  76. ]
  77. };
  78. }