modula3.vim 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. " Vim syntax file
  2. " Language: Modula-3
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Previous Maintainer: Timo Pedersen <dat97tpe@ludat.lth.se>
  5. " Last Change: 2022 Oct 31
  6. if exists("b:current_syntax")
  7. finish
  8. endif
  9. " Whitespace errors {{{1
  10. if exists("modula3_space_errors")
  11. if !exists("modula3_no_trail_space_error")
  12. syn match modula3SpaceError display excludenl "\s\+$"
  13. endif
  14. if !exists("modula3_no_tab_space_error")
  15. syn match modula3SpaceError display " \+\t"me=e-1
  16. endif
  17. endif
  18. " Keywords {{{1
  19. syn keyword modula3Keyword ANY ARRAY AS BITS BRANDED BY CASE CONST
  20. syn keyword modula3Keyword DEFINITION EVAL EXIT EXCEPT EXCEPTION EXIT
  21. syn keyword modula3Keyword EXPORTS FINALLY FROM GENERIC IMPORT LOCK METHOD
  22. syn keyword modula3Keyword OF RAISE RAISES READONLY RECORD REF
  23. syn keyword modula3Keyword RETURN SET TRY TYPE TYPECASE UNSAFE
  24. syn keyword modula3Keyword VALUE VAR WITH
  25. syn match modula3keyword "\<UNTRACED\>"
  26. " Special keywords, block delimiters etc
  27. syn keyword modula3Block PROCEDURE FUNCTION MODULE INTERFACE REPEAT THEN
  28. syn keyword modula3Block BEGIN END OBJECT METHODS OVERRIDES RECORD REVEAL
  29. syn keyword modula3Block WHILE UNTIL DO TO IF FOR ELSIF ELSE LOOP
  30. " Reserved identifiers {{{1
  31. syn keyword modula3Identifier ABS ADR ADRSIZE BITSIZE BYTESIZE CEILING DEC
  32. syn keyword modula3Identifier DISPOSE FIRST FLOAT FLOOR INC ISTYPE LAST
  33. syn keyword modula3Identifier LOOPHOLE MAX MIN NARROW NEW NUMBER ORD ROUND
  34. syn keyword modula3Identifier SUBARRAY TRUNC TYPECODE VAL
  35. " Predefined types {{{1
  36. syn keyword modula3Type ADDRESS BOOLEAN CARDINAL CHAR EXTENDED INTEGER
  37. syn keyword modula3Type LONGCARD LONGINT LONGREAL MUTEX NULL REAL REFANY TEXT
  38. syn keyword modula3Type WIDECHAR
  39. syn match modula3Type "\<\%(UNTRACED\s\+\)\=ROOT\>"
  40. " Operators {{{1
  41. syn keyword modula3Operator DIV MOD
  42. syn keyword modula3Operator IN
  43. syn keyword modula3Operator NOT AND OR
  44. " TODO: exclude = from declarations
  45. if exists("modula3_operators")
  46. syn match modula3Operator "\^"
  47. syn match modula3Operator "[-+/*]"
  48. syn match modula3Operator "&"
  49. syn match modula3Operator "<=\|<:\@!\|>=\|>"
  50. syn match modula3Operator ":\@<!=\|#"
  51. endif
  52. " Literals {{{1
  53. " Booleans
  54. syn keyword modula3Boolean TRUE FALSE
  55. " Nil
  56. syn keyword modula3Nil NIL
  57. " Numbers {{{2
  58. " NOTE: Negated numbers are constant expressions not literals
  59. syn case ignore
  60. " Integers
  61. syn match modula3Integer "\<\d\+L\=\>"
  62. if exists("modula3_number_errors")
  63. syn match modula3IntegerError "\<\d\d\=_\x\+L\=\>"
  64. endif
  65. let s:digits = "0123456789ABCDEF"
  66. for s:radix in range(2, 16)
  67. exe $'syn match modula3Integer "\<{s:radix}_[{s:digits[:s:radix - 1]}]\+L\=\>"'
  68. endfor
  69. unlet s:digits s:radix
  70. " Reals
  71. syn match modula3Real "\<\d\+\.\d\+\%([EDX][+-]\=\d\+\)\=\>"
  72. syn case match
  73. " Strings and characters {{{2
  74. " String escape sequences
  75. syn match modula3Escape "\\['"ntrf]" contained display
  76. " TODO: limit to <= 377 (255)
  77. syn match modula3Escape "\\\o\{3}" contained display
  78. syn match modula3Escape "\\\\" contained display
  79. " Characters
  80. syn match modula3Character "'\%([^']\|\\.\|\\\o\{3}\)'" contains=modula3Escape
  81. " Strings
  82. syn region modula3String start=+"+ end=+"+ contains=modula3Escape
  83. " Pragmas {{{1
  84. " EXTERNAL INLINE ASSERT TRACE FATAL UNUSED OBSOLETE CALLBACK EXPORTED PRAGMA NOWARN LINE LL LL.sup SPEC
  85. " Documented: INLINE ASSERT TRACE FATAL UNUSED OBSOLETE NOWARN
  86. syn region modula3Pragma start="<\*" end="\*>"
  87. " Comments {{{1
  88. if !exists("modula3_no_comment_fold")
  89. syn region modula3Comment start="(\*" end="\*)" contains=modula3Comment,@Spell fold
  90. syn region modula3LineCommentBlock start="^\s*(\*.*\*)\s*\n\%(^\s*(\*.*\*)\s*$\)\@=" end="^\s*(\*.*\*)\s*\n\%(^\s*(\*.*\*)\s*$\)\@!" contains=modula3Comment transparent fold keepend
  91. else
  92. syn region modula3Comment start="(\*" end="\*)" contains=modula3Comment,@Spell
  93. endif
  94. " Syncing "{{{1
  95. syn sync minlines=100
  96. " Default highlighting {{{1
  97. hi def link modula3Block Statement
  98. hi def link modula3Boolean Boolean
  99. hi def link modula3Character Character
  100. hi def link modula3Comment Comment
  101. hi def link modula3Escape Special
  102. hi def link modula3Identifier Keyword
  103. hi def link modula3Integer Number
  104. hi def link modula3Keyword Statement
  105. hi def link modula3Nil Constant
  106. hi def link modula3IntegerError Error
  107. hi def link modula3Operator Operator
  108. hi def link modula3Pragma PreProc
  109. hi def link modula3Real Float
  110. hi def link modula3String String
  111. hi def link modula3Type Type "}}}
  112. let b:current_syntax = "modula3"
  113. " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: