fortran.js 5.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. module.exports = function(hljs) {
  2. var PARAMS = {
  3. className: 'params',
  4. begin: '\\(', end: '\\)'
  5. };
  6. var F_KEYWORDS = {
  7. literal: '.False. .True.',
  8. keyword: 'kind do while private call intrinsic where elsewhere ' +
  9. 'type endtype endmodule endselect endinterface end enddo endif if forall endforall only contains default return stop then block endblock ' +
  10. 'public subroutine|10 function program .and. .or. .not. .le. .eq. .ge. .gt. .lt. ' +
  11. 'goto save else use module select case ' +
  12. 'access blank direct exist file fmt form formatted iostat name named nextrec number opened rec recl sequential status unformatted unit ' +
  13. 'continue format pause cycle exit ' +
  14. 'c_null_char c_alert c_backspace c_form_feed flush wait decimal round iomsg ' +
  15. 'synchronous nopass non_overridable pass protected volatile abstract extends import ' +
  16. 'non_intrinsic value deferred generic final enumerator class associate bind enum ' +
  17. '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 ' +
  18. '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 ' +
  19. 'c_long_double c_float_complex c_double_complex c_long_double_complex c_bool c_char c_null_ptr c_null_funptr ' +
  20. 'c_new_line c_carriage_return c_horizontal_tab c_vertical_tab iso_c_binding c_loc c_funloc c_associated c_f_pointer ' +
  21. 'c_ptr c_funptr iso_fortran_env character_storage_size error_unit file_storage_size input_unit iostat_end iostat_eor ' +
  22. 'numeric_storage_size output_unit c_f_procpointer ieee_arithmetic ieee_support_underflow_control ' +
  23. 'ieee_get_underflow_mode ieee_set_underflow_mode newunit contiguous recursive ' +
  24. 'pad position action delim readwrite eor advance nml interface procedure namelist include sequence elemental pure ' +
  25. 'integer real character complex logical dimension allocatable|10 parameter ' +
  26. 'external implicit|10 none double precision assign intent optional pointer ' +
  27. 'target in out common equivalence data',
  28. 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 ' +
  29. 'dlog dlog10 dmax1 dmin1 dmod dnint dsign dsin dsinh dsqrt dtan dtanh float iabs idim idint idnint ifix isign max0 max1 min0 min1 sngl ' +
  30. 'algama cdabs cdcos cdexp cdlog cdsin cdsqrt cqabs cqcos cqexp cqlog cqsin cqsqrt dcmplx dconjg derf derfc dfloat dgamma dimag dlgama ' +
  31. 'iqint qabs qacos qasin qatan qatan2 qcmplx qconjg qcos qcosh qdim qerf qerfc qexp qgamma qimag qlgama qlog qlog10 qmax1 qmin1 qmod ' +
  32. '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 ' +
  33. 'log10 max min nint sign sin sinh sqrt tan tanh print write dim lge lgt lle llt mod nullify allocate deallocate ' +
  34. 'adjustl adjustr all allocated any associated bit_size btest ceiling count cshift date_and_time digits dot_product ' +
  35. 'eoshift epsilon exponent floor fraction huge iand ibclr ibits ibset ieor ior ishft ishftc lbound len_trim matmul ' +
  36. 'maxexponent maxloc maxval merge minexponent minloc minval modulo mvbits nearest pack present product ' +
  37. 'radix random_number random_seed range repeat reshape rrspacing scale scan selected_int_kind selected_real_kind ' +
  38. 'set_exponent shape size spacing spread sum system_clock tiny transpose trim ubound unpack verify achar iachar transfer ' +
  39. 'dble entry dprod cpu_time command_argument_count get_command get_command_argument get_environment_variable is_iostat_end ' +
  40. 'ieee_arithmetic ieee_support_underflow_control ieee_get_underflow_mode ieee_set_underflow_mode ' +
  41. 'is_iostat_eor move_alloc new_line selected_char_kind same_type_as extends_type_of' +
  42. 'acosh asinh atanh bessel_j0 bessel_j1 bessel_jn bessel_y0 bessel_y1 bessel_yn erf erfc erfc_scaled gamma log_gamma hypot norm2 ' +
  43. 'atomic_define atomic_ref execute_command_line leadz trailz storage_size merge_bits ' +
  44. 'bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr ' +
  45. 'num_images parity popcnt poppar shifta shiftl shiftr this_image'
  46. };
  47. return {
  48. case_insensitive: true,
  49. aliases: ['f90', 'f95'],
  50. keywords: F_KEYWORDS,
  51. illegal: /\/\*/,
  52. contains: [
  53. hljs.inherit(hljs.APOS_STRING_MODE, {className: 'string', relevance: 0}),
  54. hljs.inherit(hljs.QUOTE_STRING_MODE, {className: 'string', relevance: 0}),
  55. {
  56. className: 'function',
  57. beginKeywords: 'subroutine function program',
  58. illegal: '[${=\\n]',
  59. contains: [hljs.UNDERSCORE_TITLE_MODE, PARAMS]
  60. },
  61. hljs.COMMENT('!', '$', {relevance: 0}),
  62. {
  63. className: 'number',
  64. begin: '(?=\\b|\\+|\\-|\\.)(?=\\.\\d|\\d)(?:\\d+)?(?:\\.?\\d*)(?:[de][+-]?\\d+)?\\b\\.?',
  65. relevance: 0
  66. }
  67. ]
  68. };
  69. };