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 | const 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 | const COMMENT = hljs.COMMENT('%', '$');
|
---|
39 |
|
---|
40 | const NUMCODE = {
|
---|
41 | className: 'number',
|
---|
42 | begin: "0'.\\|0[box][0-9a-fA-F]*"
|
---|
43 | };
|
---|
44 |
|
---|
45 | const ATOM = hljs.inherit(hljs.APOS_STRING_MODE, {
|
---|
46 | relevance: 0
|
---|
47 | });
|
---|
48 | const STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {
|
---|
49 | relevance: 0
|
---|
50 | });
|
---|
51 | const STRING_FMT = {
|
---|
52 | className: 'subst',
|
---|
53 | begin: '\\\\[abfnrtv]\\|\\\\x[0-9a-fA-F]*\\\\\\|%[-+# *.0-9]*[dioxXucsfeEgGp]',
|
---|
54 | relevance: 0
|
---|
55 | };
|
---|
56 | STRING.contains = STRING.contains.slice(); // we need our own copy of contains
|
---|
57 | STRING.contains.push(STRING_FMT);
|
---|
58 |
|
---|
59 | const IMPLICATION = {
|
---|
60 | className: 'built_in',
|
---|
61 | variants: [
|
---|
62 | {
|
---|
63 | begin: '<=>'
|
---|
64 | },
|
---|
65 | {
|
---|
66 | begin: '<=',
|
---|
67 | relevance: 0
|
---|
68 | },
|
---|
69 | {
|
---|
70 | begin: '=>',
|
---|
71 | relevance: 0
|
---|
72 | },
|
---|
73 | {
|
---|
74 | begin: '/\\\\'
|
---|
75 | },
|
---|
76 | {
|
---|
77 | begin: '\\\\/'
|
---|
78 | }
|
---|
79 | ]
|
---|
80 | };
|
---|
81 |
|
---|
82 | const HEAD_BODY_CONJUNCTION = {
|
---|
83 | className: 'built_in',
|
---|
84 | variants: [
|
---|
85 | {
|
---|
86 | begin: ':-\\|-->'
|
---|
87 | },
|
---|
88 | {
|
---|
89 | begin: '=',
|
---|
90 | relevance: 0
|
---|
91 | }
|
---|
92 | ]
|
---|
93 | };
|
---|
94 |
|
---|
95 | return {
|
---|
96 | name: 'Mercury',
|
---|
97 | aliases: [
|
---|
98 | 'm',
|
---|
99 | 'moo'
|
---|
100 | ],
|
---|
101 | keywords: KEYWORDS,
|
---|
102 | contains: [
|
---|
103 | IMPLICATION,
|
---|
104 | HEAD_BODY_CONJUNCTION,
|
---|
105 | COMMENT,
|
---|
106 | hljs.C_BLOCK_COMMENT_MODE,
|
---|
107 | NUMCODE,
|
---|
108 | hljs.NUMBER_MODE,
|
---|
109 | ATOM,
|
---|
110 | STRING,
|
---|
111 | { // relevance booster
|
---|
112 | begin: /:-/
|
---|
113 | },
|
---|
114 | { // relevance booster
|
---|
115 | begin: /\.$/
|
---|
116 | }
|
---|
117 | ]
|
---|
118 | };
|
---|
119 | }
|
---|
120 |
|
---|
121 | module.exports = mercury;
|
---|