eric6/ThirdParty/Pygments/pygments/lexers/mosel.py

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

eric ide

mercurial