poke.vim 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. " Copyright (C) 2021 Matthew T. Ihlenfield.
  2. "
  3. " This program is free software: you can redistribute it and/or modify
  4. " it under the terms of the GNU General Public License as published by
  5. " the Free Software Foundation, either version 3 of the License, or
  6. " (at your option) any later version.
  7. "
  8. " This program is distributed in the hope that it will be useful,
  9. " but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. " GNU General Public License for more details.
  12. "
  13. " You should have received a copy of the GNU General Public License
  14. " along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. "
  16. " Vim syntax file
  17. " Language: Poke
  18. " Maintainer: Matt Ihlenfield <mtihlenfield@protonmail.com>
  19. " Filenames: *.pk
  20. " Latest Revision: 10 March 2021
  21. if exists('b:current_syntax')
  22. finish
  23. endif
  24. " Poke statement
  25. syn keyword pokeStatement assert break continue return
  26. syn keyword pokeStatement type unit fun method nextgroup=pokeFunction skipwhite
  27. syn keyword pokeStatement var nextgroup=pokeVar skipWhite
  28. " Identifiers
  29. syn match pokeVar '\h\w*' display contained
  30. " User defined functions
  31. syn match pokeFunction '\h\w*' display contained
  32. " Poke operators
  33. syn keyword pokeOperator in sizeof as isa unmap
  34. " Conditionals
  35. syn keyword pokeConditional if else where
  36. " Structures, unions, etc...
  37. syn keyword pokeStructure struct union pinned
  38. " Loops
  39. syn keyword pokeRepeat while for
  40. " Imports
  41. syn keyword pokeLoad load
  42. " Exceptions
  43. syn keyword pokeException try catch until raise
  44. " Exception types
  45. syn keyword pokeExceptionType Exception E_generic E_out_of_bounds
  46. syn keyword pokeExceptionType E_eof E_elem E_constraint
  47. syn keyword pokeExceptionType E_conv E_map_bounds E_map
  48. syn keyword pokeExceptionType E_div_by_zero E_no_ios E_no_return
  49. syn keyword pokeExceptionType E_io E_io_flags E_assert E_overflow
  50. " Exception codes
  51. syn keyword pokeExceptionCode EC_generic EC_out_of_bounds
  52. syn keyword pokeExceptionCode EC_eof EC_elem EC_constraint
  53. syn keyword pokeExceptionCode EC_conv EC_map_bounds EC_map
  54. syn keyword pokeExceptionCode EC_div_by_zero EC_no_ios EC_no_return
  55. syn keyword pokeExceptionCode EC_io EC_io_flags EC_assert EC_overflow
  56. " Poke builtin types
  57. syn keyword pokeBuiltinType string void int uint bit nibble
  58. syn keyword pokeBuiltinType byte char ushort short ulong long
  59. syn keyword pokeBuiltinType uint8 uint16 uint32 uint64
  60. syn keyword pokeBuiltinType off64 uoff64 offset
  61. syn keyword pokeBuiltinType Comparator POSIX_Time32 POSIX_Time64
  62. syn keyword pokeBuiltinType big little any
  63. " Poke constants
  64. syn keyword pokeConstant ENDIAN_LITTLE ENDIAN_BIG
  65. syn keyword pokeConstant IOS_F_READ IOS_F_WRITE IOS_F_TRUNCATE IOS_F_CREATE
  66. syn keyword pokeConstant IOS_M_RDONLY IOS_M_WRONLY IOS_M_RDWR
  67. syn keyword pokeConstant load_path NULL OFFSET
  68. " Poke std lib
  69. syn keyword pokeBuiltinFunction print printf catos stoca atoi ltos reverse
  70. syn keyword pokeBuiltinFunction ltrim rtrim strchr qsort crc32 alignto
  71. syn keyword pokeBuiltinFunction open close flush get_ios set_ios iosize
  72. syn keyword pokeBuiltinFunction rand get_endian set_endian strace exit
  73. syn keyword pokeBuiltinFunction getenv
  74. " Formats
  75. " Special chars
  76. syn match pokeSpecial "\\\([nt\\]\|\o\{1,3}\)" display contained
  77. " Chars
  78. syn match pokeChar "'[^']*'" contains=pokeSpecial
  79. " Attributes
  80. syn match pokeAttribute "\h\w*'\h\w"
  81. " Strings
  82. syn region pokeString skip=+\\\\\|\\"+ start=+"+ end=+"+ contains=pokeSpecial
  83. " Integer literals
  84. syn match pokeInteger "\<\d\+_*\d*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
  85. syn match pokeInteger "\<0[Xx]\x\+_*\x*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
  86. syn match pokeInteger "\<0[Oo]\o\+_*\o*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
  87. syn match pokeInteger "\<0[Bb][01]\+_*[01]*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
  88. " Units
  89. syn keyword pokeBuiltinUnit b M B
  90. syn keyword pokeBuiltinUnit Kb KB Mb MB Gb GB
  91. syn keyword pokeBuiltinUnit Kib KiB Mib MiB Gib GiB
  92. " Offsets
  93. syn match pokeOffset "#\h\w*" contains=pokeBuiltinUnit
  94. " Comments
  95. syn keyword pokeCommentTodo TODO FIXME XXX TBD contained
  96. syn match pokeLineComment "\/\/.*" contains=pokeCommentTodo,@Spell extend
  97. syn region pokeComment start="/\*" end="\*/" contains=pokeCommentTodo,@Spell fold extend
  98. " Allow folding of blocks
  99. syn region pokeBlock start="{" end="}" transparent fold
  100. " Highlight groups
  101. hi def link pokeBuiltinFunction Function
  102. hi def link pokeBuiltinType Type
  103. hi def link pokeBuiltinUnit Keyword
  104. hi def link pokeChar Character
  105. hi def link pokeComment Comment
  106. hi def link pokeCommentTodo Todo
  107. hi def link pokeConditional Conditional
  108. hi def link pokeConstant Constant
  109. hi def link pokeException Exception
  110. hi def link pokeExceptionCode Constant
  111. hi def link pokeExceptionType Type
  112. hi def link pokeFunction Function
  113. hi def link pokeInteger Number
  114. hi def link pokeLineComment Comment
  115. hi def link pokeLoad Include
  116. hi def link pokeOffset StorageClass
  117. hi def link pokeOperator Operator
  118. hi def link pokeSpecial SpecialChar
  119. hi def link pokeStatement Statement
  120. hi def link pokeString String
  121. hi def link pokeStructure Structure
  122. hi def link pokeRepeat Repeat
  123. hi def link pokeVar Identifier
  124. let b:current_syntax = 'poke'