source: node_modules/highlight.js/lib/languages/irpf90.js@ 65b6638

main
Last change on this file since 65b6638 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 6.4 KB
Line 
1/**
2 * @param {string} value
3 * @returns {RegExp}
4 * */
5
6/**
7 * @param {RegExp | string } re
8 * @returns {string}
9 */
10function source(re) {
11 if (!re) return null;
12 if (typeof re === "string") return re;
13
14 return re.source;
15}
16
17/**
18 * @param {...(RegExp | string) } args
19 * @returns {string}
20 */
21function concat(...args) {
22 const joined = args.map((x) => source(x)).join("");
23 return joined;
24}
25
26/*
27Language: IRPF90
28Author: Anthony Scemama <scemama@irsamc.ups-tlse.fr>
29Description: IRPF90 is an open-source Fortran code generator
30Website: http://irpf90.ups-tlse.fr
31Category: scientific
32*/
33
34/** @type LanguageFn */
35function irpf90(hljs) {
36 const PARAMS = {
37 className: 'params',
38 begin: '\\(',
39 end: '\\)'
40 };
41
42 // regex in both fortran and irpf90 should match
43 const OPTIONAL_NUMBER_SUFFIX = /(_[a-z_\d]+)?/;
44 const OPTIONAL_NUMBER_EXP = /([de][+-]?\d+)?/;
45 const NUMBER = {
46 className: 'number',
47 variants: [
48 {
49 begin: concat(/\b\d+/, /\.(\d*)/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX)
50 },
51 {
52 begin: concat(/\b\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX)
53 },
54 {
55 begin: concat(/\.\d+/, OPTIONAL_NUMBER_EXP, OPTIONAL_NUMBER_SUFFIX)
56 }
57 ],
58 relevance: 0
59 };
60
61 const F_KEYWORDS = {
62 literal: '.False. .True.',
63 keyword: 'kind do while private call intrinsic where elsewhere ' +
64 'type endtype endmodule endselect endinterface end enddo endif if forall endforall only contains default return stop then ' +
65 'public subroutine|10 function program .and. .or. .not. .le. .eq. .ge. .gt. .lt. ' +
66 'goto save else use module select case ' +
67 'access blank direct exist file fmt form formatted iostat name named nextrec number opened rec recl sequential status unformatted unit ' +
68 'continue format pause cycle exit ' +
69 'c_null_char c_alert c_backspace c_form_feed flush wait decimal round iomsg ' +
70 'synchronous nopass non_overridable pass protected volatile abstract extends import ' +
71 'non_intrinsic value deferred generic final enumerator class associate bind enum ' +
72 'c_int c_short c_long c_long_long c_signed_char c_size_t c_int8_t c_int16_t c_int32_t c_int64_t c_int_least8_t c_int_least16_t ' +
73 'c_int_least32_t c_int_least64_t c_int_fast8_t c_int_fast16_t c_int_fast32_t c_int_fast64_t c_intmax_t C_intptr_t c_float c_double ' +
74 'c_long_double c_float_complex c_double_complex c_long_double_complex c_bool c_char c_null_ptr c_null_funptr ' +
75 'c_new_line c_carriage_return c_horizontal_tab c_vertical_tab iso_c_binding c_loc c_funloc c_associated c_f_pointer ' +
76 'c_ptr c_funptr iso_fortran_env character_storage_size error_unit file_storage_size input_unit iostat_end iostat_eor ' +
77 'numeric_storage_size output_unit c_f_procpointer ieee_arithmetic ieee_support_underflow_control ' +
78 'ieee_get_underflow_mode ieee_set_underflow_mode newunit contiguous recursive ' +
79 'pad position action delim readwrite eor advance nml interface procedure namelist include sequence elemental pure ' +
80 'integer real character complex logical dimension allocatable|10 parameter ' +
81 'external implicit|10 none double precision assign intent optional pointer ' +
82 'target in out common equivalence data ' +
83 // IRPF90 special keywords
84 'begin_provider &begin_provider end_provider begin_shell end_shell begin_template end_template subst assert touch ' +
85 'soft_touch provide no_dep free irp_if irp_else irp_endif irp_write irp_read',
86 built_in: 'alog alog10 amax0 amax1 amin0 amin1 amod cabs ccos cexp clog csin csqrt dabs dacos dasin datan datan2 dcos dcosh ddim dexp dint ' +
87 'dlog dlog10 dmax1 dmin1 dmod dnint dsign dsin dsinh dsqrt dtan dtanh float iabs idim idint idnint ifix isign max0 max1 min0 min1 sngl ' +
88 'algama cdabs cdcos cdexp cdlog cdsin cdsqrt cqabs cqcos cqexp cqlog cqsin cqsqrt dcmplx dconjg derf derfc dfloat dgamma dimag dlgama ' +
89 'iqint qabs qacos qasin qatan qatan2 qcmplx qconjg qcos qcosh qdim qerf qerfc qexp qgamma qimag qlgama qlog qlog10 qmax1 qmin1 qmod ' +
90 'qnint qsign qsin qsinh qsqrt qtan qtanh abs acos aimag aint anint asin atan atan2 char cmplx conjg cos cosh exp ichar index int log ' +
91 'log10 max min nint sign sin sinh sqrt tan tanh print write dim lge lgt lle llt mod nullify allocate deallocate ' +
92 'adjustl adjustr all allocated any associated bit_size btest ceiling count cshift date_and_time digits dot_product ' +
93 'eoshift epsilon exponent floor fraction huge iand ibclr ibits ibset ieor ior ishft ishftc lbound len_trim matmul ' +
94 'maxexponent maxloc maxval merge minexponent minloc minval modulo mvbits nearest pack present product ' +
95 'radix random_number random_seed range repeat reshape rrspacing scale scan selected_int_kind selected_real_kind ' +
96 'set_exponent shape size spacing spread sum system_clock tiny transpose trim ubound unpack verify achar iachar transfer ' +
97 'dble entry dprod cpu_time command_argument_count get_command get_command_argument get_environment_variable is_iostat_end ' +
98 'ieee_arithmetic ieee_support_underflow_control ieee_get_underflow_mode ieee_set_underflow_mode ' +
99 'is_iostat_eor move_alloc new_line selected_char_kind same_type_as extends_type_of ' +
100 'acosh asinh atanh bessel_j0 bessel_j1 bessel_jn bessel_y0 bessel_y1 bessel_yn erf erfc erfc_scaled gamma log_gamma hypot norm2 ' +
101 'atomic_define atomic_ref execute_command_line leadz trailz storage_size merge_bits ' +
102 'bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr ' +
103 'num_images parity popcnt poppar shifta shiftl shiftr this_image ' +
104 // IRPF90 special built_ins
105 'IRP_ALIGN irp_here'
106 };
107 return {
108 name: 'IRPF90',
109 case_insensitive: true,
110 keywords: F_KEYWORDS,
111 illegal: /\/\*/,
112 contains: [
113 hljs.inherit(hljs.APOS_STRING_MODE, {
114 className: 'string',
115 relevance: 0
116 }),
117 hljs.inherit(hljs.QUOTE_STRING_MODE, {
118 className: 'string',
119 relevance: 0
120 }),
121 {
122 className: 'function',
123 beginKeywords: 'subroutine function program',
124 illegal: '[${=\\n]',
125 contains: [
126 hljs.UNDERSCORE_TITLE_MODE,
127 PARAMS
128 ]
129 },
130 hljs.COMMENT('!', '$', {
131 relevance: 0
132 }),
133 hljs.COMMENT('begin_doc', 'end_doc', {
134 relevance: 10
135 }),
136 NUMBER
137 ]
138 };
139}
140
141module.exports = irpf90;
Note: See TracBrowser for help on using the repository browser.