1
0

sml.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Language: SML
  3. Author: Edwin Dalorzo <[email protected]>
  4. Description: SML language definition.
  5. Origin: ocaml.js
  6. Category: functional
  7. */
  8. function(hljs) {
  9. return {
  10. aliases: ['ml'],
  11. keywords: {
  12. keyword:
  13. /* according to Definition of Standard ML 97 */
  14. 'abstype and andalso as case datatype do else end eqtype ' +
  15. 'exception fn fun functor handle if in include infix infixr ' +
  16. 'let local nonfix of op open orelse raise rec sharing sig ' +
  17. 'signature struct structure then type val with withtype where while',
  18. built_in:
  19. /* built-in types according to basis library */
  20. 'array bool char exn int list option order real ref string substring vector unit word',
  21. literal:
  22. 'true false NONE SOME LESS EQUAL GREATER nil'
  23. },
  24. illegal: /\/\/|>>/,
  25. lexemes: '[a-z_]\\w*!?',
  26. contains: [
  27. {
  28. className: 'literal',
  29. begin: /\[(\|\|)?\]|\(\)/,
  30. relevance: 0
  31. },
  32. hljs.COMMENT(
  33. '\\(\\*',
  34. '\\*\\)',
  35. {
  36. contains: ['self']
  37. }
  38. ),
  39. { /* type variable */
  40. className: 'symbol',
  41. begin: '\'[A-Za-z_](?!\')[\\w\']*'
  42. /* the grammar is ambiguous on how 'a'b should be interpreted but not the compiler */
  43. },
  44. { /* polymorphic variant */
  45. className: 'type',
  46. begin: '`[A-Z][\\w\']*'
  47. },
  48. { /* module or constructor */
  49. className: 'type',
  50. begin: '\\b[A-Z][\\w\']*',
  51. relevance: 0
  52. },
  53. { /* don't color identifiers, but safely catch all identifiers with '*/
  54. begin: '[a-z_]\\w*\'[\\w\']*'
  55. },
  56. hljs.inherit(hljs.APOS_STRING_MODE, {className: 'string', relevance: 0}),
  57. hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
  58. {
  59. className: 'number',
  60. begin:
  61. '\\b(0[xX][a-fA-F0-9_]+[Lln]?|' +
  62. '0[oO][0-7_]+[Lln]?|' +
  63. '0[bB][01_]+[Lln]?|' +
  64. '[0-9][0-9_]*([Lln]|(\\.[0-9_]*)?([eE][-+]?[0-9_]+)?)?)',
  65. relevance: 0
  66. },
  67. {
  68. begin: /[-=]>/ // relevance booster
  69. }
  70. ]
  71. };
  72. }