l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

mercury.js (3203B)


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