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