go.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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/go/go',["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. blockComment: ['/*', '*/']
  13. },
  14. brackets: [
  15. ['{', '}'],
  16. ['[', ']'],
  17. ['(', ')']
  18. ],
  19. autoClosingPairs: [
  20. { open: '{', close: '}' },
  21. { open: '[', close: ']' },
  22. { open: '(', close: ')' },
  23. { open: '`', close: '`', notIn: ['string'] },
  24. { open: '"', close: '"', notIn: ['string'] },
  25. { open: "'", close: "'", notIn: ['string', 'comment'] }
  26. ],
  27. surroundingPairs: [
  28. { open: '{', close: '}' },
  29. { open: '[', close: ']' },
  30. { open: '(', close: ')' },
  31. { open: '`', close: '`' },
  32. { open: '"', close: '"' },
  33. { open: "'", close: "'" }
  34. ]
  35. };
  36. exports.language = {
  37. defaultToken: '',
  38. tokenPostfix: '.go',
  39. keywords: [
  40. 'break',
  41. 'case',
  42. 'chan',
  43. 'const',
  44. 'continue',
  45. 'default',
  46. 'defer',
  47. 'else',
  48. 'fallthrough',
  49. 'for',
  50. 'func',
  51. 'go',
  52. 'goto',
  53. 'if',
  54. 'import',
  55. 'interface',
  56. 'map',
  57. 'package',
  58. 'range',
  59. 'return',
  60. 'select',
  61. 'struct',
  62. 'switch',
  63. 'type',
  64. 'var',
  65. 'bool',
  66. 'true',
  67. 'false',
  68. 'uint8',
  69. 'uint16',
  70. 'uint32',
  71. 'uint64',
  72. 'int8',
  73. 'int16',
  74. 'int32',
  75. 'int64',
  76. 'float32',
  77. 'float64',
  78. 'complex64',
  79. 'complex128',
  80. 'byte',
  81. 'rune',
  82. 'uint',
  83. 'int',
  84. 'uintptr',
  85. 'string',
  86. 'nil'
  87. ],
  88. operators: [
  89. '+',
  90. '-',
  91. '*',
  92. '/',
  93. '%',
  94. '&',
  95. '|',
  96. '^',
  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. ':'
  136. ],
  137. // we include these common regular expressions
  138. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  139. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  140. // The main tokenizer for our languages
  141. tokenizer: {
  142. root: [
  143. // identifiers and keywords
  144. [
  145. /[a-zA-Z_]\w*/,
  146. {
  147. cases: {
  148. '@keywords': { token: 'keyword.$0' },
  149. '@default': 'identifier'
  150. }
  151. }
  152. ],
  153. // whitespace
  154. { include: '@whitespace' },
  155. // [[ attributes ]].
  156. [/\[\[.*\]\]/, 'annotation'],
  157. // Preprocessor directive
  158. [/^\s*#\w+/, 'keyword'],
  159. // delimiters and operators
  160. [/[{}()\[\]]/, '@brackets'],
  161. [/[<>](?!@symbols)/, '@brackets'],
  162. [
  163. /@symbols/,
  164. {
  165. cases: {
  166. '@operators': 'delimiter',
  167. '@default': ''
  168. }
  169. }
  170. ],
  171. // numbers
  172. [/\d*\d+[eE]([\-+]?\d+)?/, 'number.float'],
  173. [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
  174. [/0[xX][0-9a-fA-F']*[0-9a-fA-F]/, 'number.hex'],
  175. [/0[0-7']*[0-7]/, 'number.octal'],
  176. [/0[bB][0-1']*[0-1]/, 'number.binary'],
  177. [/\d[\d']*/, 'number'],
  178. [/\d/, 'number'],
  179. // delimiter: after number because of .\d floats
  180. [/[;,.]/, 'delimiter'],
  181. // strings
  182. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  183. [/"/, 'string', '@string'],
  184. [/`/, 'string', '@rawstring'],
  185. // characters
  186. [/'[^\\']'/, 'string'],
  187. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  188. [/'/, 'string.invalid']
  189. ],
  190. whitespace: [
  191. [/[ \t\r\n]+/, ''],
  192. [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'],
  193. [/\/\*/, 'comment', '@comment'],
  194. [/\/\/.*$/, 'comment']
  195. ],
  196. comment: [
  197. [/[^\/*]+/, 'comment'],
  198. // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-(
  199. // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/
  200. [/\*\//, 'comment', '@pop'],
  201. [/[\/*]/, 'comment']
  202. ],
  203. //Identical copy of comment above, except for the addition of .doc
  204. doccomment: [
  205. [/[^\/*]+/, 'comment.doc'],
  206. // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-(
  207. [/\/\*/, 'comment.doc.invalid'],
  208. [/\*\//, 'comment.doc', '@pop'],
  209. [/[\/*]/, 'comment.doc']
  210. ],
  211. string: [
  212. [/[^\\"]+/, 'string'],
  213. [/@escapes/, 'string.escape'],
  214. [/\\./, 'string.escape.invalid'],
  215. [/"/, 'string', '@pop']
  216. ],
  217. rawstring: [
  218. [/[^\`]/, 'string'],
  219. [/`/, 'string', '@pop']
  220. ]
  221. }
  222. };
  223. });