cpp.test.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  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 './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.cpp' },
  349. { startIndex: 8, type: 'delimiter.angle.cpp' },
  350. { startIndex: 9, type: 'identifier.cpp' },
  351. { startIndex: 17, type: 'delimiter.angle.cpp' }
  352. ]
  353. }, {
  354. line: '#include "/path/to/my/file.h"',
  355. tokens: [
  356. { startIndex: 0, type: 'keyword.cpp' },
  357. { startIndex: 8, type: '' },
  358. { startIndex: 9, type: 'string.cpp' }
  359. ]
  360. }, {
  361. line: '',
  362. tokens: [
  363. ]
  364. }, {
  365. line: '#ifdef VAR',
  366. tokens: [
  367. { startIndex: 0, type: 'keyword.cpp' },
  368. { startIndex: 6, type: '' },
  369. { startIndex: 7, type: 'identifier.cpp' }
  370. ]
  371. }, {
  372. line: '#define SUM(A,B) (A) + (B)',
  373. tokens: [
  374. { startIndex: 0, type: 'keyword.cpp' },
  375. { startIndex: 7, type: '' },
  376. { startIndex: 8, type: 'identifier.cpp' },
  377. { startIndex: 11, type: 'delimiter.parenthesis.cpp' },
  378. { startIndex: 12, type: 'identifier.cpp' },
  379. { startIndex: 13, type: 'delimiter.cpp' },
  380. { startIndex: 14, type: 'identifier.cpp' },
  381. { startIndex: 15, type: 'delimiter.parenthesis.cpp' },
  382. { startIndex: 16, type: '' },
  383. { startIndex: 17, type: 'delimiter.parenthesis.cpp' },
  384. { startIndex: 18, type: 'identifier.cpp' },
  385. { startIndex: 19, type: 'delimiter.parenthesis.cpp' },
  386. { startIndex: 20, type: '' },
  387. { startIndex: 21, type: 'delimiter.cpp' },
  388. { startIndex: 22, type: '' },
  389. { startIndex: 23, type: 'delimiter.parenthesis.cpp' },
  390. { startIndex: 24, type: 'identifier.cpp' },
  391. { startIndex: 25, type: 'delimiter.parenthesis.cpp' }
  392. ]
  393. }, {
  394. line: '',
  395. tokens: [
  396. ]
  397. }, {
  398. line: 'int main(int argc, char** argv)',
  399. tokens: [
  400. { startIndex: 0, type: 'keyword.int.cpp' },
  401. { startIndex: 3, type: '' },
  402. { startIndex: 4, type: 'identifier.cpp' },
  403. { startIndex: 8, type: 'delimiter.parenthesis.cpp' },
  404. { startIndex: 9, type: 'keyword.int.cpp' },
  405. { startIndex: 12, type: '' },
  406. { startIndex: 13, type: 'identifier.cpp' },
  407. { startIndex: 17, type: 'delimiter.cpp' },
  408. { startIndex: 18, type: '' },
  409. { startIndex: 19, type: 'keyword.char.cpp' },
  410. { startIndex: 23, type: '' },
  411. { startIndex: 26, type: 'identifier.cpp' },
  412. { startIndex: 30, type: 'delimiter.parenthesis.cpp' }
  413. ]
  414. }, {
  415. line: '{',
  416. tokens: [
  417. { startIndex: 0, type: 'delimiter.curly.cpp' }
  418. ]
  419. }, {
  420. line: ' return 0;',
  421. tokens: [
  422. { startIndex: 0, type: '' },
  423. { startIndex: 1, type: 'keyword.return.cpp' },
  424. { startIndex: 7, type: '' },
  425. { startIndex: 8, type: 'number.cpp' },
  426. { startIndex: 9, type: 'delimiter.cpp' }
  427. ]
  428. }, {
  429. line: '}',
  430. tokens: [
  431. { startIndex: 0, type: 'delimiter.curly.cpp' }
  432. ]
  433. }, {
  434. line: '',
  435. tokens: [
  436. ]
  437. }, {
  438. line: 'namespace TestSpace',
  439. tokens: [
  440. { startIndex: 0, type: 'keyword.namespace.cpp' },
  441. { startIndex: 9, type: '' },
  442. { startIndex: 10, type: 'identifier.cpp' }
  443. ]
  444. }, {
  445. line: '{',
  446. tokens: [
  447. { startIndex: 0, type: 'delimiter.curly.cpp' }
  448. ]
  449. }, {
  450. line: ' using Asdf.CDE;',
  451. tokens: [
  452. { startIndex: 0, type: '' },
  453. { startIndex: 1, type: 'keyword.using.cpp' },
  454. { startIndex: 6, type: '' },
  455. { startIndex: 7, type: 'identifier.cpp' },
  456. { startIndex: 11, type: 'delimiter.cpp' },
  457. { startIndex: 12, type: 'identifier.cpp' },
  458. { startIndex: 15, type: 'delimiter.cpp' }
  459. ]
  460. }, {
  461. line: ' template <typename T>',
  462. tokens: [
  463. { startIndex: 0, type: '' },
  464. { startIndex: 1, type: 'keyword.template.cpp' },
  465. { startIndex: 9, type: '' },
  466. { startIndex: 10, type: 'delimiter.angle.cpp' },
  467. { startIndex: 11, type: 'keyword.typename.cpp' },
  468. { startIndex: 19, type: '' },
  469. { startIndex: 20, type: 'identifier.cpp' },
  470. { startIndex: 21, type: 'delimiter.angle.cpp' }
  471. ]
  472. }, {
  473. line: ' class CoolClass : protected BaseClass',
  474. tokens: [
  475. { startIndex: 0, type: '' },
  476. { startIndex: 1, type: 'keyword.class.cpp' },
  477. { startIndex: 6, type: '' },
  478. { startIndex: 7, type: 'identifier.cpp' },
  479. { startIndex: 16, type: '' },
  480. { startIndex: 17, type: 'delimiter.cpp' },
  481. { startIndex: 18, type: '' },
  482. { startIndex: 19, type: 'keyword.protected.cpp' },
  483. { startIndex: 28, type: '' },
  484. { startIndex: 29, type: 'identifier.cpp' }
  485. ]
  486. }, {
  487. line: ' {',
  488. tokens: [
  489. { startIndex: 0, type: '' },
  490. { startIndex: 1, type: 'delimiter.curly.cpp' }
  491. ]
  492. }, {
  493. line: ' private:',
  494. tokens: [
  495. { startIndex: 0, type: '' },
  496. { startIndex: 2, type: 'keyword.private.cpp' },
  497. { startIndex: 9, type: 'delimiter.cpp' }
  498. ]
  499. }, {
  500. line: ' ',
  501. tokens: [
  502. { startIndex: 0, type: '' }
  503. ]
  504. }, {
  505. line: ' static T field;',
  506. tokens: [
  507. { startIndex: 0, type: '' },
  508. { startIndex: 2, type: 'keyword.static.cpp' },
  509. { startIndex: 8, type: '' },
  510. { startIndex: 9, type: 'identifier.cpp' },
  511. { startIndex: 10, type: '' },
  512. { startIndex: 11, type: 'identifier.cpp' },
  513. { startIndex: 16, type: 'delimiter.cpp' }
  514. ]
  515. }, {
  516. line: ' ',
  517. tokens: [
  518. { startIndex: 0, type: '' }
  519. ]
  520. }, {
  521. line: ' public:',
  522. tokens: [
  523. { startIndex: 0, type: '' },
  524. { startIndex: 2, type: 'keyword.public.cpp' },
  525. { startIndex: 8, type: 'delimiter.cpp' }
  526. ]
  527. }, {
  528. line: ' ',
  529. tokens: [
  530. { startIndex: 0, type: '' }
  531. ]
  532. }, {
  533. line: ' [[deprecated]]',
  534. tokens: [
  535. { startIndex: 0, type: '' },
  536. { startIndex: 2, type: 'annotation.cpp' }
  537. ]
  538. }, {
  539. line: ' foo method() const override',
  540. tokens: [
  541. { startIndex: 0, type: '' },
  542. { startIndex: 2, type: 'identifier.cpp' },
  543. { startIndex: 5, type: '' },
  544. { startIndex: 6, type: 'identifier.cpp' },
  545. { startIndex: 12, type: 'delimiter.parenthesis.cpp' },
  546. { startIndex: 14, type: '' },
  547. { startIndex: 15, type: 'keyword.const.cpp' },
  548. { startIndex: 20, type: '' },
  549. { startIndex: 21, type: 'keyword.override.cpp' }
  550. ]
  551. }, {
  552. line: ' {',
  553. tokens: [
  554. { startIndex: 0, type: '' },
  555. { startIndex: 2, type: 'delimiter.curly.cpp' }
  556. ]
  557. }, {
  558. line: ' auto s = new Bar();',
  559. tokens: [
  560. { startIndex: 0, type: '' },
  561. { startIndex: 3, type: 'keyword.auto.cpp' },
  562. { startIndex: 7, type: '' },
  563. { startIndex: 8, type: 'identifier.cpp' },
  564. { startIndex: 9, type: '' },
  565. { startIndex: 10, type: 'delimiter.cpp' },
  566. { startIndex: 11, type: '' },
  567. { startIndex: 12, type: 'keyword.new.cpp' },
  568. { startIndex: 15, type: '' },
  569. { startIndex: 16, type: 'identifier.cpp' },
  570. { startIndex: 19, type: 'delimiter.parenthesis.cpp' },
  571. { startIndex: 21, type: 'delimiter.cpp' }
  572. ]
  573. }, {
  574. line: ' ',
  575. tokens: [
  576. { startIndex: 0, type: '' }
  577. ]
  578. }, {
  579. line: ' if (s.field) {',
  580. tokens: [
  581. { startIndex: 0, type: '' },
  582. { startIndex: 3, type: 'keyword.if.cpp' },
  583. { startIndex: 5, type: '' },
  584. { startIndex: 6, type: 'delimiter.parenthesis.cpp' },
  585. { startIndex: 7, type: 'identifier.cpp' },
  586. { startIndex: 8, type: 'delimiter.cpp' },
  587. { startIndex: 9, type: 'identifier.cpp' },
  588. { startIndex: 14, type: 'delimiter.parenthesis.cpp' },
  589. { startIndex: 15, type: '' },
  590. { startIndex: 16, type: 'delimiter.curly.cpp' }
  591. ]
  592. }, {
  593. line: ' for(const auto & b : s.field) {',
  594. tokens: [
  595. { startIndex: 0, type: '' },
  596. { startIndex: 4, type: 'keyword.for.cpp' },
  597. { startIndex: 7, type: 'delimiter.parenthesis.cpp' },
  598. { startIndex: 8, type: 'keyword.const.cpp' },
  599. { startIndex: 13, type: '' },
  600. { startIndex: 14, type: 'keyword.auto.cpp' },
  601. { startIndex: 18, type: '' },
  602. { startIndex: 19, type: 'delimiter.cpp' },
  603. { startIndex: 20, type: '' },
  604. { startIndex: 21, type: 'identifier.cpp' },
  605. { startIndex: 22, type: '' },
  606. { startIndex: 23, type: 'delimiter.cpp' },
  607. { startIndex: 24, type: '' },
  608. { startIndex: 25, type: 'identifier.cpp' },
  609. { startIndex: 26, type: 'delimiter.cpp' },
  610. { startIndex: 27, type: 'identifier.cpp' },
  611. { startIndex: 32, type: 'delimiter.parenthesis.cpp' },
  612. { startIndex: 33, type: '' },
  613. { startIndex: 34, type: 'delimiter.curly.cpp' }
  614. ]
  615. }, {
  616. line: ' break;',
  617. tokens: [
  618. { startIndex: 0, type: '' },
  619. { startIndex: 5, type: 'keyword.break.cpp' },
  620. { startIndex: 10, type: 'delimiter.cpp' }
  621. ]
  622. }, {
  623. line: ' }',
  624. tokens: [
  625. { startIndex: 0, type: '' },
  626. { startIndex: 4, type: 'delimiter.curly.cpp' }
  627. ]
  628. }, {
  629. line: ' }',
  630. tokens: [
  631. { startIndex: 0, type: '' },
  632. { startIndex: 3, type: 'delimiter.curly.cpp' }
  633. ]
  634. }, {
  635. line: ' }',
  636. tokens: [
  637. { startIndex: 0, type: '' },
  638. { startIndex: 2, type: 'delimiter.curly.cpp' }
  639. ]
  640. }, {
  641. line: ' ',
  642. tokens: [
  643. { startIndex: 0, type: '' }
  644. ]
  645. }, {
  646. line: ' std::string s = "hello wordld\\n";',
  647. tokens: [
  648. { startIndex: 0, type: '' },
  649. { startIndex: 2, type: 'identifier.cpp' },
  650. { startIndex: 5, type: '' },
  651. { startIndex: 7, type: 'identifier.cpp' },
  652. { startIndex: 13, type: '' },
  653. { startIndex: 14, type: 'identifier.cpp' },
  654. { startIndex: 15, type: '' },
  655. { startIndex: 16, type: 'delimiter.cpp' },
  656. { startIndex: 17, type: '' },
  657. { startIndex: 18, type: 'string.cpp' },
  658. { startIndex: 31, type: 'string.escape.cpp' },
  659. { startIndex: 33, type: 'string.cpp' },
  660. { startIndex: 34, type: 'delimiter.cpp' }
  661. ]
  662. }, {
  663. line: ' ',
  664. tokens: [
  665. { startIndex: 0, type: '' }
  666. ]
  667. }, {
  668. line: ' int number = 123\'123\'123Ull;',
  669. tokens: [
  670. { startIndex: 0, type: '' },
  671. { startIndex: 2, type: 'keyword.int.cpp' },
  672. { startIndex: 5, type: '' },
  673. { startIndex: 6, type: 'identifier.cpp' },
  674. { startIndex: 12, type: '' },
  675. { startIndex: 13, type: 'delimiter.cpp' },
  676. { startIndex: 14, type: '' },
  677. { startIndex: 15, type: 'number.cpp' },
  678. { startIndex: 29, type: 'delimiter.cpp' }
  679. ]
  680. }, {
  681. line: ' }',
  682. tokens: [
  683. { startIndex: 0, type: '' },
  684. { startIndex: 1, type: 'delimiter.curly.cpp' }
  685. ]
  686. }, {
  687. line: '}',
  688. tokens: [
  689. { startIndex: 0, type: 'delimiter.curly.cpp' }
  690. ]
  691. }, {
  692. line: '',
  693. tokens: [
  694. ]
  695. }, {
  696. line: '#endif',
  697. tokens: [
  698. { startIndex: 0, type: 'keyword.cpp' }
  699. ]
  700. }, {
  701. line: '# ifdef VAR',
  702. tokens: [
  703. { startIndex: 0, type: 'keyword.cpp' },
  704. { startIndex: 10, type: '' },
  705. { startIndex: 11, type: 'identifier.cpp' }
  706. ]
  707. }, {
  708. line: '# define SUM(A,B) (A) + (B)',
  709. tokens: [
  710. { startIndex: 0, type: 'keyword.cpp' },
  711. { startIndex: 8, type: '' },
  712. { startIndex: 9, type: 'identifier.cpp' },
  713. { startIndex: 12, type: 'delimiter.parenthesis.cpp' },
  714. { startIndex: 13, type: 'identifier.cpp' },
  715. { startIndex: 14, type: 'delimiter.cpp' },
  716. { startIndex: 15, type: 'identifier.cpp' },
  717. { startIndex: 16, type: 'delimiter.parenthesis.cpp' },
  718. { startIndex: 17, type: '' },
  719. { startIndex: 18, type: 'delimiter.parenthesis.cpp' },
  720. { startIndex: 19, type: 'identifier.cpp' },
  721. { startIndex: 20, type: 'delimiter.parenthesis.cpp' },
  722. { startIndex: 21, type: '' },
  723. { startIndex: 22, type: 'delimiter.cpp' },
  724. { startIndex: 23, type: '' },
  725. { startIndex: 24, type: 'delimiter.parenthesis.cpp' },
  726. { startIndex: 25, type: 'identifier.cpp' },
  727. { startIndex: 26, type: 'delimiter.parenthesis.cpp' }
  728. ]
  729. }]
  730. ]);