mercury.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. module.exports = function(hljs) {
  2. var KEYWORDS = {
  3. keyword:
  4. 'module use_module import_module include_module end_module initialise ' +
  5. 'mutable initialize finalize finalise interface implementation pred ' +
  6. 'mode func type inst solver any_pred any_func is semidet det nondet ' +
  7. 'multi erroneous failure cc_nondet cc_multi typeclass instance where ' +
  8. 'pragma promise external trace atomic or_else require_complete_switch ' +
  9. 'require_det require_semidet require_multi require_nondet ' +
  10. 'require_cc_multi require_cc_nondet require_erroneous require_failure',
  11. meta:
  12. // pragma
  13. 'inline no_inline type_spec source_file fact_table obsolete memo ' +
  14. 'loop_check minimal_model terminates does_not_terminate ' +
  15. 'check_termination promise_equivalent_clauses ' +
  16. // preprocessor
  17. 'foreign_proc foreign_decl foreign_code foreign_type ' +
  18. 'foreign_import_module foreign_export_enum foreign_export ' +
  19. 'foreign_enum may_call_mercury will_not_call_mercury thread_safe ' +
  20. 'not_thread_safe maybe_thread_safe promise_pure promise_semipure ' +
  21. 'tabled_for_io local untrailed trailed attach_to_io_state ' +
  22. 'can_pass_as_mercury_type stable will_not_throw_exception ' +
  23. 'may_modify_trail will_not_modify_trail may_duplicate ' +
  24. 'may_not_duplicate affects_liveness does_not_affect_liveness ' +
  25. 'doesnt_affect_liveness no_sharing unknown_sharing sharing',
  26. built_in:
  27. 'some all not if then else true fail false try catch catch_any ' +
  28. 'semidet_true semidet_false semidet_fail impure_true impure semipure'
  29. };
  30. var COMMENT = hljs.COMMENT('%', '$');
  31. var NUMCODE = {
  32. className: 'number',
  33. begin: "0'.\\|0[box][0-9a-fA-F]*"
  34. };
  35. var ATOM = hljs.inherit(hljs.APOS_STRING_MODE, {relevance: 0});
  36. var STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {relevance: 0});
  37. var STRING_FMT = {
  38. className: 'subst',
  39. begin: '\\\\[abfnrtv]\\|\\\\x[0-9a-fA-F]*\\\\\\|%[-+# *.0-9]*[dioxXucsfeEgGp]',
  40. relevance: 0
  41. };
  42. STRING.contains = STRING.contains.slice() // we need our own copy of contains
  43. STRING.contains.push(STRING_FMT);
  44. var IMPLICATION = {
  45. className: 'built_in',
  46. variants: [
  47. {begin: '<=>'},
  48. {begin: '<=', relevance: 0},
  49. {begin: '=>', relevance: 0},
  50. {begin: '/\\\\'},
  51. {begin: '\\\\/'}
  52. ]
  53. };
  54. var HEAD_BODY_CONJUNCTION = {
  55. className: 'built_in',
  56. variants: [
  57. {begin: ':-\\|-->'},
  58. {begin: '=', relevance: 0}
  59. ]
  60. };
  61. return {
  62. aliases: ['m', 'moo'],
  63. keywords: KEYWORDS,
  64. contains: [
  65. IMPLICATION,
  66. HEAD_BODY_CONJUNCTION,
  67. COMMENT,
  68. hljs.C_BLOCK_COMMENT_MODE,
  69. NUMCODE,
  70. hljs.NUMBER_MODE,
  71. ATOM,
  72. STRING,
  73. {begin: /:-/}, // relevance booster
  74. {begin: /\.$/} // relevance booster
  75. ]
  76. };
  77. };