]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/fortran.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / fortran.js
1 /*! `fortran` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Fortran
7 Author: Anthony Scemama <scemama@irsamc.ups-tlse.fr>
8 Website: https://en.wikipedia.org/wiki/Fortran
9 Category: scientific
10 */
11
12 /** @type LanguageFn */
13 function fortran(hljs) {
14 const regex = hljs.regex;
15 const PARAMS = {
16 className: 'params',
17 begin: '\\(',
18 end: '\\)'
19 };
20
21 const COMMENT = { variants: [
22 hljs.COMMENT('!', '$', { relevance: 0 }),
23 // allow FORTRAN 77 style comments
24 hljs.COMMENT('^C[ ]', '$', { relevance: 0 }),
25 hljs.COMMENT('^C$', '$', { relevance: 0 })
26 ] };
27
28 // regex in both fortran and irpf90 should match
29 const OPTIONAL_NUMBER_SUFFIX = /(_[a-z_\d]+)?/;
30 const OPTIONAL_NUMBER_EXP = /([de][+-]?\d+)?/;
31 const NUMBER = {
32 className: 'number',
33 variants: [
34 { begin: regex.concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) },
35 { begin: regex.concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) },
36 { begin: regex.concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX) }
37 ],
38 relevance: 0
39 };
40
41 const FUNCTION_DEF = {
42 className: 'function',
43 beginKeywords: 'subroutine function program',
44 illegal: '[${=\\n]',
45 contains: [
46 hljs.UNDERSCORE_TITLE_MODE,
47 PARAMS
48 ]
49 };
50
51 const STRING = {
52 className: 'string',
53 relevance: 0,
54 variants: [
55 hljs.APOS_STRING_MODE,
56 hljs.QUOTE_STRING_MODE
57 ]
58 };
59
60 const KEYWORDS = [
61 "kind",
62 "do",
63 "concurrent",
64 "local",
65 "shared",
66 "while",
67 "private",
68 "call",
69 "intrinsic",
70 "where",
71 "elsewhere",
72 "type",
73 "endtype",
74 "endmodule",
75 "endselect",
76 "endinterface",
77 "end",
78 "enddo",
79 "endif",
80 "if",
81 "forall",
82 "endforall",
83 "only",
84 "contains",
85 "default",
86 "return",
87 "stop",
88 "then",
89 "block",
90 "endblock",
91 "endassociate",
92 "public",
93 "subroutine|10",
94 "function",
95 "program",
96 ".and.",
97 ".or.",
98 ".not.",
99 ".le.",
100 ".eq.",
101 ".ge.",
102 ".gt.",
103 ".lt.",
104 "goto",
105 "save",
106 "else",
107 "use",
108 "module",
109 "select",
110 "case",
111 "access",
112 "blank",
113 "direct",
114 "exist",
115 "file",
116 "fmt",
117 "form",
118 "formatted",
119 "iostat",
120 "name",
121 "named",
122 "nextrec",
123 "number",
124 "opened",
125 "rec",
126 "recl",
127 "sequential",
128 "status",
129 "unformatted",
130 "unit",
131 "continue",
132 "format",
133 "pause",
134 "cycle",
135 "exit",
136 "c_null_char",
137 "c_alert",
138 "c_backspace",
139 "c_form_feed",
140 "flush",
141 "wait",
142 "decimal",
143 "round",
144 "iomsg",
145 "synchronous",
146 "nopass",
147 "non_overridable",
148 "pass",
149 "protected",
150 "volatile",
151 "abstract",
152 "extends",
153 "import",
154 "non_intrinsic",
155 "value",
156 "deferred",
157 "generic",
158 "final",
159 "enumerator",
160 "class",
161 "associate",
162 "bind",
163 "enum",
164 "c_int",
165 "c_short",
166 "c_long",
167 "c_long_long",
168 "c_signed_char",
169 "c_size_t",
170 "c_int8_t",
171 "c_int16_t",
172 "c_int32_t",
173 "c_int64_t",
174 "c_int_least8_t",
175 "c_int_least16_t",
176 "c_int_least32_t",
177 "c_int_least64_t",
178 "c_int_fast8_t",
179 "c_int_fast16_t",
180 "c_int_fast32_t",
181 "c_int_fast64_t",
182 "c_intmax_t",
183 "C_intptr_t",
184 "c_float",
185 "c_double",
186 "c_long_double",
187 "c_float_complex",
188 "c_double_complex",
189 "c_long_double_complex",
190 "c_bool",
191 "c_char",
192 "c_null_ptr",
193 "c_null_funptr",
194 "c_new_line",
195 "c_carriage_return",
196 "c_horizontal_tab",
197 "c_vertical_tab",
198 "iso_c_binding",
199 "c_loc",
200 "c_funloc",
201 "c_associated",
202 "c_f_pointer",
203 "c_ptr",
204 "c_funptr",
205 "iso_fortran_env",
206 "character_storage_size",
207 "error_unit",
208 "file_storage_size",
209 "input_unit",
210 "iostat_end",
211 "iostat_eor",
212 "numeric_storage_size",
213 "output_unit",
214 "c_f_procpointer",
215 "ieee_arithmetic",
216 "ieee_support_underflow_control",
217 "ieee_get_underflow_mode",
218 "ieee_set_underflow_mode",
219 "newunit",
220 "contiguous",
221 "recursive",
222 "pad",
223 "position",
224 "action",
225 "delim",
226 "readwrite",
227 "eor",
228 "advance",
229 "nml",
230 "interface",
231 "procedure",
232 "namelist",
233 "include",
234 "sequence",
235 "elemental",
236 "pure",
237 "impure",
238 "integer",
239 "real",
240 "character",
241 "complex",
242 "logical",
243 "codimension",
244 "dimension",
245 "allocatable|10",
246 "parameter",
247 "external",
248 "implicit|10",
249 "none",
250 "double",
251 "precision",
252 "assign",
253 "intent",
254 "optional",
255 "pointer",
256 "target",
257 "in",
258 "out",
259 "common",
260 "equivalence",
261 "data"
262 ];
263 const LITERALS = [
264 ".False.",
265 ".True."
266 ];
267 const BUILT_INS = [
268 "alog",
269 "alog10",
270 "amax0",
271 "amax1",
272 "amin0",
273 "amin1",
274 "amod",
275 "cabs",
276 "ccos",
277 "cexp",
278 "clog",
279 "csin",
280 "csqrt",
281 "dabs",
282 "dacos",
283 "dasin",
284 "datan",
285 "datan2",
286 "dcos",
287 "dcosh",
288 "ddim",
289 "dexp",
290 "dint",
291 "dlog",
292 "dlog10",
293 "dmax1",
294 "dmin1",
295 "dmod",
296 "dnint",
297 "dsign",
298 "dsin",
299 "dsinh",
300 "dsqrt",
301 "dtan",
302 "dtanh",
303 "float",
304 "iabs",
305 "idim",
306 "idint",
307 "idnint",
308 "ifix",
309 "isign",
310 "max0",
311 "max1",
312 "min0",
313 "min1",
314 "sngl",
315 "algama",
316 "cdabs",
317 "cdcos",
318 "cdexp",
319 "cdlog",
320 "cdsin",
321 "cdsqrt",
322 "cqabs",
323 "cqcos",
324 "cqexp",
325 "cqlog",
326 "cqsin",
327 "cqsqrt",
328 "dcmplx",
329 "dconjg",
330 "derf",
331 "derfc",
332 "dfloat",
333 "dgamma",
334 "dimag",
335 "dlgama",
336 "iqint",
337 "qabs",
338 "qacos",
339 "qasin",
340 "qatan",
341 "qatan2",
342 "qcmplx",
343 "qconjg",
344 "qcos",
345 "qcosh",
346 "qdim",
347 "qerf",
348 "qerfc",
349 "qexp",
350 "qgamma",
351 "qimag",
352 "qlgama",
353 "qlog",
354 "qlog10",
355 "qmax1",
356 "qmin1",
357 "qmod",
358 "qnint",
359 "qsign",
360 "qsin",
361 "qsinh",
362 "qsqrt",
363 "qtan",
364 "qtanh",
365 "abs",
366 "acos",
367 "aimag",
368 "aint",
369 "anint",
370 "asin",
371 "atan",
372 "atan2",
373 "char",
374 "cmplx",
375 "conjg",
376 "cos",
377 "cosh",
378 "exp",
379 "ichar",
380 "index",
381 "int",
382 "log",
383 "log10",
384 "max",
385 "min",
386 "nint",
387 "sign",
388 "sin",
389 "sinh",
390 "sqrt",
391 "tan",
392 "tanh",
393 "print",
394 "write",
395 "dim",
396 "lge",
397 "lgt",
398 "lle",
399 "llt",
400 "mod",
401 "nullify",
402 "allocate",
403 "deallocate",
404 "adjustl",
405 "adjustr",
406 "all",
407 "allocated",
408 "any",
409 "associated",
410 "bit_size",
411 "btest",
412 "ceiling",
413 "count",
414 "cshift",
415 "date_and_time",
416 "digits",
417 "dot_product",
418 "eoshift",
419 "epsilon",
420 "exponent",
421 "floor",
422 "fraction",
423 "huge",
424 "iand",
425 "ibclr",
426 "ibits",
427 "ibset",
428 "ieor",
429 "ior",
430 "ishft",
431 "ishftc",
432 "lbound",
433 "len_trim",
434 "matmul",
435 "maxexponent",
436 "maxloc",
437 "maxval",
438 "merge",
439 "minexponent",
440 "minloc",
441 "minval",
442 "modulo",
443 "mvbits",
444 "nearest",
445 "pack",
446 "present",
447 "product",
448 "radix",
449 "random_number",
450 "random_seed",
451 "range",
452 "repeat",
453 "reshape",
454 "rrspacing",
455 "scale",
456 "scan",
457 "selected_int_kind",
458 "selected_real_kind",
459 "set_exponent",
460 "shape",
461 "size",
462 "spacing",
463 "spread",
464 "sum",
465 "system_clock",
466 "tiny",
467 "transpose",
468 "trim",
469 "ubound",
470 "unpack",
471 "verify",
472 "achar",
473 "iachar",
474 "transfer",
475 "dble",
476 "entry",
477 "dprod",
478 "cpu_time",
479 "command_argument_count",
480 "get_command",
481 "get_command_argument",
482 "get_environment_variable",
483 "is_iostat_end",
484 "ieee_arithmetic",
485 "ieee_support_underflow_control",
486 "ieee_get_underflow_mode",
487 "ieee_set_underflow_mode",
488 "is_iostat_eor",
489 "move_alloc",
490 "new_line",
491 "selected_char_kind",
492 "same_type_as",
493 "extends_type_of",
494 "acosh",
495 "asinh",
496 "atanh",
497 "bessel_j0",
498 "bessel_j1",
499 "bessel_jn",
500 "bessel_y0",
501 "bessel_y1",
502 "bessel_yn",
503 "erf",
504 "erfc",
505 "erfc_scaled",
506 "gamma",
507 "log_gamma",
508 "hypot",
509 "norm2",
510 "atomic_define",
511 "atomic_ref",
512 "execute_command_line",
513 "leadz",
514 "trailz",
515 "storage_size",
516 "merge_bits",
517 "bge",
518 "bgt",
519 "ble",
520 "blt",
521 "dshiftl",
522 "dshiftr",
523 "findloc",
524 "iall",
525 "iany",
526 "iparity",
527 "image_index",
528 "lcobound",
529 "ucobound",
530 "maskl",
531 "maskr",
532 "num_images",
533 "parity",
534 "popcnt",
535 "poppar",
536 "shifta",
537 "shiftl",
538 "shiftr",
539 "this_image",
540 "sync",
541 "change",
542 "team",
543 "co_broadcast",
544 "co_max",
545 "co_min",
546 "co_sum",
547 "co_reduce"
548 ];
549 return {
550 name: 'Fortran',
551 case_insensitive: true,
552 aliases: [
553 'f90',
554 'f95'
555 ],
556 keywords: {
557 $pattern: /\b[a-z][a-z0-9_]+\b|\.[a-z][a-z0-9_]+\./,
558 keyword: KEYWORDS,
559 literal: LITERALS,
560 built_in: BUILT_INS
561 },
562 illegal: /\/\*/,
563 contains: [
564 STRING,
565 FUNCTION_DEF,
566 // allow `C = value` for assignments so they aren't misdetected
567 // as Fortran 77 style comments
568 {
569 begin: /^C\s*=(?!=)/,
570 relevance: 0
571 },
572 COMMENT,
573 NUMBER
574 ]
575 };
576 }
577
578 return fortran;
579
580 })();
581 ;
582 export default hljsGrammar;