prism-fortran.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Prism.languages.fortran = {
  2. 'quoted-number': {
  3. pattern: /[BOZ](['"])[A-F0-9]+\1/i,
  4. alias: 'number'
  5. },
  6. 'string': {
  7. pattern: /(?:\b\w+_)?(['"])(?:\1\1|&(?:\r\n?|\n)(?:[ \t]*!.*(?:\r\n?|\n)|(?![ \t]*!))|(?!\1).)*(?:\1|&)/,
  8. inside: {
  9. 'comment': {
  10. pattern: /(&(?:\r\n?|\n)\s*)!.*/,
  11. lookbehind: true
  12. }
  13. }
  14. },
  15. 'comment': {
  16. pattern: /!.*/,
  17. greedy: true
  18. },
  19. 'boolean': /\.(?:FALSE|TRUE)\.(?:_\w+)?/i,
  20. 'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[ED][+-]?\d+)?(?:_\w+)?/i,
  21. 'keyword': [
  22. // Types
  23. /\b(?:CHARACTER|COMPLEX|DOUBLE ?PRECISION|INTEGER|LOGICAL|REAL)\b/i,
  24. // END statements
  25. /\b(?:END ?)?(?:BLOCK ?DATA|DO|FILE|FORALL|FUNCTION|IF|INTERFACE|MODULE(?! PROCEDURE)|PROGRAM|SELECT|SUBROUTINE|TYPE|WHERE)\b/i,
  26. // Statements
  27. /\b(?:ALLOCATABLE|ALLOCATE|BACKSPACE|CALL|CASE|CLOSE|COMMON|CONTAINS|CONTINUE|CYCLE|DATA|DEALLOCATE|DIMENSION|DO|END|EQUIVALENCE|EXIT|EXTERNAL|FORMAT|GO ?TO|IMPLICIT(?: NONE)?|INQUIRE|INTENT|INTRINSIC|MODULE PROCEDURE|NAMELIST|NULLIFY|OPEN|OPTIONAL|PARAMETER|POINTER|PRINT|PRIVATE|PUBLIC|READ|RETURN|REWIND|SAVE|SELECT|STOP|TARGET|WHILE|WRITE)\b/i,
  28. // Others
  29. /\b(?:ASSIGNMENT|DEFAULT|ELEMENTAL|ELSE|ELSEIF|ELSEWHERE|ENTRY|IN|INCLUDE|INOUT|KIND|NULL|ONLY|OPERATOR|OUT|PURE|RECURSIVE|RESULT|SEQUENCE|STAT|THEN|USE)\b/i
  30. ],
  31. 'operator': [
  32. /\*\*|\/\/|=>|[=\/]=|[<>]=?|::|[+\-*=%]|\.[A-Z]+\./i,
  33. {
  34. // Use lookbehind to prevent confusion with (/ /)
  35. pattern: /(^|(?!\().)\/(?!\))/,
  36. lookbehind: true
  37. }
  38. ],
  39. 'punctuation': /\(\/|\/\)|[(),;:&]/
  40. };