r.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. define('vs/basic-languages/r/r',["require", "exports"], function (require, exports) {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.language = exports.conf = void 0;
  9. exports.conf = {
  10. comments: {
  11. lineComment: '#'
  12. },
  13. brackets: [
  14. ['{', '}'],
  15. ['[', ']'],
  16. ['(', ')']
  17. ],
  18. autoClosingPairs: [
  19. { open: '{', close: '}' },
  20. { open: '[', close: ']' },
  21. { open: '(', close: ')' },
  22. { open: '"', close: '"' }
  23. ],
  24. surroundingPairs: [
  25. { open: '{', close: '}' },
  26. { open: '[', close: ']' },
  27. { open: '(', close: ')' },
  28. { open: '"', close: '"' }
  29. ]
  30. };
  31. exports.language = {
  32. defaultToken: '',
  33. tokenPostfix: '.r',
  34. roxygen: [
  35. '@alias',
  36. '@aliases',
  37. '@assignee',
  38. '@author',
  39. '@backref',
  40. '@callGraph',
  41. '@callGraphDepth',
  42. '@callGraphPrimitives',
  43. '@concept',
  44. '@describeIn',
  45. '@description',
  46. '@details',
  47. '@docType',
  48. '@encoding',
  49. '@evalNamespace',
  50. '@evalRd',
  51. '@example',
  52. '@examples',
  53. '@export',
  54. '@exportClass',
  55. '@exportMethod',
  56. '@exportPattern',
  57. '@family',
  58. '@field',
  59. '@formals',
  60. '@format',
  61. '@import',
  62. '@importClassesFrom',
  63. '@importFrom',
  64. '@importMethodsFrom',
  65. '@include',
  66. '@inherit',
  67. '@inheritDotParams',
  68. '@inheritParams',
  69. '@inheritSection',
  70. '@keywords',
  71. '@md',
  72. '@method',
  73. '@name',
  74. '@noMd',
  75. '@noRd',
  76. '@note',
  77. '@param',
  78. '@rawNamespace',
  79. '@rawRd',
  80. '@rdname',
  81. '@references',
  82. '@return',
  83. '@S3method',
  84. '@section',
  85. '@seealso',
  86. '@setClass',
  87. '@slot',
  88. '@source',
  89. '@template',
  90. '@templateVar',
  91. '@title',
  92. '@TODO',
  93. '@usage',
  94. '@useDynLib'
  95. ],
  96. constants: [
  97. 'NULL',
  98. 'FALSE',
  99. 'TRUE',
  100. 'NA',
  101. 'Inf',
  102. 'NaN',
  103. 'NA_integer_',
  104. 'NA_real_',
  105. 'NA_complex_',
  106. 'NA_character_',
  107. 'T',
  108. 'F',
  109. 'LETTERS',
  110. 'letters',
  111. 'month.abb',
  112. 'month.name',
  113. 'pi',
  114. 'R.version.string'
  115. ],
  116. keywords: [
  117. 'break',
  118. 'next',
  119. 'return',
  120. 'if',
  121. 'else',
  122. 'for',
  123. 'in',
  124. 'repeat',
  125. 'while',
  126. 'array',
  127. 'category',
  128. 'character',
  129. 'complex',
  130. 'double',
  131. 'function',
  132. 'integer',
  133. 'list',
  134. 'logical',
  135. 'matrix',
  136. 'numeric',
  137. 'vector',
  138. 'data.frame',
  139. 'factor',
  140. 'library',
  141. 'require',
  142. 'attach',
  143. 'detach',
  144. 'source'
  145. ],
  146. special: ['\\n', '\\r', '\\t', '\\b', '\\a', '\\f', '\\v', "\\'", '\\"', '\\\\'],
  147. brackets: [
  148. { open: '{', close: '}', token: 'delimiter.curly' },
  149. { open: '[', close: ']', token: 'delimiter.bracket' },
  150. { open: '(', close: ')', token: 'delimiter.parenthesis' }
  151. ],
  152. tokenizer: {
  153. root: [
  154. { include: '@numbers' },
  155. { include: '@strings' },
  156. [/[{}\[\]()]/, '@brackets'],
  157. { include: '@operators' },
  158. [/#'$/, 'comment.doc'],
  159. [/#'/, 'comment.doc', '@roxygen'],
  160. [/(^#.*$)/, 'comment'],
  161. [/\s+/, 'white'],
  162. [/[,:;]/, 'delimiter'],
  163. [/@[a-zA-Z]\w*/, 'tag'],
  164. [
  165. /[a-zA-Z]\w*/,
  166. {
  167. cases: {
  168. '@keywords': 'keyword',
  169. '@constants': 'constant',
  170. '@default': 'identifier'
  171. }
  172. }
  173. ]
  174. ],
  175. // Recognize Roxygen comments
  176. roxygen: [
  177. [
  178. /@\w+/,
  179. {
  180. cases: {
  181. '@roxygen': 'tag',
  182. '@eos': { token: 'comment.doc', next: '@pop' },
  183. '@default': 'comment.doc'
  184. }
  185. }
  186. ],
  187. [
  188. /\s+/,
  189. {
  190. cases: {
  191. '@eos': { token: 'comment.doc', next: '@pop' },
  192. '@default': 'comment.doc'
  193. }
  194. }
  195. ],
  196. [/.*/, { token: 'comment.doc', next: '@pop' }]
  197. ],
  198. // Recognize positives, negatives, decimals, imaginaries, and scientific notation
  199. numbers: [
  200. [/0[xX][0-9a-fA-F]+/, 'number.hex'],
  201. [/-?(\d*\.)?\d+([eE][+\-]?\d+)?/, 'number']
  202. ],
  203. // Recognize operators
  204. operators: [
  205. [/<{1,2}-/, 'operator'],
  206. [/->{1,2}/, 'operator'],
  207. [/%[^%\s]+%/, 'operator'],
  208. [/\*\*/, 'operator'],
  209. [/%%/, 'operator'],
  210. [/&&/, 'operator'],
  211. [/\|\|/, 'operator'],
  212. [/<</, 'operator'],
  213. [/>>/, 'operator'],
  214. [/[-+=&|!<>^~*/:$]/, 'operator']
  215. ],
  216. // Recognize strings, including those broken across lines
  217. strings: [
  218. [/'/, 'string.escape', '@stringBody'],
  219. [/"/, 'string.escape', '@dblStringBody']
  220. ],
  221. stringBody: [
  222. [
  223. /\\./,
  224. {
  225. cases: {
  226. '@special': 'string',
  227. '@default': 'error-token'
  228. }
  229. }
  230. ],
  231. [/'/, 'string.escape', '@popall'],
  232. [/./, 'string']
  233. ],
  234. dblStringBody: [
  235. [
  236. /\\./,
  237. {
  238. cases: {
  239. '@special': 'string',
  240. '@default': 'error-token'
  241. }
  242. }
  243. ],
  244. [/"/, 'string.escape', '@popall'],
  245. [/./, 'string']
  246. ]
  247. }
  248. };
  249. });