objective-c.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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(["require", "exports"], function (require, exports) {
  6. 'use strict';
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.conf = {
  9. comments: {
  10. lineComment: '//',
  11. blockComment: ['/*', '*/'],
  12. },
  13. brackets: [
  14. ['{', '}'],
  15. ['[', ']'],
  16. ['(', ')']
  17. ],
  18. autoClosingPairs: [
  19. { open: '{', close: '}' },
  20. { open: '[', close: ']' },
  21. { open: '(', close: ')' },
  22. { open: '"', close: '"' },
  23. { open: '\'', close: '\'' },
  24. ],
  25. surroundingPairs: [
  26. { open: '{', close: '}' },
  27. { open: '[', close: ']' },
  28. { open: '(', close: ')' },
  29. { open: '"', close: '"' },
  30. { open: '\'', close: '\'' },
  31. ]
  32. };
  33. exports.language = {
  34. defaultToken: '',
  35. tokenPostfix: '.objective-c',
  36. keywords: [
  37. '#import',
  38. '#include',
  39. '#define',
  40. '#else',
  41. '#endif',
  42. '#if',
  43. '#ifdef',
  44. '#ifndef',
  45. '#ident',
  46. '#undef',
  47. '@class',
  48. '@defs',
  49. '@dynamic',
  50. '@encode',
  51. '@end',
  52. '@implementation',
  53. '@interface',
  54. '@package',
  55. '@private',
  56. '@protected',
  57. '@property',
  58. '@protocol',
  59. '@public',
  60. '@selector',
  61. '@synthesize',
  62. '__declspec',
  63. 'assign',
  64. 'auto',
  65. 'BOOL',
  66. 'break',
  67. 'bycopy',
  68. 'byref',
  69. 'case',
  70. 'char',
  71. 'Class',
  72. 'const',
  73. 'copy',
  74. 'continue',
  75. 'default',
  76. 'do',
  77. 'double',
  78. 'else',
  79. 'enum',
  80. 'extern',
  81. 'FALSE',
  82. 'false',
  83. 'float',
  84. 'for',
  85. 'goto',
  86. 'if',
  87. 'in',
  88. 'int',
  89. 'id',
  90. 'inout',
  91. 'IMP',
  92. 'long',
  93. 'nil',
  94. 'nonatomic',
  95. 'NULL',
  96. 'oneway',
  97. 'out',
  98. 'private',
  99. 'public',
  100. 'protected',
  101. 'readwrite',
  102. 'readonly',
  103. 'register',
  104. 'return',
  105. 'SEL',
  106. 'self',
  107. 'short',
  108. 'signed',
  109. 'sizeof',
  110. 'static',
  111. 'struct',
  112. 'super',
  113. 'switch',
  114. 'typedef',
  115. 'TRUE',
  116. 'true',
  117. 'union',
  118. 'unsigned',
  119. 'volatile',
  120. 'void',
  121. 'while',
  122. ],
  123. decpart: /\d(_?\d)*/,
  124. decimal: /0|@decpart/,
  125. tokenizer: {
  126. root: [
  127. { include: '@comments' },
  128. { include: '@whitespace' },
  129. { include: '@numbers' },
  130. { include: '@strings' },
  131. [/[,:;]/, 'delimiter'],
  132. [/[{}\[\]()<>]/, '@brackets'],
  133. [/[a-zA-Z@#]\w*/, {
  134. cases: {
  135. '@keywords': 'keyword',
  136. '@default': 'identifier'
  137. }
  138. }],
  139. [/[<>=\\+\\-\\*\\/\\^\\|\\~,]|and\\b|or\\b|not\\b]/, 'operator'],
  140. ],
  141. whitespace: [
  142. [/\s+/, 'white'],
  143. ],
  144. comments: [
  145. ['\\/\\*', 'comment', '@comment'],
  146. ['\\/\\/+.*', 'comment'],
  147. ],
  148. comment: [
  149. ['\\*\\/', 'comment', '@pop'],
  150. ['.', 'comment',],
  151. ],
  152. numbers: [
  153. [/0[xX][0-9a-fA-F]*(_?[0-9a-fA-F])*/, 'number.hex'],
  154. [/@decimal((\.@decpart)?([eE][\-+]?@decpart)?)[fF]*/, {
  155. cases: {
  156. '(\\d)*': 'number',
  157. '$0': 'number.float'
  158. }
  159. }]
  160. ],
  161. // Recognize strings, including those broken across lines with \ (but not without)
  162. strings: [
  163. [/'$/, 'string.escape', '@popall'],
  164. [/'/, 'string.escape', '@stringBody'],
  165. [/"$/, 'string.escape', '@popall'],
  166. [/"/, 'string.escape', '@dblStringBody']
  167. ],
  168. stringBody: [
  169. [/[^\\']+$/, 'string', '@popall'],
  170. [/[^\\']+/, 'string'],
  171. [/\\./, 'string'],
  172. [/'/, 'string.escape', '@popall'],
  173. [/\\$/, 'string']
  174. ],
  175. dblStringBody: [
  176. [/[^\\"]+$/, 'string', '@popall'],
  177. [/[^\\"]+/, 'string'],
  178. [/\\./, 'string'],
  179. [/"/, 'string.escape', '@popall'],
  180. [/\\$/, 'string']
  181. ]
  182. }
  183. };
  184. });