]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/gams.js
Initial commit.
[flow-web.git] / static / highlight / languages / gams.js
1 /*! `gams` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: GAMS
8 Author: Stefan Bechert <stefan.bechert@gmx.net>
9 Contributors: Oleg Efimov <efimovov@gmail.com>, Mikko Kouhia <mikko.kouhia@iki.fi>
10 Description: The General Algebraic Modeling System language
11 Website: https://www.gams.com
12 Category: scientific
13 */
14
15 /** @type LanguageFn */
16 function gams(hljs) {
17 const regex = hljs.regex;
18 const KEYWORDS = {
19 keyword:
20 'abort acronym acronyms alias all and assign binary card diag display '
21 + 'else eq file files for free ge gt if integer le loop lt maximizing '
22 + 'minimizing model models ne negative no not option options or ord '
23 + 'positive prod put putpage puttl repeat sameas semicont semiint smax '
24 + 'smin solve sos1 sos2 sum system table then until using while xor yes',
25 literal:
26 'eps inf na',
27 built_in:
28 'abs arccos arcsin arctan arctan2 Beta betaReg binomial ceil centropy '
29 + 'cos cosh cvPower div div0 eDist entropy errorf execSeed exp fact '
30 + 'floor frac gamma gammaReg log logBeta logGamma log10 log2 mapVal max '
31 + 'min mod ncpCM ncpF ncpVUpow ncpVUsin normal pi poly power '
32 + 'randBinomial randLinear randTriangle round rPower sigmoid sign '
33 + 'signPower sin sinh slexp sllog10 slrec sqexp sqlog10 sqr sqrec sqrt '
34 + 'tan tanh trunc uniform uniformInt vcPower bool_and bool_eqv bool_imp '
35 + 'bool_not bool_or bool_xor ifThen rel_eq rel_ge rel_gt rel_le rel_lt '
36 + 'rel_ne gday gdow ghour gleap gmillisec gminute gmonth gsecond gyear '
37 + 'jdate jnow jstart jtime errorLevel execError gamsRelease gamsVersion '
38 + 'handleCollect handleDelete handleStatus handleSubmit heapFree '
39 + 'heapLimit heapSize jobHandle jobKill jobStatus jobTerminate '
40 + 'licenseLevel licenseStatus maxExecError sleep timeClose timeComp '
41 + 'timeElapsed timeExec timeStart'
42 };
43 const PARAMS = {
44 className: 'params',
45 begin: /\(/,
46 end: /\)/,
47 excludeBegin: true,
48 excludeEnd: true
49 };
50 const SYMBOLS = {
51 className: 'symbol',
52 variants: [
53 { begin: /=[lgenxc]=/ },
54 { begin: /\$/ }
55 ]
56 };
57 const QSTR = { // One-line quoted comment string
58 className: 'comment',
59 variants: [
60 {
61 begin: '\'',
62 end: '\''
63 },
64 {
65 begin: '"',
66 end: '"'
67 }
68 ],
69 illegal: '\\n',
70 contains: [ hljs.BACKSLASH_ESCAPE ]
71 };
72 const ASSIGNMENT = {
73 begin: '/',
74 end: '/',
75 keywords: KEYWORDS,
76 contains: [
77 QSTR,
78 hljs.C_LINE_COMMENT_MODE,
79 hljs.C_BLOCK_COMMENT_MODE,
80 hljs.QUOTE_STRING_MODE,
81 hljs.APOS_STRING_MODE,
82 hljs.C_NUMBER_MODE
83 ]
84 };
85 const COMMENT_WORD = /[a-z0-9&#*=?@\\><:,()$[\]_.{}!+%^-]+/;
86 const DESCTEXT = { // Parameter/set/variable description text
87 begin: /[a-z][a-z0-9_]*(\([a-z0-9_, ]*\))?[ \t]+/,
88 excludeBegin: true,
89 end: '$',
90 endsWithParent: true,
91 contains: [
92 QSTR,
93 ASSIGNMENT,
94 {
95 className: 'comment',
96 // one comment word, then possibly more
97 begin: regex.concat(
98 COMMENT_WORD,
99 // [ ] because \s would be too broad (matching newlines)
100 regex.anyNumberOfTimes(regex.concat(/[ ]+/, COMMENT_WORD))
101 ),
102 relevance: 0
103 }
104 ]
105 };
106
107 return {
108 name: 'GAMS',
109 aliases: [ 'gms' ],
110 case_insensitive: true,
111 keywords: KEYWORDS,
112 contains: [
113 hljs.COMMENT(/^\$ontext/, /^\$offtext/),
114 {
115 className: 'meta',
116 begin: '^\\$[a-z0-9]+',
117 end: '$',
118 returnBegin: true,
119 contains: [
120 {
121 className: 'keyword',
122 begin: '^\\$[a-z0-9]+'
123 }
124 ]
125 },
126 hljs.COMMENT('^\\*', '$'),
127 hljs.C_LINE_COMMENT_MODE,
128 hljs.C_BLOCK_COMMENT_MODE,
129 hljs.QUOTE_STRING_MODE,
130 hljs.APOS_STRING_MODE,
131 // Declarations
132 {
133 beginKeywords:
134 'set sets parameter parameters variable variables '
135 + 'scalar scalars equation equations',
136 end: ';',
137 contains: [
138 hljs.COMMENT('^\\*', '$'),
139 hljs.C_LINE_COMMENT_MODE,
140 hljs.C_BLOCK_COMMENT_MODE,
141 hljs.QUOTE_STRING_MODE,
142 hljs.APOS_STRING_MODE,
143 ASSIGNMENT,
144 DESCTEXT
145 ]
146 },
147 { // table environment
148 beginKeywords: 'table',
149 end: ';',
150 returnBegin: true,
151 contains: [
152 { // table header row
153 beginKeywords: 'table',
154 end: '$',
155 contains: [ DESCTEXT ]
156 },
157 hljs.COMMENT('^\\*', '$'),
158 hljs.C_LINE_COMMENT_MODE,
159 hljs.C_BLOCK_COMMENT_MODE,
160 hljs.QUOTE_STRING_MODE,
161 hljs.APOS_STRING_MODE,
162 hljs.C_NUMBER_MODE
163 // Table does not contain DESCTEXT or ASSIGNMENT
164 ]
165 },
166 // Function definitions
167 {
168 className: 'function',
169 begin: /^[a-z][a-z0-9_,\-+' ()$]+\.{2}/,
170 returnBegin: true,
171 contains: [
172 { // Function title
173 className: 'title',
174 begin: /^[a-z0-9_]+/
175 },
176 PARAMS,
177 SYMBOLS
178 ]
179 },
180 hljs.C_NUMBER_MODE,
181 SYMBOLS
182 ]
183 };
184 }
185
186 return gams;
187
188 })();
189
190 hljs.registerLanguage('gams', hljsGrammar);
191 })();