prism-fortran.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. Prism.languages.fortran = {
  2. 'quoted-number': {
  3. pattern: /[BOZ](['"])[A-F0-9]+\1/i,
  4. alias: 'number'
  5. },
  6. 'string': {
  7. pattern: /(?:\w+_)?(['"])(?:\1\1|&\n(?:\s*!.+\n)?|(?!\1).)*(?:\1|&)/,
  8. inside: {
  9. 'comment': /!.*/
  10. }
  11. },
  12. 'comment': /!.*/,
  13. 'boolean': /\.(?:TRUE|FALSE)\.(?:_\w+)?/i,
  14. 'number': /(?:\b|[+-])(?:\d+(?:\.\d*)?|\.\d+)(?:[ED][+-]?\d+)?(?:_\w+)?/i,
  15. 'keyword': [
  16. // Types
  17. /\b(?:INTEGER|REAL|DOUBLE ?PRECISION|COMPLEX|CHARACTER|LOGICAL)\b/i,
  18. // Statements
  19. /\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,
  20. // END statements
  21. /\b(?:END ?)?(?:BLOCK ?DATA|DO|FILE|FORALL|FUNCTION|IF|INTERFACE|MODULE|PROGRAM|SELECT|SUBROUTINE|TYPE|WHERE)\b/i,
  22. // Others
  23. /\b(?:ASSIGNMENT|DEFAULT|ELEMENTAL|ELSE|ELSEWHERE|ELSEIF|ENTRY|IN|INCLUDE|INOUT|KIND|NULL|ONLY|OPERATOR|OUT|PURE|RECURSIVE|RESULT|SEQUENCE|STAT|THEN|USE)\b/i
  24. ],
  25. 'operator': [
  26. /\*\*|\/\/|=>|[=\/]=|[<>]=?|::|[+\-*=%]|\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV)\.|\.[A-Z]+\./i,
  27. {
  28. // Use lookbehind to prevent confusion with (/ /)
  29. pattern: /(^|(?!\().)\/(?!\))/,
  30. lookbehind: true
  31. }
  32. ],
  33. 'punctuation': /\(\/|\/\)|[(),;:&]/
  34. };