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