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