java.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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/java/java.ts
  8. var conf = {
  9. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  10. comments: {
  11. lineComment: "//",
  12. blockComment: ["/*", "*/"]
  13. },
  14. brackets: [
  15. ["{", "}"],
  16. ["[", "]"],
  17. ["(", ")"]
  18. ],
  19. autoClosingPairs: [
  20. { open: "{", close: "}" },
  21. { open: "[", close: "]" },
  22. { open: "(", close: ")" },
  23. { open: '"', close: '"' },
  24. { open: "'", close: "'" }
  25. ],
  26. surroundingPairs: [
  27. { open: "{", close: "}" },
  28. { open: "[", close: "]" },
  29. { open: "(", close: ")" },
  30. { open: '"', close: '"' },
  31. { open: "'", close: "'" },
  32. { open: "<", close: ">" }
  33. ],
  34. folding: {
  35. markers: {
  36. start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),
  37. end: new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")
  38. }
  39. }
  40. };
  41. var language = {
  42. defaultToken: "",
  43. tokenPostfix: ".java",
  44. keywords: [
  45. "abstract",
  46. "continue",
  47. "for",
  48. "new",
  49. "switch",
  50. "assert",
  51. "default",
  52. "goto",
  53. "package",
  54. "synchronized",
  55. "boolean",
  56. "do",
  57. "if",
  58. "private",
  59. "this",
  60. "break",
  61. "double",
  62. "implements",
  63. "protected",
  64. "throw",
  65. "byte",
  66. "else",
  67. "import",
  68. "public",
  69. "throws",
  70. "case",
  71. "enum",
  72. "instanceof",
  73. "return",
  74. "transient",
  75. "catch",
  76. "extends",
  77. "int",
  78. "short",
  79. "try",
  80. "char",
  81. "final",
  82. "interface",
  83. "static",
  84. "void",
  85. "class",
  86. "finally",
  87. "long",
  88. "strictfp",
  89. "volatile",
  90. "const",
  91. "float",
  92. "native",
  93. "super",
  94. "while",
  95. "true",
  96. "false",
  97. "yield",
  98. "record",
  99. "sealed",
  100. "non-sealed",
  101. "permits"
  102. ],
  103. operators: [
  104. "=",
  105. ">",
  106. "<",
  107. "!",
  108. "~",
  109. "?",
  110. ":",
  111. "==",
  112. "<=",
  113. ">=",
  114. "!=",
  115. "&&",
  116. "||",
  117. "++",
  118. "--",
  119. "+",
  120. "-",
  121. "*",
  122. "/",
  123. "&",
  124. "|",
  125. "^",
  126. "%",
  127. "<<",
  128. ">>",
  129. ">>>",
  130. "+=",
  131. "-=",
  132. "*=",
  133. "/=",
  134. "&=",
  135. "|=",
  136. "^=",
  137. "%=",
  138. "<<=",
  139. ">>=",
  140. ">>>="
  141. ],
  142. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  143. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  144. digits: /\d+(_+\d+)*/,
  145. octaldigits: /[0-7]+(_+[0-7]+)*/,
  146. binarydigits: /[0-1]+(_+[0-1]+)*/,
  147. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  148. tokenizer: {
  149. root: [
  150. ["non-sealed", "keyword.non-sealed"],
  151. [
  152. /[a-zA-Z_$][\w$]*/,
  153. {
  154. cases: {
  155. "@keywords": { token: "keyword.$0" },
  156. "@default": "identifier"
  157. }
  158. }
  159. ],
  160. { include: "@whitespace" },
  161. [/[{}()\[\]]/, "@brackets"],
  162. [/[<>](?!@symbols)/, "@brackets"],
  163. [
  164. /@symbols/,
  165. {
  166. cases: {
  167. "@operators": "delimiter",
  168. "@default": ""
  169. }
  170. }
  171. ],
  172. [/@\s*[a-zA-Z_\$][\w\$]*/, "annotation"],
  173. [/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, "number.float"],
  174. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, "number.float"],
  175. [/0[xX](@hexdigits)[Ll]?/, "number.hex"],
  176. [/0(@octaldigits)[Ll]?/, "number.octal"],
  177. [/0[bB](@binarydigits)[Ll]?/, "number.binary"],
  178. [/(@digits)[fFdD]/, "number.float"],
  179. [/(@digits)[lL]?/, "number"],
  180. [/[;,.]/, "delimiter"],
  181. [/"([^"\\]|\\.)*$/, "string.invalid"],
  182. [/"""/, "string", "@multistring"],
  183. [/"/, "string", "@string"],
  184. [/'[^\\']'/, "string"],
  185. [/(')(@escapes)(')/, ["string", "string.escape", "string"]],
  186. [/'/, "string.invalid"]
  187. ],
  188. whitespace: [
  189. [/[ \t\r\n]+/, ""],
  190. [/\/\*\*(?!\/)/, "comment.doc", "@javadoc"],
  191. [/\/\*/, "comment", "@comment"],
  192. [/\/\/.*$/, "comment"]
  193. ],
  194. comment: [
  195. [/[^\/*]+/, "comment"],
  196. [/\*\//, "comment", "@pop"],
  197. [/[\/*]/, "comment"]
  198. ],
  199. javadoc: [
  200. [/[^\/*]+/, "comment.doc"],
  201. [/\/\*/, "comment.doc.invalid"],
  202. [/\*\//, "comment.doc", "@pop"],
  203. [/[\/*]/, "comment.doc"]
  204. ],
  205. string: [
  206. [/[^\\"]+/, "string"],
  207. [/@escapes/, "string.escape"],
  208. [/\\./, "string.escape.invalid"],
  209. [/"/, "string", "@pop"]
  210. ],
  211. multistring: [
  212. [/[^\\"]+/, "string"],
  213. [/@escapes/, "string.escape"],
  214. [/\\./, "string.escape.invalid"],
  215. [/"""/, "string", "@pop"],
  216. [/./, "string"]
  217. ]
  218. }
  219. };
  220. export {
  221. conf,
  222. language
  223. };