Lexer.cs 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  1. using System;
  2. using System.IO;
  3. using System.Runtime.CompilerServices;
  4. using System.Text;
  5. namespace LitJson
  6. {
  7. internal class Lexer
  8. {
  9. static Lexer()
  10. {
  11. Lexer.PopulateFsmTables();
  12. }
  13. public Lexer(TextReader reader)
  14. {
  15. this.allow_comments = true;
  16. this.allow_single_quoted_strings = true;
  17. this.input_buffer = 0;
  18. this.string_buffer = new StringBuilder(128);
  19. this.state = 1;
  20. this.end_of_input = false;
  21. this.reader = reader;
  22. this.fsm_context = new FsmContext();
  23. this.fsm_context.L = this;
  24. }
  25. public bool AllowComments
  26. {
  27. get
  28. {
  29. return this.allow_comments;
  30. }
  31. set
  32. {
  33. this.allow_comments = value;
  34. }
  35. }
  36. public bool AllowSingleQuotedStrings
  37. {
  38. get
  39. {
  40. return this.allow_single_quoted_strings;
  41. }
  42. set
  43. {
  44. this.allow_single_quoted_strings = value;
  45. }
  46. }
  47. public bool EndOfInput
  48. {
  49. get
  50. {
  51. return this.end_of_input;
  52. }
  53. }
  54. public int Token
  55. {
  56. get
  57. {
  58. return this.token;
  59. }
  60. }
  61. public string StringValue
  62. {
  63. get
  64. {
  65. return this.string_value;
  66. }
  67. }
  68. private static int HexValue(int digit)
  69. {
  70. switch (digit)
  71. {
  72. case 65:
  73. break;
  74. case 66:
  75. return 11;
  76. case 67:
  77. return 12;
  78. case 68:
  79. return 13;
  80. case 69:
  81. return 14;
  82. case 70:
  83. return 15;
  84. default:
  85. switch (digit)
  86. {
  87. case 97:
  88. break;
  89. case 98:
  90. return 11;
  91. case 99:
  92. return 12;
  93. case 100:
  94. return 13;
  95. case 101:
  96. return 14;
  97. case 102:
  98. return 15;
  99. default:
  100. return digit - 48;
  101. }
  102. break;
  103. }
  104. return 10;
  105. }
  106. private static void PopulateFsmTables()
  107. {
  108. Lexer.StateHandler[] array = new Lexer.StateHandler[28];
  109. int num = 0;
  110. if (Lexer._003C_003Ef__mg_0024cache0 == null)
  111. {
  112. Lexer._003C_003Ef__mg_0024cache0 = new Lexer.StateHandler(Lexer.State1);
  113. }
  114. array[num] = Lexer._003C_003Ef__mg_0024cache0;
  115. int num2 = 1;
  116. if (Lexer._003C_003Ef__mg_0024cache1 == null)
  117. {
  118. Lexer._003C_003Ef__mg_0024cache1 = new Lexer.StateHandler(Lexer.State2);
  119. }
  120. array[num2] = Lexer._003C_003Ef__mg_0024cache1;
  121. int num3 = 2;
  122. if (Lexer._003C_003Ef__mg_0024cache2 == null)
  123. {
  124. Lexer._003C_003Ef__mg_0024cache2 = new Lexer.StateHandler(Lexer.State3);
  125. }
  126. array[num3] = Lexer._003C_003Ef__mg_0024cache2;
  127. int num4 = 3;
  128. if (Lexer._003C_003Ef__mg_0024cache3 == null)
  129. {
  130. Lexer._003C_003Ef__mg_0024cache3 = new Lexer.StateHandler(Lexer.State4);
  131. }
  132. array[num4] = Lexer._003C_003Ef__mg_0024cache3;
  133. int num5 = 4;
  134. if (Lexer._003C_003Ef__mg_0024cache4 == null)
  135. {
  136. Lexer._003C_003Ef__mg_0024cache4 = new Lexer.StateHandler(Lexer.State5);
  137. }
  138. array[num5] = Lexer._003C_003Ef__mg_0024cache4;
  139. int num6 = 5;
  140. if (Lexer._003C_003Ef__mg_0024cache5 == null)
  141. {
  142. Lexer._003C_003Ef__mg_0024cache5 = new Lexer.StateHandler(Lexer.State6);
  143. }
  144. array[num6] = Lexer._003C_003Ef__mg_0024cache5;
  145. int num7 = 6;
  146. if (Lexer._003C_003Ef__mg_0024cache6 == null)
  147. {
  148. Lexer._003C_003Ef__mg_0024cache6 = new Lexer.StateHandler(Lexer.State7);
  149. }
  150. array[num7] = Lexer._003C_003Ef__mg_0024cache6;
  151. int num8 = 7;
  152. if (Lexer._003C_003Ef__mg_0024cache7 == null)
  153. {
  154. Lexer._003C_003Ef__mg_0024cache7 = new Lexer.StateHandler(Lexer.State8);
  155. }
  156. array[num8] = Lexer._003C_003Ef__mg_0024cache7;
  157. int num9 = 8;
  158. if (Lexer._003C_003Ef__mg_0024cache8 == null)
  159. {
  160. Lexer._003C_003Ef__mg_0024cache8 = new Lexer.StateHandler(Lexer.State9);
  161. }
  162. array[num9] = Lexer._003C_003Ef__mg_0024cache8;
  163. int num10 = 9;
  164. if (Lexer._003C_003Ef__mg_0024cache9 == null)
  165. {
  166. Lexer._003C_003Ef__mg_0024cache9 = new Lexer.StateHandler(Lexer.State10);
  167. }
  168. array[num10] = Lexer._003C_003Ef__mg_0024cache9;
  169. int num11 = 10;
  170. if (Lexer._003C_003Ef__mg_0024cacheA == null)
  171. {
  172. Lexer._003C_003Ef__mg_0024cacheA = new Lexer.StateHandler(Lexer.State11);
  173. }
  174. array[num11] = Lexer._003C_003Ef__mg_0024cacheA;
  175. int num12 = 11;
  176. if (Lexer._003C_003Ef__mg_0024cacheB == null)
  177. {
  178. Lexer._003C_003Ef__mg_0024cacheB = new Lexer.StateHandler(Lexer.State12);
  179. }
  180. array[num12] = Lexer._003C_003Ef__mg_0024cacheB;
  181. int num13 = 12;
  182. if (Lexer._003C_003Ef__mg_0024cacheC == null)
  183. {
  184. Lexer._003C_003Ef__mg_0024cacheC = new Lexer.StateHandler(Lexer.State13);
  185. }
  186. array[num13] = Lexer._003C_003Ef__mg_0024cacheC;
  187. int num14 = 13;
  188. if (Lexer._003C_003Ef__mg_0024cacheD == null)
  189. {
  190. Lexer._003C_003Ef__mg_0024cacheD = new Lexer.StateHandler(Lexer.State14);
  191. }
  192. array[num14] = Lexer._003C_003Ef__mg_0024cacheD;
  193. int num15 = 14;
  194. if (Lexer._003C_003Ef__mg_0024cacheE == null)
  195. {
  196. Lexer._003C_003Ef__mg_0024cacheE = new Lexer.StateHandler(Lexer.State15);
  197. }
  198. array[num15] = Lexer._003C_003Ef__mg_0024cacheE;
  199. int num16 = 15;
  200. if (Lexer._003C_003Ef__mg_0024cacheF == null)
  201. {
  202. Lexer._003C_003Ef__mg_0024cacheF = new Lexer.StateHandler(Lexer.State16);
  203. }
  204. array[num16] = Lexer._003C_003Ef__mg_0024cacheF;
  205. int num17 = 16;
  206. if (Lexer._003C_003Ef__mg_0024cache10 == null)
  207. {
  208. Lexer._003C_003Ef__mg_0024cache10 = new Lexer.StateHandler(Lexer.State17);
  209. }
  210. array[num17] = Lexer._003C_003Ef__mg_0024cache10;
  211. int num18 = 17;
  212. if (Lexer._003C_003Ef__mg_0024cache11 == null)
  213. {
  214. Lexer._003C_003Ef__mg_0024cache11 = new Lexer.StateHandler(Lexer.State18);
  215. }
  216. array[num18] = Lexer._003C_003Ef__mg_0024cache11;
  217. int num19 = 18;
  218. if (Lexer._003C_003Ef__mg_0024cache12 == null)
  219. {
  220. Lexer._003C_003Ef__mg_0024cache12 = new Lexer.StateHandler(Lexer.State19);
  221. }
  222. array[num19] = Lexer._003C_003Ef__mg_0024cache12;
  223. int num20 = 19;
  224. if (Lexer._003C_003Ef__mg_0024cache13 == null)
  225. {
  226. Lexer._003C_003Ef__mg_0024cache13 = new Lexer.StateHandler(Lexer.State20);
  227. }
  228. array[num20] = Lexer._003C_003Ef__mg_0024cache13;
  229. int num21 = 20;
  230. if (Lexer._003C_003Ef__mg_0024cache14 == null)
  231. {
  232. Lexer._003C_003Ef__mg_0024cache14 = new Lexer.StateHandler(Lexer.State21);
  233. }
  234. array[num21] = Lexer._003C_003Ef__mg_0024cache14;
  235. int num22 = 21;
  236. if (Lexer._003C_003Ef__mg_0024cache15 == null)
  237. {
  238. Lexer._003C_003Ef__mg_0024cache15 = new Lexer.StateHandler(Lexer.State22);
  239. }
  240. array[num22] = Lexer._003C_003Ef__mg_0024cache15;
  241. int num23 = 22;
  242. if (Lexer._003C_003Ef__mg_0024cache16 == null)
  243. {
  244. Lexer._003C_003Ef__mg_0024cache16 = new Lexer.StateHandler(Lexer.State23);
  245. }
  246. array[num23] = Lexer._003C_003Ef__mg_0024cache16;
  247. int num24 = 23;
  248. if (Lexer._003C_003Ef__mg_0024cache17 == null)
  249. {
  250. Lexer._003C_003Ef__mg_0024cache17 = new Lexer.StateHandler(Lexer.State24);
  251. }
  252. array[num24] = Lexer._003C_003Ef__mg_0024cache17;
  253. int num25 = 24;
  254. if (Lexer._003C_003Ef__mg_0024cache18 == null)
  255. {
  256. Lexer._003C_003Ef__mg_0024cache18 = new Lexer.StateHandler(Lexer.State25);
  257. }
  258. array[num25] = Lexer._003C_003Ef__mg_0024cache18;
  259. int num26 = 25;
  260. if (Lexer._003C_003Ef__mg_0024cache19 == null)
  261. {
  262. Lexer._003C_003Ef__mg_0024cache19 = new Lexer.StateHandler(Lexer.State26);
  263. }
  264. array[num26] = Lexer._003C_003Ef__mg_0024cache19;
  265. int num27 = 26;
  266. if (Lexer._003C_003Ef__mg_0024cache1A == null)
  267. {
  268. Lexer._003C_003Ef__mg_0024cache1A = new Lexer.StateHandler(Lexer.State27);
  269. }
  270. array[num27] = Lexer._003C_003Ef__mg_0024cache1A;
  271. int num28 = 27;
  272. if (Lexer._003C_003Ef__mg_0024cache1B == null)
  273. {
  274. Lexer._003C_003Ef__mg_0024cache1B = new Lexer.StateHandler(Lexer.State28);
  275. }
  276. array[num28] = Lexer._003C_003Ef__mg_0024cache1B;
  277. Lexer.fsm_handler_table = array;
  278. Lexer.fsm_return_table = new int[]
  279. {
  280. 65542,
  281. 0,
  282. 65537,
  283. 65537,
  284. 0,
  285. 65537,
  286. 0,
  287. 65537,
  288. 0,
  289. 0,
  290. 65538,
  291. 0,
  292. 0,
  293. 0,
  294. 65539,
  295. 0,
  296. 0,
  297. 65540,
  298. 65541,
  299. 65542,
  300. 0,
  301. 0,
  302. 65541,
  303. 65542,
  304. 0,
  305. 0,
  306. 0,
  307. 0
  308. };
  309. }
  310. private static char ProcessEscChar(int esc_char)
  311. {
  312. switch (esc_char)
  313. {
  314. case 114:
  315. return '\r';
  316. default:
  317. if (esc_char == 34 || esc_char == 39 || esc_char == 47 || esc_char == 92)
  318. {
  319. return Convert.ToChar(esc_char);
  320. }
  321. if (esc_char == 98)
  322. {
  323. return '\b';
  324. }
  325. if (esc_char == 102)
  326. {
  327. return '\f';
  328. }
  329. if (esc_char != 110)
  330. {
  331. return '?';
  332. }
  333. return '\n';
  334. case 116:
  335. return '\t';
  336. }
  337. }
  338. private static bool State1(FsmContext ctx)
  339. {
  340. while (ctx.L.GetChar())
  341. {
  342. if (ctx.L.input_char != 32 && (ctx.L.input_char < 9 || ctx.L.input_char > 13))
  343. {
  344. if (ctx.L.input_char >= 49 && ctx.L.input_char <= 57)
  345. {
  346. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  347. ctx.NextState = 3;
  348. return true;
  349. }
  350. int num = ctx.L.input_char;
  351. switch (num)
  352. {
  353. case 44:
  354. break;
  355. case 45:
  356. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  357. ctx.NextState = 2;
  358. return true;
  359. default:
  360. switch (num)
  361. {
  362. case 91:
  363. case 93:
  364. break;
  365. default:
  366. switch (num)
  367. {
  368. case 123:
  369. case 125:
  370. break;
  371. default:
  372. if (num == 34)
  373. {
  374. ctx.NextState = 19;
  375. ctx.Return = true;
  376. return true;
  377. }
  378. if (num != 39)
  379. {
  380. if (num != 58)
  381. {
  382. if (num == 102)
  383. {
  384. ctx.NextState = 12;
  385. return true;
  386. }
  387. if (num == 110)
  388. {
  389. ctx.NextState = 16;
  390. return true;
  391. }
  392. if (num != 116)
  393. {
  394. return false;
  395. }
  396. ctx.NextState = 9;
  397. return true;
  398. }
  399. }
  400. else
  401. {
  402. if (!ctx.L.allow_single_quoted_strings)
  403. {
  404. return false;
  405. }
  406. ctx.L.input_char = 34;
  407. ctx.NextState = 23;
  408. ctx.Return = true;
  409. return true;
  410. }
  411. break;
  412. }
  413. break;
  414. }
  415. break;
  416. case 47:
  417. if (!ctx.L.allow_comments)
  418. {
  419. return false;
  420. }
  421. ctx.NextState = 25;
  422. return true;
  423. case 48:
  424. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  425. ctx.NextState = 4;
  426. return true;
  427. }
  428. ctx.NextState = 1;
  429. ctx.Return = true;
  430. return true;
  431. }
  432. }
  433. return true;
  434. }
  435. private static bool State2(FsmContext ctx)
  436. {
  437. ctx.L.GetChar();
  438. if (ctx.L.input_char >= 49 && ctx.L.input_char <= 57)
  439. {
  440. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  441. ctx.NextState = 3;
  442. return true;
  443. }
  444. int num = ctx.L.input_char;
  445. if (num != 48)
  446. {
  447. return false;
  448. }
  449. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  450. ctx.NextState = 4;
  451. return true;
  452. }
  453. private static bool State3(FsmContext ctx)
  454. {
  455. while (ctx.L.GetChar())
  456. {
  457. if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57)
  458. {
  459. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  460. }
  461. else
  462. {
  463. if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13))
  464. {
  465. ctx.Return = true;
  466. ctx.NextState = 1;
  467. return true;
  468. }
  469. int num = ctx.L.input_char;
  470. switch (num)
  471. {
  472. case 44:
  473. break;
  474. default:
  475. if (num != 69)
  476. {
  477. if (num == 93)
  478. {
  479. break;
  480. }
  481. if (num != 101)
  482. {
  483. if (num != 125)
  484. {
  485. return false;
  486. }
  487. break;
  488. }
  489. }
  490. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  491. ctx.NextState = 7;
  492. return true;
  493. case 46:
  494. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  495. ctx.NextState = 5;
  496. return true;
  497. }
  498. ctx.L.UngetChar();
  499. ctx.Return = true;
  500. ctx.NextState = 1;
  501. return true;
  502. }
  503. }
  504. return true;
  505. }
  506. private static bool State4(FsmContext ctx)
  507. {
  508. ctx.L.GetChar();
  509. if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13))
  510. {
  511. ctx.Return = true;
  512. ctx.NextState = 1;
  513. return true;
  514. }
  515. int num = ctx.L.input_char;
  516. switch (num)
  517. {
  518. case 44:
  519. break;
  520. default:
  521. if (num != 69)
  522. {
  523. if (num == 93)
  524. {
  525. break;
  526. }
  527. if (num != 101)
  528. {
  529. if (num != 125)
  530. {
  531. return false;
  532. }
  533. break;
  534. }
  535. }
  536. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  537. ctx.NextState = 7;
  538. return true;
  539. case 46:
  540. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  541. ctx.NextState = 5;
  542. return true;
  543. }
  544. ctx.L.UngetChar();
  545. ctx.Return = true;
  546. ctx.NextState = 1;
  547. return true;
  548. }
  549. private static bool State5(FsmContext ctx)
  550. {
  551. ctx.L.GetChar();
  552. if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57)
  553. {
  554. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  555. ctx.NextState = 6;
  556. return true;
  557. }
  558. return false;
  559. }
  560. private static bool State6(FsmContext ctx)
  561. {
  562. while (ctx.L.GetChar())
  563. {
  564. if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57)
  565. {
  566. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  567. }
  568. else
  569. {
  570. if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13))
  571. {
  572. ctx.Return = true;
  573. ctx.NextState = 1;
  574. return true;
  575. }
  576. int num = ctx.L.input_char;
  577. if (num != 44)
  578. {
  579. if (num != 69)
  580. {
  581. if (num == 93)
  582. {
  583. goto IL_CA;
  584. }
  585. if (num != 101)
  586. {
  587. if (num != 125)
  588. {
  589. return false;
  590. }
  591. goto IL_CA;
  592. }
  593. }
  594. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  595. ctx.NextState = 7;
  596. return true;
  597. }
  598. IL_CA:
  599. ctx.L.UngetChar();
  600. ctx.Return = true;
  601. ctx.NextState = 1;
  602. return true;
  603. }
  604. }
  605. return true;
  606. }
  607. private static bool State7(FsmContext ctx)
  608. {
  609. ctx.L.GetChar();
  610. if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57)
  611. {
  612. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  613. ctx.NextState = 8;
  614. return true;
  615. }
  616. int num = ctx.L.input_char;
  617. if (num != 43 && num != 45)
  618. {
  619. return false;
  620. }
  621. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  622. ctx.NextState = 8;
  623. return true;
  624. }
  625. private static bool State8(FsmContext ctx)
  626. {
  627. while (ctx.L.GetChar())
  628. {
  629. if (ctx.L.input_char >= 48 && ctx.L.input_char <= 57)
  630. {
  631. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  632. }
  633. else
  634. {
  635. if (ctx.L.input_char == 32 || (ctx.L.input_char >= 9 && ctx.L.input_char <= 13))
  636. {
  637. ctx.Return = true;
  638. ctx.NextState = 1;
  639. return true;
  640. }
  641. int num = ctx.L.input_char;
  642. if (num != 44 && num != 93 && num != 125)
  643. {
  644. return false;
  645. }
  646. ctx.L.UngetChar();
  647. ctx.Return = true;
  648. ctx.NextState = 1;
  649. return true;
  650. }
  651. }
  652. return true;
  653. }
  654. private static bool State9(FsmContext ctx)
  655. {
  656. ctx.L.GetChar();
  657. int num = ctx.L.input_char;
  658. if (num != 114)
  659. {
  660. return false;
  661. }
  662. ctx.NextState = 10;
  663. return true;
  664. }
  665. private static bool State10(FsmContext ctx)
  666. {
  667. ctx.L.GetChar();
  668. int num = ctx.L.input_char;
  669. if (num != 117)
  670. {
  671. return false;
  672. }
  673. ctx.NextState = 11;
  674. return true;
  675. }
  676. private static bool State11(FsmContext ctx)
  677. {
  678. ctx.L.GetChar();
  679. int num = ctx.L.input_char;
  680. if (num != 101)
  681. {
  682. return false;
  683. }
  684. ctx.Return = true;
  685. ctx.NextState = 1;
  686. return true;
  687. }
  688. private static bool State12(FsmContext ctx)
  689. {
  690. ctx.L.GetChar();
  691. int num = ctx.L.input_char;
  692. if (num != 97)
  693. {
  694. return false;
  695. }
  696. ctx.NextState = 13;
  697. return true;
  698. }
  699. private static bool State13(FsmContext ctx)
  700. {
  701. ctx.L.GetChar();
  702. int num = ctx.L.input_char;
  703. if (num != 108)
  704. {
  705. return false;
  706. }
  707. ctx.NextState = 14;
  708. return true;
  709. }
  710. private static bool State14(FsmContext ctx)
  711. {
  712. ctx.L.GetChar();
  713. int num = ctx.L.input_char;
  714. if (num != 115)
  715. {
  716. return false;
  717. }
  718. ctx.NextState = 15;
  719. return true;
  720. }
  721. private static bool State15(FsmContext ctx)
  722. {
  723. ctx.L.GetChar();
  724. int num = ctx.L.input_char;
  725. if (num != 101)
  726. {
  727. return false;
  728. }
  729. ctx.Return = true;
  730. ctx.NextState = 1;
  731. return true;
  732. }
  733. private static bool State16(FsmContext ctx)
  734. {
  735. ctx.L.GetChar();
  736. int num = ctx.L.input_char;
  737. if (num != 117)
  738. {
  739. return false;
  740. }
  741. ctx.NextState = 17;
  742. return true;
  743. }
  744. private static bool State17(FsmContext ctx)
  745. {
  746. ctx.L.GetChar();
  747. int num = ctx.L.input_char;
  748. if (num != 108)
  749. {
  750. return false;
  751. }
  752. ctx.NextState = 18;
  753. return true;
  754. }
  755. private static bool State18(FsmContext ctx)
  756. {
  757. ctx.L.GetChar();
  758. int num = ctx.L.input_char;
  759. if (num != 108)
  760. {
  761. return false;
  762. }
  763. ctx.Return = true;
  764. ctx.NextState = 1;
  765. return true;
  766. }
  767. private static bool State19(FsmContext ctx)
  768. {
  769. while (ctx.L.GetChar())
  770. {
  771. int num = ctx.L.input_char;
  772. if (num == 34)
  773. {
  774. ctx.L.UngetChar();
  775. ctx.Return = true;
  776. ctx.NextState = 20;
  777. return true;
  778. }
  779. if (num == 92)
  780. {
  781. ctx.StateStack = 19;
  782. ctx.NextState = 21;
  783. return true;
  784. }
  785. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  786. }
  787. return true;
  788. }
  789. private static bool State20(FsmContext ctx)
  790. {
  791. ctx.L.GetChar();
  792. int num = ctx.L.input_char;
  793. if (num != 34)
  794. {
  795. return false;
  796. }
  797. ctx.Return = true;
  798. ctx.NextState = 1;
  799. return true;
  800. }
  801. private static bool State21(FsmContext ctx)
  802. {
  803. ctx.L.GetChar();
  804. int num = ctx.L.input_char;
  805. switch (num)
  806. {
  807. case 114:
  808. case 116:
  809. break;
  810. default:
  811. if (num != 34 && num != 39 && num != 47 && num != 92 && num != 98 && num != 102 && num != 110)
  812. {
  813. return false;
  814. }
  815. break;
  816. case 117:
  817. ctx.NextState = 22;
  818. return true;
  819. }
  820. ctx.L.string_buffer.Append(Lexer.ProcessEscChar(ctx.L.input_char));
  821. ctx.NextState = ctx.StateStack;
  822. return true;
  823. }
  824. private static bool State22(FsmContext ctx)
  825. {
  826. int num = 0;
  827. int num2 = 4096;
  828. ctx.L.unichar = 0;
  829. while (ctx.L.GetChar())
  830. {
  831. if ((ctx.L.input_char < 48 || ctx.L.input_char > 57) && (ctx.L.input_char < 65 || ctx.L.input_char > 70) && (ctx.L.input_char < 97 || ctx.L.input_char > 102))
  832. {
  833. return false;
  834. }
  835. ctx.L.unichar += Lexer.HexValue(ctx.L.input_char) * num2;
  836. num++;
  837. num2 /= 16;
  838. if (num == 4)
  839. {
  840. ctx.L.string_buffer.Append(Convert.ToChar(ctx.L.unichar));
  841. ctx.NextState = ctx.StateStack;
  842. return true;
  843. }
  844. }
  845. return true;
  846. }
  847. private static bool State23(FsmContext ctx)
  848. {
  849. while (ctx.L.GetChar())
  850. {
  851. int num = ctx.L.input_char;
  852. if (num == 39)
  853. {
  854. ctx.L.UngetChar();
  855. ctx.Return = true;
  856. ctx.NextState = 24;
  857. return true;
  858. }
  859. if (num == 92)
  860. {
  861. ctx.StateStack = 23;
  862. ctx.NextState = 21;
  863. return true;
  864. }
  865. ctx.L.string_buffer.Append((char)ctx.L.input_char);
  866. }
  867. return true;
  868. }
  869. private static bool State24(FsmContext ctx)
  870. {
  871. ctx.L.GetChar();
  872. int num = ctx.L.input_char;
  873. if (num != 39)
  874. {
  875. return false;
  876. }
  877. ctx.L.input_char = 34;
  878. ctx.Return = true;
  879. ctx.NextState = 1;
  880. return true;
  881. }
  882. private static bool State25(FsmContext ctx)
  883. {
  884. ctx.L.GetChar();
  885. int num = ctx.L.input_char;
  886. if (num == 42)
  887. {
  888. ctx.NextState = 27;
  889. return true;
  890. }
  891. if (num != 47)
  892. {
  893. return false;
  894. }
  895. ctx.NextState = 26;
  896. return true;
  897. }
  898. private static bool State26(FsmContext ctx)
  899. {
  900. while (ctx.L.GetChar())
  901. {
  902. if (ctx.L.input_char == 10)
  903. {
  904. ctx.NextState = 1;
  905. return true;
  906. }
  907. }
  908. return true;
  909. }
  910. private static bool State27(FsmContext ctx)
  911. {
  912. while (ctx.L.GetChar())
  913. {
  914. if (ctx.L.input_char == 42)
  915. {
  916. ctx.NextState = 28;
  917. return true;
  918. }
  919. }
  920. return true;
  921. }
  922. private static bool State28(FsmContext ctx)
  923. {
  924. while (ctx.L.GetChar())
  925. {
  926. if (ctx.L.input_char != 42)
  927. {
  928. if (ctx.L.input_char == 47)
  929. {
  930. ctx.NextState = 1;
  931. return true;
  932. }
  933. ctx.NextState = 27;
  934. return true;
  935. }
  936. }
  937. return true;
  938. }
  939. private bool GetChar()
  940. {
  941. if ((this.input_char = this.NextChar()) != -1)
  942. {
  943. return true;
  944. }
  945. this.end_of_input = true;
  946. return false;
  947. }
  948. private int NextChar()
  949. {
  950. if (this.input_buffer != 0)
  951. {
  952. int result = this.input_buffer;
  953. this.input_buffer = 0;
  954. return result;
  955. }
  956. return this.reader.Read();
  957. }
  958. public bool NextToken()
  959. {
  960. this.fsm_context.Return = false;
  961. for (;;)
  962. {
  963. Lexer.StateHandler stateHandler = Lexer.fsm_handler_table[this.state - 1];
  964. if (!stateHandler(this.fsm_context))
  965. {
  966. break;
  967. }
  968. if (this.end_of_input)
  969. {
  970. return false;
  971. }
  972. if (this.fsm_context.Return)
  973. {
  974. goto Block_3;
  975. }
  976. this.state = this.fsm_context.NextState;
  977. }
  978. throw new JsonException(this.input_char);
  979. Block_3:
  980. this.string_value = this.string_buffer.ToString();
  981. this.string_buffer.Remove(0, this.string_buffer.Length);
  982. this.token = Lexer.fsm_return_table[this.state - 1];
  983. if (this.token == 65542)
  984. {
  985. this.token = this.input_char;
  986. }
  987. this.state = this.fsm_context.NextState;
  988. return true;
  989. }
  990. private void UngetChar()
  991. {
  992. this.input_buffer = this.input_char;
  993. }
  994. private static int[] fsm_return_table;
  995. private static Lexer.StateHandler[] fsm_handler_table;
  996. private bool allow_comments;
  997. private bool allow_single_quoted_strings;
  998. private bool end_of_input;
  999. private FsmContext fsm_context;
  1000. private int input_buffer;
  1001. private int input_char;
  1002. private TextReader reader;
  1003. private int state;
  1004. private StringBuilder string_buffer;
  1005. private string string_value;
  1006. private int token;
  1007. private int unichar;
  1008. [CompilerGenerated]
  1009. private static Lexer.StateHandler _003C_003Ef__mg_0024cache0;
  1010. [CompilerGenerated]
  1011. private static Lexer.StateHandler _003C_003Ef__mg_0024cache1;
  1012. [CompilerGenerated]
  1013. private static Lexer.StateHandler _003C_003Ef__mg_0024cache2;
  1014. [CompilerGenerated]
  1015. private static Lexer.StateHandler _003C_003Ef__mg_0024cache3;
  1016. [CompilerGenerated]
  1017. private static Lexer.StateHandler _003C_003Ef__mg_0024cache4;
  1018. [CompilerGenerated]
  1019. private static Lexer.StateHandler _003C_003Ef__mg_0024cache5;
  1020. [CompilerGenerated]
  1021. private static Lexer.StateHandler _003C_003Ef__mg_0024cache6;
  1022. [CompilerGenerated]
  1023. private static Lexer.StateHandler _003C_003Ef__mg_0024cache7;
  1024. [CompilerGenerated]
  1025. private static Lexer.StateHandler _003C_003Ef__mg_0024cache8;
  1026. [CompilerGenerated]
  1027. private static Lexer.StateHandler _003C_003Ef__mg_0024cache9;
  1028. [CompilerGenerated]
  1029. private static Lexer.StateHandler _003C_003Ef__mg_0024cacheA;
  1030. [CompilerGenerated]
  1031. private static Lexer.StateHandler _003C_003Ef__mg_0024cacheB;
  1032. [CompilerGenerated]
  1033. private static Lexer.StateHandler _003C_003Ef__mg_0024cacheC;
  1034. [CompilerGenerated]
  1035. private static Lexer.StateHandler _003C_003Ef__mg_0024cacheD;
  1036. [CompilerGenerated]
  1037. private static Lexer.StateHandler _003C_003Ef__mg_0024cacheE;
  1038. [CompilerGenerated]
  1039. private static Lexer.StateHandler _003C_003Ef__mg_0024cacheF;
  1040. [CompilerGenerated]
  1041. private static Lexer.StateHandler _003C_003Ef__mg_0024cache10;
  1042. [CompilerGenerated]
  1043. private static Lexer.StateHandler _003C_003Ef__mg_0024cache11;
  1044. [CompilerGenerated]
  1045. private static Lexer.StateHandler _003C_003Ef__mg_0024cache12;
  1046. [CompilerGenerated]
  1047. private static Lexer.StateHandler _003C_003Ef__mg_0024cache13;
  1048. [CompilerGenerated]
  1049. private static Lexer.StateHandler _003C_003Ef__mg_0024cache14;
  1050. [CompilerGenerated]
  1051. private static Lexer.StateHandler _003C_003Ef__mg_0024cache15;
  1052. [CompilerGenerated]
  1053. private static Lexer.StateHandler _003C_003Ef__mg_0024cache16;
  1054. [CompilerGenerated]
  1055. private static Lexer.StateHandler _003C_003Ef__mg_0024cache17;
  1056. [CompilerGenerated]
  1057. private static Lexer.StateHandler _003C_003Ef__mg_0024cache18;
  1058. [CompilerGenerated]
  1059. private static Lexer.StateHandler _003C_003Ef__mg_0024cache19;
  1060. [CompilerGenerated]
  1061. private static Lexer.StateHandler _003C_003Ef__mg_0024cache1A;
  1062. [CompilerGenerated]
  1063. private static Lexer.StateHandler _003C_003Ef__mg_0024cache1B;
  1064. private delegate bool StateHandler(FsmContext ctx);
  1065. }
  1066. }