Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/mosel.py: 100%
9 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:07 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:07 +0000
1"""
2 pygments.lexers.mosel
3 ~~~~~~~~~~~~~~~~~~~~~
5 Lexers for the mosel language.
6 http://www.fico.com/en/products/fico-xpress-optimization
8 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details.
10"""
12from pygments.lexer import RegexLexer, words
13from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
14 Number, Punctuation
16__all__ = ['MoselLexer']
18FUNCTIONS = (
19 # core functions
20 '_',
21 'abs',
22 'arctan',
23 'asproc',
24 'assert',
25 'bitflip',
26 'bitneg',
27 'bitset',
28 'bitshift',
29 'bittest',
30 'bitval',
31 'ceil',
32 'cos',
33 'create',
34 'currentdate',
35 'currenttime',
36 'cutelt',
37 'cutfirst',
38 'cuthead',
39 'cutlast',
40 'cuttail',
41 'datablock',
42 'delcell',
43 'exists',
44 'exit',
45 'exp',
46 'exportprob',
47 'fclose',
48 'fflush',
49 'finalize',
50 'findfirst',
51 'findlast',
52 'floor',
53 'fopen',
54 'fselect',
55 'fskipline',
56 'fwrite',
57 'fwrite_',
58 'fwriteln',
59 'fwriteln_',
60 'getact',
61 'getcoeff',
62 'getcoeffs',
63 'getdual',
64 'getelt',
65 'getfid',
66 'getfirst',
67 'getfname',
68 'gethead',
69 'getlast',
70 'getobjval',
71 'getparam',
72 'getrcost',
73 'getreadcnt',
74 'getreverse',
75 'getsize',
76 'getslack',
77 'getsol',
78 'gettail',
79 'gettype',
80 'getvars',
81 'isdynamic',
82 'iseof',
83 'isfinite',
84 'ishidden',
85 'isinf',
86 'isnan',
87 'isodd',
88 'ln',
89 'localsetparam',
90 'log',
91 'makesos1',
92 'makesos2',
93 'maxlist',
94 'memoryuse',
95 'minlist',
96 'newmuid',
97 'publish',
98 'random',
99 'read',
100 'readln',
101 'reset',
102 'restoreparam',
103 'reverse',
104 'round',
105 'setcoeff',
106 'sethidden',
107 'setioerr',
108 'setmatherr',
109 'setname',
110 'setparam',
111 'setrandseed',
112 'setrange',
113 'settype',
114 'sin',
115 'splithead',
116 'splittail',
117 'sqrt',
118 'strfmt',
119 'substr',
120 'timestamp',
121 'unpublish',
122 'versionnum',
123 'versionstr',
124 'write',
125 'write_',
126 'writeln',
127 'writeln_',
129 # mosel exam mmxprs | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u
130 'addcut',
131 'addcuts',
132 'addmipsol',
133 'basisstability',
134 'calcsolinfo',
135 'clearmipdir',
136 'clearmodcut',
137 'command',
138 'copysoltoinit',
139 'crossoverlpsol',
140 'defdelayedrows',
141 'defsecurevecs',
142 'delcuts',
143 'dropcuts',
144 'estimatemarginals',
145 'fixglobal',
146 'flushmsgq',
147 'getbstat',
148 'getcnlist',
149 'getcplist',
150 'getdualray',
151 'getiis',
152 'getiissense',
153 'getiistype',
154 'getinfcause',
155 'getinfeas',
156 'getlb',
157 'getlct',
158 'getleft',
159 'getloadedlinctrs',
160 'getloadedmpvars',
161 'getname',
162 'getprimalray',
163 'getprobstat',
164 'getrange',
165 'getright',
166 'getsensrng',
167 'getsize',
168 'getsol',
169 'gettype',
170 'getub',
171 'getvars',
172 'gety',
173 'hasfeature',
174 'implies',
175 'indicator',
176 'initglobal',
177 'ishidden',
178 'isiisvalid',
179 'isintegral',
180 'loadbasis',
181 'loadcuts',
182 'loadlpsol',
183 'loadmipsol',
184 'loadprob',
185 'maximise',
186 'maximize',
187 'minimise',
188 'minimize',
189 'postsolve',
190 'readbasis',
191 'readdirs',
192 'readsol',
193 'refinemipsol',
194 'rejectintsol',
195 'repairinfeas',
196 'repairinfeas_deprec',
197 'resetbasis',
198 'resetiis',
199 'resetsol',
200 'savebasis',
201 'savemipsol',
202 'savesol',
203 'savestate',
204 'selectsol',
205 'setarchconsistency',
206 'setbstat',
207 'setcallback',
208 'setcbcutoff',
209 'setgndata',
210 'sethidden',
211 'setlb',
212 'setmipdir',
213 'setmodcut',
214 'setsol',
215 'setub',
216 'setucbdata',
217 'stopoptimise',
218 'stopoptimize',
219 'storecut',
220 'storecuts',
221 'unloadprob',
222 'uselastbarsol',
223 'writebasis',
224 'writedirs',
225 'writeprob',
226 'writesol',
227 'xor',
228 'xprs_addctr',
229 'xprs_addindic',
231 # mosel exam mmsystem | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u
232 'addmonths',
233 'copytext',
234 'cuttext',
235 'deltext',
236 'endswith',
237 'erase',
238 'expandpath',
239 'fcopy',
240 'fdelete',
241 'findfiles',
242 'findtext',
243 'fmove',
244 'formattext',
245 'getasnumber',
246 'getchar',
247 'getcwd',
248 'getdate',
249 'getday',
250 'getdaynum',
251 'getdays',
252 'getdirsep',
253 'getdsoparam',
254 'getendparse',
255 'getenv',
256 'getfsize',
257 'getfstat',
258 'getftime',
259 'gethour',
260 'getminute',
261 'getmonth',
262 'getmsec',
263 'getoserrmsg',
264 'getoserror',
265 'getpathsep',
266 'getqtype',
267 'getsecond',
268 'getsepchar',
269 'getsize',
270 'getstart',
271 'getsucc',
272 'getsysinfo',
273 'getsysstat',
274 'gettime',
275 'gettmpdir',
276 'gettrim',
277 'getweekday',
278 'getyear',
279 'inserttext',
280 'isvalid',
281 'jointext',
282 'makedir',
283 'makepath',
284 'newtar',
285 'newzip',
286 'nextfield',
287 'openpipe',
288 'parseextn',
289 'parseint',
290 'parsereal',
291 'parsetext',
292 'pastetext',
293 'pathmatch',
294 'pathsplit',
295 'qsort',
296 'quote',
297 'readtextline',
298 'regmatch',
299 'regreplace',
300 'removedir',
301 'removefiles',
302 'setchar',
303 'setdate',
304 'setday',
305 'setdsoparam',
306 'setendparse',
307 'setenv',
308 'sethour',
309 'setminute',
310 'setmonth',
311 'setmsec',
312 'setoserror',
313 'setqtype',
314 'setsecond',
315 'setsepchar',
316 'setstart',
317 'setsucc',
318 'settime',
319 'settrim',
320 'setyear',
321 'sleep',
322 'splittext',
323 'startswith',
324 'system',
325 'tarlist',
326 'textfmt',
327 'tolower',
328 'toupper',
329 'trim',
330 'untar',
331 'unzip',
332 'ziplist',
334 # mosel exam mmjobs | sed -n -e "s/ [pf][a-z]* \([a-zA-Z0-9_]*\).*/'\1',/p" | sort -u
335 'canceltimer',
336 'clearaliases',
337 'compile',
338 'connect',
339 'detach',
340 'disconnect',
341 'dropnextevent',
342 'findxsrvs',
343 'getaliases',
344 'getannidents',
345 'getannotations',
346 'getbanner',
347 'getclass',
348 'getdsoprop',
349 'getdsopropnum',
350 'getexitcode',
351 'getfromgid',
352 'getfromid',
353 'getfromuid',
354 'getgid',
355 'gethostalias',
356 'getid',
357 'getmodprop',
358 'getmodpropnum',
359 'getnextevent',
360 'getnode',
361 'getrmtid',
362 'getstatus',
363 'getsysinfo',
364 'gettimer',
365 'getuid',
366 'getvalue',
367 'isqueueempty',
368 'load',
369 'nullevent',
370 'peeknextevent',
371 'resetmodpar',
372 'run',
373 'send',
374 'setcontrol',
375 'setdefstream',
376 'setgid',
377 'sethostalias',
378 'setmodpar',
379 'settimer',
380 'setuid',
381 'setworkdir',
382 'stop',
383 'unload',
384 'wait',
385 'waitexpired',
386 'waitfor',
387 'waitforend',
388)
391class MoselLexer(RegexLexer):
392 """
393 For the Mosel optimization language.
395 .. versionadded:: 2.6
396 """
397 name = 'Mosel'
398 aliases = ['mosel']
399 filenames = ['*.mos']
401 tokens = {
402 'root': [
403 (r'\n', Text),
404 (r'\s+', Text.Whitespace),
405 (r'!.*?\n', Comment.Single),
406 (r'\(!(.|\n)*?!\)', Comment.Multiline),
407 (words((
408 'and', 'as', 'break', 'case', 'count', 'declarations', 'do',
409 'dynamic', 'elif', 'else', 'end-', 'end', 'evaluation', 'false',
410 'forall', 'forward', 'from', 'function', 'hashmap', 'if',
411 'imports', 'include', 'initialisations', 'initializations', 'inter',
412 'max', 'min', 'model', 'namespace', 'next', 'not', 'nsgroup',
413 'nssearch', 'of', 'options', 'or', 'package', 'parameters',
414 'procedure', 'public', 'prod', 'record', 'repeat', 'requirements',
415 'return', 'sum', 'then', 'to', 'true', 'union', 'until', 'uses',
416 'version', 'while', 'with'), prefix=r'\b', suffix=r'\b'),
417 Keyword.Builtin),
418 (words((
419 'range', 'array', 'set', 'list', 'mpvar', 'mpproblem', 'linctr',
420 'nlctr', 'integer', 'string', 'real', 'boolean', 'text', 'time',
421 'date', 'datetime', 'returned', 'Model', 'Mosel', 'counter',
422 'xmldoc', 'is_sos1', 'is_sos2', 'is_integer', 'is_binary',
423 'is_continuous', 'is_free', 'is_semcont', 'is_semint',
424 'is_partint'), prefix=r'\b', suffix=r'\b'),
425 Keyword.Type),
426 (r'(\+|\-|\*|/|=|<=|>=|\||\^|<|>|<>|\.\.|\.|:=|::|:|in|mod|div)',
427 Operator),
428 (r'[()\[\]{},;]+', Punctuation),
429 (words(FUNCTIONS, prefix=r'\b', suffix=r'\b'), Name.Function),
430 (r'(\d+\.(?!\.)\d*|\.(?!.)\d+)([eE][+-]?\d+)?', Number.Float),
431 (r'\d+([eE][+-]?\d+)?', Number.Integer),
432 (r'[+-]?Infinity', Number.Integer),
433 (r'0[xX][0-9a-fA-F]+', Number),
434 (r'"', String.Double, 'double_quote'),
435 (r'\'', String.Single, 'single_quote'),
436 (r'(\w+|(\.(?!\.)))', Text),
437 ],
438 'single_quote': [
439 (r'\'', String.Single, '#pop'),
440 (r'[^\']+', String.Single),
441 ],
442 'double_quote': [
443 (r'(\\"|\\[0-7]{1,3}\D|\\[abfnrtv]|\\\\)', String.Escape),
444 (r'\"', String.Double, '#pop'),
445 (r'[^"\\]+', String.Double),
446 ],
447 }