java.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. export var conf = {
  6. // the default separators except `@$`
  7. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  8. comments: {
  9. lineComment: '//',
  10. blockComment: ['/*', '*/']
  11. },
  12. brackets: [
  13. ['{', '}'],
  14. ['[', ']'],
  15. ['(', ')']
  16. ],
  17. autoClosingPairs: [
  18. { open: '{', close: '}' },
  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. { open: "'", close: "'" },
  30. { open: '<', close: '>' }
  31. ],
  32. folding: {
  33. markers: {
  34. start: new RegExp('^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))'),
  35. end: new RegExp('^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))')
  36. }
  37. }
  38. };
  39. export var language = {
  40. defaultToken: '',
  41. tokenPostfix: '.java',
  42. keywords: [
  43. 'abstract',
  44. 'continue',
  45. 'for',
  46. 'new',
  47. 'switch',
  48. 'assert',
  49. 'default',
  50. 'goto',
  51. 'package',
  52. 'synchronized',
  53. 'boolean',
  54. 'do',
  55. 'if',
  56. 'private',
  57. 'this',
  58. 'break',
  59. 'double',
  60. 'implements',
  61. 'protected',
  62. 'throw',
  63. 'byte',
  64. 'else',
  65. 'import',
  66. 'public',
  67. 'throws',
  68. 'case',
  69. 'enum',
  70. 'instanceof',
  71. 'return',
  72. 'transient',
  73. 'catch',
  74. 'extends',
  75. 'int',
  76. 'short',
  77. 'try',
  78. 'char',
  79. 'final',
  80. 'interface',
  81. 'static',
  82. 'void',
  83. 'class',
  84. 'finally',
  85. 'long',
  86. 'strictfp',
  87. 'volatile',
  88. 'const',
  89. 'float',
  90. 'native',
  91. 'super',
  92. 'while',
  93. 'true',
  94. 'false'
  95. ],
  96. operators: [
  97. '=',
  98. '>',
  99. '<',
  100. '!',
  101. '~',
  102. '?',
  103. ':',
  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. // we include these common regular expressions
  136. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  137. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  138. digits: /\d+(_+\d+)*/,
  139. octaldigits: /[0-7]+(_+[0-7]+)*/,
  140. binarydigits: /[0-1]+(_+[0-1]+)*/,
  141. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  142. // The main tokenizer for our languages
  143. tokenizer: {
  144. root: [
  145. // identifiers and keywords
  146. [
  147. /[a-zA-Z_$][\w$]*/,
  148. {
  149. cases: {
  150. '@keywords': { token: 'keyword.$0' },
  151. '@default': 'identifier'
  152. }
  153. }
  154. ],
  155. // whitespace
  156. { include: '@whitespace' },
  157. // delimiters and operators
  158. [/[{}()\[\]]/, '@brackets'],
  159. [/[<>](?!@symbols)/, '@brackets'],
  160. [
  161. /@symbols/,
  162. {
  163. cases: {
  164. '@operators': 'delimiter',
  165. '@default': ''
  166. }
  167. }
  168. ],
  169. // @ annotations.
  170. [/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
  171. // numbers
  172. [/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'],
  173. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'],
  174. [/0[xX](@hexdigits)[Ll]?/, 'number.hex'],
  175. [/0(@octaldigits)[Ll]?/, 'number.octal'],
  176. [/0[bB](@binarydigits)[Ll]?/, 'number.binary'],
  177. [/(@digits)[fFdD]/, 'number.float'],
  178. [/(@digits)[lL]?/, 'number'],
  179. // delimiter: after number because of .\d floats
  180. [/[;,.]/, 'delimiter'],
  181. // strings
  182. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  183. [/"/, 'string', '@string'],
  184. // characters
  185. [/'[^\\']'/, 'string'],
  186. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  187. [/'/, 'string.invalid']
  188. ],
  189. whitespace: [
  190. [/[ \t\r\n]+/, ''],
  191. [/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'],
  192. [/\/\*/, 'comment', '@comment'],
  193. [/\/\/.*$/, 'comment']
  194. ],
  195. comment: [
  196. [/[^\/*]+/, 'comment'],
  197. // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-(
  198. // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/
  199. [/\*\//, 'comment', '@pop'],
  200. [/[\/*]/, 'comment']
  201. ],
  202. //Identical copy of comment above, except for the addition of .doc
  203. javadoc: [
  204. [/[^\/*]+/, 'comment.doc'],
  205. // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-(
  206. [/\/\*/, 'comment.doc.invalid'],
  207. [/\*\//, 'comment.doc', '@pop'],
  208. [/[\/*]/, 'comment.doc']
  209. ],
  210. string: [
  211. [/[^\\"]+/, 'string'],
  212. [/@escapes/, 'string.escape'],
  213. [/\\./, 'string.escape.invalid'],
  214. [/"/, 'string', '@pop']
  215. ]
  216. }
  217. };