cpp.test.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  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. 'use strict';
  6. import { testTokenization } from '../test/testRunner';
  7. testTokenization('cpp', [
  8. // Keywords
  9. [{
  10. line: 'int _tmain(int argc, _TCHAR* argv[])',
  11. tokens: [
  12. { startIndex: 0, type: 'keyword.int.cpp' },
  13. { startIndex: 3, type: '' },
  14. { startIndex: 4, type: 'identifier.cpp' },
  15. { startIndex: 10, type: 'delimiter.parenthesis.cpp' },
  16. { startIndex: 11, type: 'keyword.int.cpp' },
  17. { startIndex: 14, type: '' },
  18. { startIndex: 15, type: 'identifier.cpp' },
  19. { startIndex: 19, type: 'delimiter.cpp' },
  20. { startIndex: 20, type: '' },
  21. { startIndex: 21, type: 'identifier.cpp' },
  22. { startIndex: 27, type: 'delimiter.cpp' },
  23. { startIndex: 28, type: '' },
  24. { startIndex: 29, type: 'identifier.cpp' },
  25. { startIndex: 33, type: 'delimiter.square.cpp' },
  26. { startIndex: 35, type: 'delimiter.parenthesis.cpp' }
  27. ]
  28. }],
  29. // Comments - single line
  30. [{
  31. line: '//',
  32. tokens: [
  33. { startIndex: 0, type: 'comment.cpp' }
  34. ]
  35. }],
  36. [{
  37. line: ' // a comment',
  38. tokens: [
  39. { startIndex: 0, type: '' },
  40. { startIndex: 4, type: 'comment.cpp' }
  41. ]
  42. }],
  43. [{
  44. line: '// a comment',
  45. tokens: [
  46. { startIndex: 0, type: 'comment.cpp' }
  47. ]
  48. }],
  49. [{
  50. line: '//sticky comment',
  51. tokens: [
  52. { startIndex: 0, type: 'comment.cpp' }
  53. ]
  54. }],
  55. [{
  56. line: '/almost a comment',
  57. tokens: [
  58. { startIndex: 0, type: 'delimiter.cpp' },
  59. { startIndex: 1, type: 'identifier.cpp' },
  60. { startIndex: 7, type: '' },
  61. { startIndex: 8, type: 'identifier.cpp' },
  62. { startIndex: 9, type: '' },
  63. { startIndex: 10, type: 'identifier.cpp' }
  64. ]
  65. }],
  66. [{
  67. line: '/* //*/ a',
  68. tokens: [
  69. { startIndex: 0, type: 'comment.cpp' },
  70. { startIndex: 7, type: '' },
  71. { startIndex: 8, type: 'identifier.cpp' }
  72. ]
  73. }],
  74. [{
  75. line: '1 / 2; /* comment',
  76. tokens: [
  77. { startIndex: 0, type: 'number.cpp' },
  78. { startIndex: 1, type: '' },
  79. { startIndex: 2, type: 'delimiter.cpp' },
  80. { startIndex: 3, type: '' },
  81. { startIndex: 4, type: 'number.cpp' },
  82. { startIndex: 5, type: 'delimiter.cpp' },
  83. { startIndex: 6, type: '' },
  84. { startIndex: 7, type: 'comment.cpp' }
  85. ]
  86. }],
  87. [{
  88. line: 'int x = 1; // my comment // is a nice one',
  89. tokens: [
  90. { startIndex: 0, type: 'keyword.int.cpp' },
  91. { startIndex: 3, type: '' },
  92. { startIndex: 4, type: 'identifier.cpp' },
  93. { startIndex: 5, type: '' },
  94. { startIndex: 6, type: 'delimiter.cpp' },
  95. { startIndex: 7, type: '' },
  96. { startIndex: 8, type: 'number.cpp' },
  97. { startIndex: 9, type: 'delimiter.cpp' },
  98. { startIndex: 10, type: '' },
  99. { startIndex: 11, type: 'comment.cpp' }
  100. ]
  101. }],
  102. // Comments - range comment, single line
  103. [{
  104. line: '/* a simple comment */',
  105. tokens: [
  106. { startIndex: 0, type: 'comment.cpp' }
  107. ]
  108. }],
  109. [{
  110. line: 'int x = /* a simple comment */ 1;',
  111. tokens: [
  112. { startIndex: 0, type: 'keyword.int.cpp' },
  113. { startIndex: 3, type: '' },
  114. { startIndex: 4, type: 'identifier.cpp' },
  115. { startIndex: 5, type: '' },
  116. { startIndex: 6, type: 'delimiter.cpp' },
  117. { startIndex: 7, type: '' },
  118. { startIndex: 8, type: 'comment.cpp' },
  119. { startIndex: 30, type: '' },
  120. { startIndex: 31, type: 'number.cpp' },
  121. { startIndex: 32, type: 'delimiter.cpp' }
  122. ]
  123. }],
  124. [{
  125. line: 'int x = /* comment */ 1; */',
  126. tokens: [
  127. { startIndex: 0, type: 'keyword.int.cpp' },
  128. { startIndex: 3, type: '' },
  129. { startIndex: 4, type: 'identifier.cpp' },
  130. { startIndex: 5, type: '' },
  131. { startIndex: 6, type: 'delimiter.cpp' },
  132. { startIndex: 7, type: '' },
  133. { startIndex: 8, type: 'comment.cpp' },
  134. { startIndex: 21, type: '' },
  135. { startIndex: 22, type: 'number.cpp' },
  136. { startIndex: 23, type: 'delimiter.cpp' },
  137. { startIndex: 24, type: '' }
  138. ]
  139. }],
  140. [{
  141. line: 'x = /**/;',
  142. tokens: [
  143. { startIndex: 0, type: 'identifier.cpp' },
  144. { startIndex: 1, type: '' },
  145. { startIndex: 2, type: 'delimiter.cpp' },
  146. { startIndex: 3, type: '' },
  147. { startIndex: 4, type: 'comment.cpp' },
  148. { startIndex: 8, type: 'delimiter.cpp' }
  149. ]
  150. }],
  151. [{
  152. line: 'x = /*/;',
  153. tokens: [
  154. { startIndex: 0, type: 'identifier.cpp' },
  155. { startIndex: 1, type: '' },
  156. { startIndex: 2, type: 'delimiter.cpp' },
  157. { startIndex: 3, type: '' },
  158. { startIndex: 4, type: 'comment.cpp' }
  159. ]
  160. }],
  161. // Numbers
  162. [{
  163. line: '0',
  164. tokens: [
  165. { startIndex: 0, type: 'number.cpp' }
  166. ]
  167. }],
  168. [{
  169. line: '12l',
  170. tokens: [
  171. { startIndex: 0, type: 'number.cpp' }
  172. ]
  173. }],
  174. [{
  175. line: '34U',
  176. tokens: [
  177. { startIndex: 0, type: 'number.cpp' }
  178. ]
  179. }],
  180. [{
  181. line: '55LL',
  182. tokens: [
  183. { startIndex: 0, type: 'number.cpp' }
  184. ]
  185. }],
  186. [{
  187. line: '34ul',
  188. tokens: [
  189. { startIndex: 0, type: 'number.cpp' }
  190. ]
  191. }],
  192. [{
  193. line: '55llU',
  194. tokens: [
  195. { startIndex: 0, type: 'number.cpp' }
  196. ]
  197. }],
  198. [{
  199. line: '5\'5llU',
  200. tokens: [
  201. { startIndex: 0, type: 'number.cpp' }
  202. ]
  203. }],
  204. [{
  205. line: '100\'000\'000',
  206. tokens: [
  207. { startIndex: 0, type: 'number.cpp' }
  208. ]
  209. }],
  210. [{
  211. line: '0x100\'aafllU',
  212. tokens: [
  213. { startIndex: 0, type: 'number.hex.cpp' }
  214. ]
  215. }],
  216. [{
  217. line: '0342\'325',
  218. tokens: [
  219. { startIndex: 0, type: 'number.octal.cpp' }
  220. ]
  221. }],
  222. [{
  223. line: '0x123',
  224. tokens: [
  225. { startIndex: 0, type: 'number.hex.cpp' }
  226. ]
  227. }],
  228. [{
  229. line: '23.5',
  230. tokens: [
  231. { startIndex: 0, type: 'number.float.cpp' }
  232. ]
  233. }],
  234. [{
  235. line: '23.5e3',
  236. tokens: [
  237. { startIndex: 0, type: 'number.float.cpp' }
  238. ]
  239. }],
  240. [{
  241. line: '23.5E3',
  242. tokens: [
  243. { startIndex: 0, type: 'number.float.cpp' }
  244. ]
  245. }],
  246. [{
  247. line: '23.5F',
  248. tokens: [
  249. { startIndex: 0, type: 'number.float.cpp' }
  250. ]
  251. }],
  252. [{
  253. line: '23.5f',
  254. tokens: [
  255. { startIndex: 0, type: 'number.float.cpp' }
  256. ]
  257. }],
  258. [{
  259. line: '1.72E3F',
  260. tokens: [
  261. { startIndex: 0, type: 'number.float.cpp' }
  262. ]
  263. }],
  264. [{
  265. line: '1.72E3f',
  266. tokens: [
  267. { startIndex: 0, type: 'number.float.cpp' }
  268. ]
  269. }],
  270. [{
  271. line: '1.72e3F',
  272. tokens: [
  273. { startIndex: 0, type: 'number.float.cpp' }
  274. ]
  275. }],
  276. [{
  277. line: '1.72e3f',
  278. tokens: [
  279. { startIndex: 0, type: 'number.float.cpp' }
  280. ]
  281. }],
  282. [{
  283. line: '23.5L',
  284. tokens: [
  285. { startIndex: 0, type: 'number.float.cpp' }
  286. ]
  287. }],
  288. [{
  289. line: '23.5l',
  290. tokens: [
  291. { startIndex: 0, type: 'number.float.cpp' }
  292. ]
  293. }],
  294. [{
  295. line: '1.72E3L',
  296. tokens: [
  297. { startIndex: 0, type: 'number.float.cpp' }
  298. ]
  299. }],
  300. [{
  301. line: '1.72E3l',
  302. tokens: [
  303. { startIndex: 0, type: 'number.float.cpp' }
  304. ]
  305. }],
  306. [{
  307. line: '1.72e3L',
  308. tokens: [
  309. { startIndex: 0, type: 'number.float.cpp' }
  310. ]
  311. }],
  312. [{
  313. line: '1.72e3l',
  314. tokens: [
  315. { startIndex: 0, type: 'number.float.cpp' }
  316. ]
  317. }],
  318. [{
  319. line: '0+0',
  320. tokens: [
  321. { startIndex: 0, type: 'number.cpp' },
  322. { startIndex: 1, type: 'delimiter.cpp' },
  323. { startIndex: 2, type: 'number.cpp' }
  324. ]
  325. }],
  326. [{
  327. line: '100+10',
  328. tokens: [
  329. { startIndex: 0, type: 'number.cpp' },
  330. { startIndex: 3, type: 'delimiter.cpp' },
  331. { startIndex: 4, type: 'number.cpp' }
  332. ]
  333. }],
  334. [{
  335. line: '0 + 0',
  336. tokens: [
  337. { startIndex: 0, type: 'number.cpp' },
  338. { startIndex: 1, type: '' },
  339. { startIndex: 2, type: 'delimiter.cpp' },
  340. { startIndex: 3, type: '' },
  341. { startIndex: 4, type: 'number.cpp' }
  342. ]
  343. }],
  344. // Monarch Generated
  345. [{
  346. line: '#include<iostream>',
  347. tokens: [
  348. { startIndex: 0, type: 'keyword.directive.include.cpp' },
  349. { startIndex: 8, type: 'keyword.directive.include.begin.cpp' },
  350. { startIndex: 9, type: 'string.include.identifier.cpp' },
  351. { startIndex: 17, type: 'keyword.directive.include.end.cpp' }
  352. ]
  353. }, {
  354. line: '#include "/path/to/my/file.h"',
  355. tokens: [
  356. { startIndex: 0, type: 'keyword.directive.include.cpp' },
  357. { startIndex: 8, type: '' },
  358. { startIndex: 9, type: 'keyword.directive.include.begin.cpp' },
  359. { startIndex: 10, type: 'string.include.identifier.cpp' },
  360. { startIndex: 28, type: 'keyword.directive.include.end.cpp' }
  361. ]
  362. }, {
  363. line: '',
  364. tokens: [
  365. ]
  366. }, {
  367. line: '#ifdef VAR',
  368. tokens: [
  369. { startIndex: 0, type: 'keyword.cpp' },
  370. { startIndex: 6, type: '' },
  371. { startIndex: 7, type: 'identifier.cpp' }
  372. ]
  373. }, {
  374. line: '#define SUM(A,B) (A) + (B)',
  375. tokens: [
  376. { startIndex: 0, type: 'keyword.cpp' },
  377. { startIndex: 7, type: '' },
  378. { startIndex: 8, type: 'identifier.cpp' },
  379. { startIndex: 11, type: 'delimiter.parenthesis.cpp' },
  380. { startIndex: 12, type: 'identifier.cpp' },
  381. { startIndex: 13, type: 'delimiter.cpp' },
  382. { startIndex: 14, type: 'identifier.cpp' },
  383. { startIndex: 15, type: 'delimiter.parenthesis.cpp' },
  384. { startIndex: 16, type: '' },
  385. { startIndex: 17, type: 'delimiter.parenthesis.cpp' },
  386. { startIndex: 18, type: 'identifier.cpp' },
  387. { startIndex: 19, type: 'delimiter.parenthesis.cpp' },
  388. { startIndex: 20, type: '' },
  389. { startIndex: 21, type: 'delimiter.cpp' },
  390. { startIndex: 22, type: '' },
  391. { startIndex: 23, type: 'delimiter.parenthesis.cpp' },
  392. { startIndex: 24, type: 'identifier.cpp' },
  393. { startIndex: 25, type: 'delimiter.parenthesis.cpp' }
  394. ]
  395. }, {
  396. line: '',
  397. tokens: [
  398. ]
  399. }, {
  400. line: 'int main(int argc, char** argv)',
  401. tokens: [
  402. { startIndex: 0, type: 'keyword.int.cpp' },
  403. { startIndex: 3, type: '' },
  404. { startIndex: 4, type: 'identifier.cpp' },
  405. { startIndex: 8, type: 'delimiter.parenthesis.cpp' },
  406. { startIndex: 9, type: 'keyword.int.cpp' },
  407. { startIndex: 12, type: '' },
  408. { startIndex: 13, type: 'identifier.cpp' },
  409. { startIndex: 17, type: 'delimiter.cpp' },
  410. { startIndex: 18, type: '' },
  411. { startIndex: 19, type: 'keyword.char.cpp' },
  412. { startIndex: 23, type: '' },
  413. { startIndex: 26, type: 'identifier.cpp' },
  414. { startIndex: 30, type: 'delimiter.parenthesis.cpp' }
  415. ]
  416. }, {
  417. line: '{',
  418. tokens: [
  419. { startIndex: 0, type: 'delimiter.curly.cpp' }
  420. ]
  421. }, {
  422. line: ' return 0;',
  423. tokens: [
  424. { startIndex: 0, type: '' },
  425. { startIndex: 1, type: 'keyword.return.cpp' },
  426. { startIndex: 7, type: '' },
  427. { startIndex: 8, type: 'number.cpp' },
  428. { startIndex: 9, type: 'delimiter.cpp' }
  429. ]
  430. }, {
  431. line: '}',
  432. tokens: [
  433. { startIndex: 0, type: 'delimiter.curly.cpp' }
  434. ]
  435. }, {
  436. line: '',
  437. tokens: [
  438. ]
  439. }, {
  440. line: 'namespace TestSpace',
  441. tokens: [
  442. { startIndex: 0, type: 'keyword.namespace.cpp' },
  443. { startIndex: 9, type: '' },
  444. { startIndex: 10, type: 'identifier.cpp' }
  445. ]
  446. }, {
  447. line: '{',
  448. tokens: [
  449. { startIndex: 0, type: 'delimiter.curly.cpp' }
  450. ]
  451. }, {
  452. line: ' using Asdf.CDE;',
  453. tokens: [
  454. { startIndex: 0, type: '' },
  455. { startIndex: 1, type: 'keyword.using.cpp' },
  456. { startIndex: 6, type: '' },
  457. { startIndex: 7, type: 'identifier.cpp' },
  458. { startIndex: 11, type: 'delimiter.cpp' },
  459. { startIndex: 12, type: 'identifier.cpp' },
  460. { startIndex: 15, type: 'delimiter.cpp' }
  461. ]
  462. }, {
  463. line: ' template <typename T>',
  464. tokens: [
  465. { startIndex: 0, type: '' },
  466. { startIndex: 1, type: 'keyword.template.cpp' },
  467. { startIndex: 9, type: '' },
  468. { startIndex: 10, type: 'delimiter.angle.cpp' },
  469. { startIndex: 11, type: 'keyword.typename.cpp' },
  470. { startIndex: 19, type: '' },
  471. { startIndex: 20, type: 'identifier.cpp' },
  472. { startIndex: 21, type: 'delimiter.angle.cpp' }
  473. ]
  474. }, {
  475. line: ' class CoolClass : protected BaseClass',
  476. tokens: [
  477. { startIndex: 0, type: '' },
  478. { startIndex: 1, type: 'keyword.class.cpp' },
  479. { startIndex: 6, type: '' },
  480. { startIndex: 7, type: 'identifier.cpp' },
  481. { startIndex: 16, type: '' },
  482. { startIndex: 17, type: 'delimiter.cpp' },
  483. { startIndex: 18, type: '' },
  484. { startIndex: 19, type: 'keyword.protected.cpp' },
  485. { startIndex: 28, type: '' },
  486. { startIndex: 29, type: 'identifier.cpp' }
  487. ]
  488. }, {
  489. line: ' {',
  490. tokens: [
  491. { startIndex: 0, type: '' },
  492. { startIndex: 1, type: 'delimiter.curly.cpp' }
  493. ]
  494. }, {
  495. line: ' private:',
  496. tokens: [
  497. { startIndex: 0, type: '' },
  498. { startIndex: 2, type: 'keyword.private.cpp' },
  499. { startIndex: 9, type: 'delimiter.cpp' }
  500. ]
  501. }, {
  502. line: ' ',
  503. tokens: [
  504. { startIndex: 0, type: '' }
  505. ]
  506. }, {
  507. line: ' static T field;',
  508. tokens: [
  509. { startIndex: 0, type: '' },
  510. { startIndex: 2, type: 'keyword.static.cpp' },
  511. { startIndex: 8, type: '' },
  512. { startIndex: 9, type: 'identifier.cpp' },
  513. { startIndex: 10, type: '' },
  514. { startIndex: 11, type: 'identifier.cpp' },
  515. { startIndex: 16, type: 'delimiter.cpp' }
  516. ]
  517. }, {
  518. line: ' ',
  519. tokens: [
  520. { startIndex: 0, type: '' }
  521. ]
  522. }, {
  523. line: ' public:',
  524. tokens: [
  525. { startIndex: 0, type: '' },
  526. { startIndex: 2, type: 'keyword.public.cpp' },
  527. { startIndex: 8, type: 'delimiter.cpp' }
  528. ]
  529. }, {
  530. line: ' ',
  531. tokens: [
  532. { startIndex: 0, type: '' }
  533. ]
  534. }, {
  535. line: ' [[deprecated]]',
  536. tokens: [
  537. { startIndex: 0, type: '' },
  538. { startIndex: 2, type: 'annotation.cpp' }
  539. ]
  540. }, {
  541. line: ' foo method() const override',
  542. tokens: [
  543. { startIndex: 0, type: '' },
  544. { startIndex: 2, type: 'identifier.cpp' },
  545. { startIndex: 5, type: '' },
  546. { startIndex: 6, type: 'identifier.cpp' },
  547. { startIndex: 12, type: 'delimiter.parenthesis.cpp' },
  548. { startIndex: 14, type: '' },
  549. { startIndex: 15, type: 'keyword.const.cpp' },
  550. { startIndex: 20, type: '' },
  551. { startIndex: 21, type: 'keyword.override.cpp' }
  552. ]
  553. }, {
  554. line: ' {',
  555. tokens: [
  556. { startIndex: 0, type: '' },
  557. { startIndex: 2, type: 'delimiter.curly.cpp' }
  558. ]
  559. }, {
  560. line: ' auto s = new Bar();',
  561. tokens: [
  562. { startIndex: 0, type: '' },
  563. { startIndex: 3, type: 'keyword.auto.cpp' },
  564. { startIndex: 7, type: '' },
  565. { startIndex: 8, type: 'identifier.cpp' },
  566. { startIndex: 9, type: '' },
  567. { startIndex: 10, type: 'delimiter.cpp' },
  568. { startIndex: 11, type: '' },
  569. { startIndex: 12, type: 'keyword.new.cpp' },
  570. { startIndex: 15, type: '' },
  571. { startIndex: 16, type: 'identifier.cpp' },
  572. { startIndex: 19, type: 'delimiter.parenthesis.cpp' },
  573. { startIndex: 21, type: 'delimiter.cpp' }
  574. ]
  575. }, {
  576. line: ' ',
  577. tokens: [
  578. { startIndex: 0, type: '' }
  579. ]
  580. }, {
  581. line: ' if (s.field) {',
  582. tokens: [
  583. { startIndex: 0, type: '' },
  584. { startIndex: 3, type: 'keyword.if.cpp' },
  585. { startIndex: 5, type: '' },
  586. { startIndex: 6, type: 'delimiter.parenthesis.cpp' },
  587. { startIndex: 7, type: 'identifier.cpp' },
  588. { startIndex: 8, type: 'delimiter.cpp' },
  589. { startIndex: 9, type: 'identifier.cpp' },
  590. { startIndex: 14, type: 'delimiter.parenthesis.cpp' },
  591. { startIndex: 15, type: '' },
  592. { startIndex: 16, type: 'delimiter.curly.cpp' }
  593. ]
  594. }, {
  595. line: ' for(const auto & b : s.field) {',
  596. tokens: [
  597. { startIndex: 0, type: '' },
  598. { startIndex: 4, type: 'keyword.for.cpp' },
  599. { startIndex: 7, type: 'delimiter.parenthesis.cpp' },
  600. { startIndex: 8, type: 'keyword.const.cpp' },
  601. { startIndex: 13, type: '' },
  602. { startIndex: 14, type: 'keyword.auto.cpp' },
  603. { startIndex: 18, type: '' },
  604. { startIndex: 19, type: 'delimiter.cpp' },
  605. { startIndex: 20, type: '' },
  606. { startIndex: 21, type: 'identifier.cpp' },
  607. { startIndex: 22, type: '' },
  608. { startIndex: 23, type: 'delimiter.cpp' },
  609. { startIndex: 24, type: '' },
  610. { startIndex: 25, type: 'identifier.cpp' },
  611. { startIndex: 26, type: 'delimiter.cpp' },
  612. { startIndex: 27, type: 'identifier.cpp' },
  613. { startIndex: 32, type: 'delimiter.parenthesis.cpp' },
  614. { startIndex: 33, type: '' },
  615. { startIndex: 34, type: 'delimiter.curly.cpp' }
  616. ]
  617. }, {
  618. line: ' break;',
  619. tokens: [
  620. { startIndex: 0, type: '' },
  621. { startIndex: 5, type: 'keyword.break.cpp' },
  622. { startIndex: 10, type: 'delimiter.cpp' }
  623. ]
  624. }, {
  625. line: ' }',
  626. tokens: [
  627. { startIndex: 0, type: '' },
  628. { startIndex: 4, type: 'delimiter.curly.cpp' }
  629. ]
  630. }, {
  631. line: ' }',
  632. tokens: [
  633. { startIndex: 0, type: '' },
  634. { startIndex: 3, type: 'delimiter.curly.cpp' }
  635. ]
  636. }, {
  637. line: ' }',
  638. tokens: [
  639. { startIndex: 0, type: '' },
  640. { startIndex: 2, type: 'delimiter.curly.cpp' }
  641. ]
  642. }, {
  643. line: ' ',
  644. tokens: [
  645. { startIndex: 0, type: '' }
  646. ]
  647. }, {
  648. line: ' std::string s = "hello wordld\\n";',
  649. tokens: [
  650. { startIndex: 0, type: '' },
  651. { startIndex: 2, type: 'identifier.cpp' },
  652. { startIndex: 5, type: '' },
  653. { startIndex: 7, type: 'identifier.cpp' },
  654. { startIndex: 13, type: '' },
  655. { startIndex: 14, type: 'identifier.cpp' },
  656. { startIndex: 15, type: '' },
  657. { startIndex: 16, type: 'delimiter.cpp' },
  658. { startIndex: 17, type: '' },
  659. { startIndex: 18, type: 'string.cpp' },
  660. { startIndex: 31, type: 'string.escape.cpp' },
  661. { startIndex: 33, type: 'string.cpp' },
  662. { startIndex: 34, type: 'delimiter.cpp' }
  663. ]
  664. }, {
  665. line: ' ',
  666. tokens: [
  667. { startIndex: 0, type: '' }
  668. ]
  669. }, {
  670. line: ' int number = 123\'123\'123Ull;',
  671. tokens: [
  672. { startIndex: 0, type: '' },
  673. { startIndex: 2, type: 'keyword.int.cpp' },
  674. { startIndex: 5, type: '' },
  675. { startIndex: 6, type: 'identifier.cpp' },
  676. { startIndex: 12, type: '' },
  677. { startIndex: 13, type: 'delimiter.cpp' },
  678. { startIndex: 14, type: '' },
  679. { startIndex: 15, type: 'number.cpp' },
  680. { startIndex: 29, type: 'delimiter.cpp' }
  681. ]
  682. }, {
  683. line: ' }',
  684. tokens: [
  685. { startIndex: 0, type: '' },
  686. { startIndex: 1, type: 'delimiter.curly.cpp' }
  687. ]
  688. }, {
  689. line: '}',
  690. tokens: [
  691. { startIndex: 0, type: 'delimiter.curly.cpp' }
  692. ]
  693. }, {
  694. line: '',
  695. tokens: [
  696. ]
  697. }, {
  698. line: '#endif',
  699. tokens: [
  700. { startIndex: 0, type: 'keyword.cpp' }
  701. ]
  702. }, {
  703. line: '# ifdef VAR',
  704. tokens: [
  705. { startIndex: 0, type: 'keyword.cpp' },
  706. { startIndex: 10, type: '' },
  707. { startIndex: 11, type: 'identifier.cpp' }
  708. ]
  709. }, {
  710. line: '# define SUM(A,B) (A) + (B)',
  711. tokens: [
  712. { startIndex: 0, type: 'keyword.cpp' },
  713. { startIndex: 8, type: '' },
  714. { startIndex: 9, type: 'identifier.cpp' },
  715. { startIndex: 12, type: 'delimiter.parenthesis.cpp' },
  716. { startIndex: 13, type: 'identifier.cpp' },
  717. { startIndex: 14, type: 'delimiter.cpp' },
  718. { startIndex: 15, type: 'identifier.cpp' },
  719. { startIndex: 16, type: 'delimiter.parenthesis.cpp' },
  720. { startIndex: 17, type: '' },
  721. { startIndex: 18, type: 'delimiter.parenthesis.cpp' },
  722. { startIndex: 19, type: 'identifier.cpp' },
  723. { startIndex: 20, type: 'delimiter.parenthesis.cpp' },
  724. { startIndex: 21, type: '' },
  725. { startIndex: 22, type: 'delimiter.cpp' },
  726. { startIndex: 23, type: '' },
  727. { startIndex: 24, type: 'delimiter.parenthesis.cpp' },
  728. { startIndex: 25, type: 'identifier.cpp' },
  729. { startIndex: 26, type: 'delimiter.parenthesis.cpp' }
  730. ]
  731. }, {
  732. line: 'uR"V0G0N(abc)V0G0N"def',
  733. tokens: [
  734. { startIndex: 0, type: 'string.raw.begin.cpp' },
  735. { startIndex: 9, type: 'string.raw.cpp' },
  736. { startIndex: 12, type: 'string.raw.end.cpp' },
  737. { startIndex: 19, type: 'identifier.cpp' }
  738. ]
  739. }]
  740. ]);