modula2-definition.tmLanguage.json 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. {
  2. "name": "GNU Modula-2 Definition",
  3. "scopeName": "source.modula2.definition",
  4. "patterns": [
  5. {
  6. "include": "#comments"
  7. },
  8. {
  9. "include": "#strings"
  10. },
  11. {
  12. "include": "#numbers"
  13. },
  14. {
  15. "include": "#header"
  16. },
  17. {
  18. "include": "#imports"
  19. },
  20. {
  21. "include": "#exports"
  22. },
  23. {
  24. "include": "#declarations"
  25. },
  26. {
  27. "include": "#procedure"
  28. },
  29. {
  30. "include": "#attributes"
  31. },
  32. {
  33. "include": "#types"
  34. },
  35. {
  36. "include": "#operators"
  37. },
  38. {
  39. "include": "#keywords"
  40. }
  41. ],
  42. "repository": {
  43. "comments": {
  44. "patterns": [
  45. {
  46. "name": "comment.block.modula2",
  47. "begin": "\\(\\*",
  48. "end": "\\*\\)"
  49. }
  50. ]
  51. },
  52. "strings": {
  53. "patterns": [
  54. {
  55. "name": "string.quoted.double.modula2",
  56. "begin": "\"",
  57. "end": "\"",
  58. "patterns": [
  59. {
  60. "name": "constant.character.escape.modula2",
  61. "match": "\\\\."
  62. }
  63. ]
  64. }
  65. ]
  66. },
  67. "numbers": {
  68. "patterns": [
  69. {
  70. "name": "constant.numeric.modula2",
  71. "match": "\\b(?:[0-9]+|[0-9A-Fa-f]+H)\\b"
  72. }
  73. ]
  74. },
  75. "header": {
  76. "patterns": [
  77. {
  78. "name": "meta.module.definition.modula2",
  79. "match": "\\b(DEFINITION)\\s+(MODULE)\\s+([A-Za-z_][A-Za-z0-9_]*)",
  80. "captures": {
  81. "1": {
  82. "name": "keyword.control.module.modula2"
  83. },
  84. "2": {
  85. "name": "keyword.control.module.modula2"
  86. },
  87. "3": {
  88. "name": "entity.name.namespace.modula2"
  89. }
  90. }
  91. },
  92. {
  93. "name": "meta.module.end.modula2",
  94. "match": "\\b(END)\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*\\.",
  95. "captures": {
  96. "1": {
  97. "name": "keyword.control.module.modula2"
  98. },
  99. "2": {
  100. "name": "entity.name.namespace.modula2"
  101. }
  102. }
  103. },
  104. {
  105. "name": "keyword.control.module.modula2",
  106. "match": "\\bFOR\\b(?=\\s+\")"
  107. }
  108. ]
  109. },
  110. "imports": {
  111. "patterns": [
  112. {
  113. "name": "keyword.control.import.modula2",
  114. "match": "\\b(?:FROM|IMPORT)\\b"
  115. },
  116. {
  117. "name": "entity.name.namespace.import.modula2",
  118. "match": "\\b(FROM)\\s+([A-Za-z_][A-Za-z0-9_]*)",
  119. "captures": {
  120. "1": {
  121. "name": "keyword.control.import.modula2"
  122. },
  123. "2": {
  124. "name": "entity.name.namespace.import.modula2"
  125. }
  126. }
  127. }
  128. ]
  129. },
  130. "exports": {
  131. "patterns": [
  132. {
  133. "name": "keyword.control.export.modula2",
  134. "match": "\\bEXPORT(?:\\s+(?:QUALIFIED|UNQUALIFIED))?\\b"
  135. }
  136. ]
  137. },
  138. "declarations": {
  139. "patterns": [
  140. {
  141. "name": "storage.type.declaration.modula2",
  142. "match": "\\b(?:CONST|TYPE|VAR)\\b"
  143. },
  144. {
  145. "name": "entity.name.type.modula2",
  146. "match": "\\bTYPE\\s+([A-Za-z_][A-Za-z0-9_]*)",
  147. "captures": {
  148. "1": {
  149. "name": "entity.name.type.modula2"
  150. }
  151. }
  152. },
  153. {
  154. "name": "constant.other.modula2",
  155. "match": "\\bCONST\\s+([A-Za-z_][A-Za-z0-9_]*)",
  156. "captures": {
  157. "1": {
  158. "name": "constant.other.modula2"
  159. }
  160. }
  161. },
  162. {
  163. "name": "variable.other.modula2",
  164. "match": "\\bVAR\\s+([A-Za-z_][A-Za-z0-9_]*)",
  165. "captures": {
  166. "1": {
  167. "name": "variable.other.modula2"
  168. }
  169. }
  170. }
  171. ]
  172. },
  173. "procedure": {
  174. "patterns": [
  175. {
  176. "name": "keyword.control.procedure.modula2",
  177. "match": "\\bPROCEDURE\\b"
  178. },
  179. {
  180. "name": "meta.procedure.modula2",
  181. "match": "\\b(PROCEDURE)\\s+((?:__ATTRIBUTE__\\s+__BUILTIN__\\s+)?[A-Za-z_][A-Za-z0-9_]*)",
  182. "captures": {
  183. "1": {
  184. "name": "keyword.control.procedure.modula2"
  185. },
  186. "2": {
  187. "name": "entity.name.function.modula2"
  188. }
  189. }
  190. }
  191. ]
  192. },
  193. "attributes": {
  194. "patterns": [
  195. {
  196. "name": "keyword.other.gnu.modula2",
  197. "match": "\\b__(?:ATTRIBUTE|BUILTIN)__\\b"
  198. }
  199. ]
  200. },
  201. "types": {
  202. "patterns": [
  203. {
  204. "name": "storage.type.modula2",
  205. "match": "\\b(?:INTEGER|CARDINAL|REAL|LONGREAL|SHORTREAL|CHAR|BOOLEAN|BITSET|ADDRESS|WORD|LOC|BYTE)\\b"
  206. },
  207. {
  208. "name": "keyword.operator.type.modula2",
  209. "match": "\\b(?:ARRAY|OF|POINTER)\\b"
  210. }
  211. ]
  212. },
  213. "operators": {
  214. "patterns": [
  215. {
  216. "name": "keyword.operator.modula2",
  217. "match": ":=|<=|>=|<>|#|=|<|>|\\+|-|\\*|/|\\.\\.|;|:|\\."
  218. }
  219. ]
  220. },
  221. "keywords": {
  222. "patterns": [
  223. {
  224. "name": "keyword.control.modula2",
  225. "match": "\\b(?:AND|BEGIN|BY|CASE|DEFINITION|DIV|DO|ELSE|ELSIF|END|EXIT|EXPORT|FOR|FROM|IF|IMPLEMENTATION|IMPORT|IN|LOOP|MOD|MODULE|NOT|OF|OR|POINTER|PROCEDURE|QUALIFIED|RECORD|REPEAT|RETURN|SET|THEN|TO|TYPE|UNTIL|VAR|WHILE|WITH)\\b"
  226. }
  227. ]
  228. }
  229. }
  230. }