r.js 4.9 KB

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