Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 68.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using static System.String;
  7. using static System.Char;
  8. using static System.Int32;
  9. using static Analyzer.KindsofErrors;
  10.  
  11. namespace Analyzer
  12. {
  13. class Graph
  14. {
  15. private enum State
  16. {
  17. E, S, S1, S2, S3, S4, S5, S6, S7, S8, F, F0, F00,
  18. D, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11,
  19. G, /*B1, B2, B3, B4, B5, B6, B7, B8, FL1, FL2, FL3, FL4, C1, C2, C3, C4, C5, C6, C7, C8,*/
  20. G1, B11, B22, B33, B44, B55, B66, B77, B88, FL11, FL22, FL33, FL44, C11, C22, C33, C44, C55, C66, C77, C88,
  21. };
  22.  
  23. /// <summary>
  24. ///
  25. /// </summary>
  26. /// <param name="str">Строка, подаваемая на вход</param>
  27. /// <param name="error">Ошибка</param>
  28. public void Analyz(string str, out KindsofErrors error, out VariableAndConstList list)
  29. {
  30. error = new KindsofErrors();
  31. list = new VariableAndConstList();
  32. int i = 0; //текущая позиция в строке
  33. char ch; //текущий символ строки
  34. int length = str.Length;
  35.  
  36. State state = State.S;
  37.  
  38. int maxlen = 8;
  39. int delta = 1;
  40. string id = ""; int minint = -32769; int maxint = 32768;
  41. string type = "";
  42. string int_numb_char = "";
  43. string int_numb_left = "";
  44. string int_numb_right = "";
  45. bool array = false;
  46.  
  47. while ((state != State.F) && (state != State.E) && (i < length))
  48. {
  49. ch = str[i]; i++;
  50. switch (state)
  51. {
  52. case State.S:
  53. {
  54. if (ch == ' ')
  55. state = State.S;
  56. else if (ch == 'd')
  57. state = State.S1;
  58. else
  59. {
  60. error = new KindsofErrors(Error.DD, i - 1);
  61. state = State.E;
  62. }
  63. break;
  64. }
  65.  
  66. case State.S1:
  67. {
  68. if (ch == 'c')
  69. state = State.S2;
  70. else if (ch == 'e')
  71. state = State.S4;
  72. else
  73. {
  74. error = new KindsofErrors(Error.DD, i - 2);
  75. state = State.E;
  76. }
  77. break;
  78. }
  79.  
  80. case State.S2:
  81. {
  82. if (ch == 'l')
  83. state = State.S3;
  84. else
  85. {
  86. error = new KindsofErrors(Error.DC, i - 3);
  87. state = State.E;
  88. }
  89. break;
  90. }
  91. case State.S3:
  92. {
  93. if (ch == ' ')
  94. state = State.D;
  95. else
  96. {
  97. error = new KindsofErrors(Error.Space, i - 3);
  98. state = State.E;
  99. }
  100. break;
  101. }
  102. case State.S4:
  103. {
  104. if (ch == 'c')
  105. state = State.S5;
  106. else
  107. {
  108. error = new KindsofErrors(Error.DE, i - 4);
  109. state = State.E;
  110. }
  111. break;
  112. }
  113. case State.S5:
  114. {
  115. if (ch == 'l')
  116. state = State.S6;
  117. else
  118. {
  119. error = new KindsofErrors(Error.DE, i - 5);
  120. state = State.E;
  121. }
  122. break;
  123. }
  124. case State.S6:
  125. {
  126. if (ch == 'a')
  127. state = State.S7;
  128. else
  129. {
  130. error = new KindsofErrors(Error.DE, i - 6);
  131. state = State.E;
  132. }
  133. break;
  134. }
  135. case State.S7:
  136. {
  137. if (ch == 'r')
  138. state = State.S8;
  139. else
  140. {
  141. error = new KindsofErrors(Error.DE, i - 7);
  142. state = State.E;
  143. }
  144. break;
  145. }
  146. case State.S8:
  147. {
  148. if (ch == 'e')
  149. state = State.S3;
  150. else
  151. {
  152. error = new KindsofErrors(Error.DE, i - 8);
  153. state = State.E;
  154. }
  155. break;
  156. }
  157. case State.D:
  158. {
  159. if (ch == ' ')
  160. state = State.D;
  161. else if (((ch >= 'a') && (ch <= 'z')) || (ch == '_'))
  162. {
  163. state = State.D1;
  164. id = id + ch;
  165. }
  166. else if (ch == '(')
  167. state = State.D2;
  168. else
  169. {
  170. error = new KindsofErrors(Error.IDOrOpeningBracket, i - 1);
  171. state = State.E;
  172. }
  173. break;
  174. }
  175. case State.D1:
  176. {
  177. //char.IsLetterOrDigit
  178. if (((ch >= 'a') && (ch <= 'z')) || (ch == '_') || ((ch >= '0') && (ch <= '9')))
  179. {
  180. if (id.Length < maxlen)
  181. {
  182. id = id + ch;
  183. state = State.D1;
  184. }
  185. else
  186. {
  187. error = new KindsofErrors(Error.IDLength, i - 1);
  188. state = State.E;
  189.  
  190. }
  191. }
  192.  
  193. else if (ch == '(')
  194. {
  195. if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
  196. {
  197. error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
  198. state = State.E;
  199. }
  200. else
  201. {
  202. list.AddLastID(id);
  203. state = State.L1;
  204. }
  205. id = "";
  206. }
  207. else if (ch == ',')
  208. {
  209.  
  210. if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
  211. {
  212. error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
  213. state = State.E;
  214. }
  215. else
  216. {
  217. list.AddLastID(id);
  218. state = State.D;
  219. }
  220. id = "";
  221. }
  222. else if (ch == ';')
  223. {
  224. if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
  225. {
  226. error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
  227. state = State.E;
  228. }
  229. else
  230. {
  231. list.AddLastID(id);
  232. state = State.F;
  233. }
  234. id = "";
  235. }
  236. else if (ch == ' ')
  237. {
  238. if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
  239. {
  240. error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
  241. state = State.E;
  242. }
  243. else
  244. {
  245. list.AddLastID(id);
  246. state = State.G;
  247. }
  248. id = "";
  249. }
  250. else
  251. { //Как учесть ошибки в идентификаторе?
  252. error = new KindsofErrors(Error.OpeningBracketOrEndOfLine, i - 1);
  253. state = State.E;
  254. }
  255. break;
  256. }
  257. case State.G:
  258. {
  259. if (ch == ' ')
  260. state = State.G;
  261. else if (ch == '(')
  262. state = State.L1;
  263. else if (ch == ';')
  264. state = State.F;
  265. else if (ch == 'b')
  266. state = State.B11;
  267. else if (ch == 'f')
  268. state = State.FL11;
  269. else if (ch == 'c')
  270. state = State.C11;
  271. else
  272. {
  273. error = new KindsofErrors(Error.OpeningBracketOrTypesOfDataOrEndOfLine, i - 1);
  274. state = State.E;
  275. }
  276. break;
  277. }
  278. case State.L1:
  279. {
  280. if (ch == ' ')
  281. state = State.L1;
  282. else if ((ch >= '0') && (ch <= '9'))
  283. {
  284.  
  285. int_numb_left = int_numb_left + ch;
  286. state = State.L3;
  287. }
  288. else if (ch == '-')
  289. {
  290.  
  291. int_numb_left = int_numb_left + ch;
  292. state = State.L2;
  293. }
  294. else
  295. {
  296. error = new KindsofErrors(Error.Integer, i - 1);
  297. state = State.E;
  298. }
  299. break;
  300. }
  301. case State.L2:
  302. {
  303. if ((ch >= '0') && (ch <= '9'))
  304. {
  305. state = State.L3;
  306. int_numb_left = int_numb_left + ch;
  307. }
  308. else
  309. {
  310. error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
  311. state = State.E;
  312. }
  313. break;
  314. }
  315. case State.L3:
  316. {
  317. if ((ch >= '0') && (ch <= '9'))
  318. {
  319. state = State.L3;
  320. int_numb_left = int_numb_left + ch;
  321. }
  322. else if (ch == ' ')
  323. {
  324. TryParse(int_numb_left, out int int_numb_left1);
  325. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  326. {
  327. if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
  328. {
  329. delta = int_numb_left1 * delta;
  330. state = State.L4;
  331. }
  332. else
  333. {
  334. error = new KindsofErrors(Error.Integer, i - 1);
  335. state = State.E;
  336. }
  337. }
  338. else
  339. {
  340. error = new KindsofErrors(Error.Integer, i - 1);
  341. state = State.E;
  342. }
  343. //int_numb_left = "";
  344. }
  345. else if (ch == ',')
  346. {
  347. TryParse(int_numb_left, out int int_numb_left1);
  348. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  349. {
  350.  
  351. if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
  352. {
  353. delta = int_numb_left1 * delta;
  354. state = State.L1;
  355. }
  356. else
  357. {
  358. error = new KindsofErrors(Error.Integer, i - 1);
  359. state = State.E;
  360. }
  361. }
  362. else
  363. {
  364. error = new KindsofErrors(Error.Integer, i - 1);
  365. state = State.E;
  366. }
  367. int_numb_left = "";
  368. }
  369. else if (ch == ')')
  370. {
  371. TryParse(int_numb_left, out int int_numb_left1);
  372. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  373. {
  374. if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
  375. {
  376. delta = int_numb_left1 * delta;
  377. state = State.L5;
  378. }
  379. else
  380. {
  381. error = new KindsofErrors(Error.Integer, i - 1);
  382. state = State.E;
  383. }
  384. }
  385. else
  386. {
  387. error = new KindsofErrors(Error.Integer, i - 1);
  388. state = State.E;
  389. }
  390. int_numb_left = "";
  391. }
  392. else if (ch == ':')
  393. {
  394. TryParse(int_numb_left, out int int_numb_left1);
  395. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  396. {
  397.  
  398. if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
  399. {
  400. delta = int_numb_left1 * delta;
  401. state = State.L6;
  402. }
  403. else
  404. {
  405. error = new KindsofErrors(Error.Integer, i - 1);
  406. state = State.E;
  407. }
  408. //int_numb_left = ""; СЧИТАЛАСЬ ЛЕВАЯ КОНСТАНТА
  409. }
  410. else
  411. {
  412. error = new KindsofErrors(Error.Integer, i - 1);
  413. state = State.E;
  414. }
  415. }
  416. else
  417. {
  418. error = new KindsofErrors(Error.CloseBracketOrCommaOrRightConstant, i - 1); //Ожидалась закрывающая скобка, запятая или правая константа размерности dim
  419. state = State.E;
  420. }
  421. break;
  422. }
  423. case State.L4:
  424. {
  425. if (ch == ' ')
  426. state = State.L4;
  427. else if (ch == ')')
  428. state = State.L5;
  429. else if (ch == ',')
  430. state = State.L1;
  431. else if (ch == ':')
  432. state = State.L6;
  433. else
  434. {
  435. error = new KindsofErrors(Error.CloseBracketOrTwoPoints, i - 1);
  436. state = State.E;
  437. }
  438. break;
  439. }
  440. case State.L5:
  441. {
  442. if (ch == ' ')
  443. {
  444. int_numb_left = ""; int_numb_right = "";
  445. state = State.L11;
  446. }
  447. else if (ch == ',')
  448. {
  449. int_numb_left = ""; int_numb_right = "";
  450. state = State.D;
  451. }
  452. else if (ch == ';')
  453. state = State.F;
  454. else
  455. {
  456. error = new KindsofErrors(Error.CommaOrEndLine, i - 1);
  457. state = State.E;
  458. }
  459. break;
  460. }
  461. case State.L6:
  462. {
  463. if (ch == ' ')
  464. state = State.L6;
  465. else if ((ch >= '0') && (ch <= '9'))
  466. {
  467. state = State.L7;
  468. int_numb_right = int_numb_right + ch;
  469. }
  470. else if (ch == '-')
  471. {
  472. state = State.L8;
  473. int_numb_right = int_numb_right + ch;
  474. }
  475. else
  476. {
  477. error = new KindsofErrors(Error.Integer, i - 1);
  478. state = State.E;
  479. }
  480. break;
  481. }
  482. case State.L7:
  483. {
  484. if ((ch >= '0') && (ch <= '9'))
  485. {
  486. state = State.L7;
  487. int_numb_right = int_numb_right + ch;
  488. }
  489. else if (ch == ' ')
  490. {
  491. TryParse(int_numb_right, out int int_numb_right1); TryParse(int_numb_left, out int int_numb_left1);
  492. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  493. {
  494. if ((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint))
  495. {
  496. if (int_numb_left1 < int_numb_right1)
  497. {
  498. delta = int_numb_left1 * delta;
  499. state = State.L9;
  500. }
  501. else
  502. {
  503. error = new KindsofErrors(Error.IsMoreThan, i - 1);
  504. state = State.E;
  505. }
  506. }
  507. else
  508. {
  509. error = new KindsofErrors(Error.Integer, i - 1);
  510. state = State.E;
  511. }
  512. }
  513. else
  514. {
  515. error = new KindsofErrors(Error.Integer, i - 1);
  516. state = State.E;
  517. }
  518. int_numb_left = "";
  519. int_numb_right = "";
  520. }
  521. else if (ch == ',')
  522. {
  523. TryParse(int_numb_right, out int int_numb_right1); TryParse(int_numb_left, out int int_numb_left1);
  524. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  525. {
  526. if ((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint))
  527. {
  528. if ((int_numb_right1 > minint) && (int_numb_right1 < maxint))
  529. {
  530. delta = int_numb_left1 * delta;
  531. state = State.L1;
  532. }
  533. else
  534. {
  535. error = new KindsofErrors(Error.IsMoreThan, i - 1);
  536. state = State.E;
  537. }
  538. }
  539. else
  540. {
  541. error = new KindsofErrors(Error.Integer, i - 1);
  542. state = State.E;
  543. }
  544. }
  545. else
  546. {
  547. error = new KindsofErrors(Error.Integer, i - 1);
  548. state = State.E;
  549. }
  550. int_numb_left = "";
  551. int_numb_right = "";
  552. }
  553. else if (ch == ')')
  554. {
  555. TryParse(int_numb_right, out int int_numb_right1); TryParse(int_numb_left, out int int_numb_left1);
  556. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  557. {
  558. if ((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint))
  559. {
  560. if (((int_numb_left1 < int_numb_right1)))
  561. {
  562. delta = int_numb_left1 * delta;
  563. state = State.L10;
  564. }
  565. else
  566. {
  567. error = new KindsofErrors(Error.IsMoreThan, i - 1);
  568. state = State.E;
  569. }
  570. }
  571. else
  572. {
  573. error = new KindsofErrors(Error.Integer, i - 1);
  574. state = State.E;
  575. }
  576. }
  577. else
  578. {
  579. error = new KindsofErrors(Error.Integer, i - 1);
  580. state = State.E;
  581. }
  582. int_numb_left = "";
  583. int_numb_right = "";
  584. }
  585. else
  586. {
  587. error = new KindsofErrors(Error.CloseBracketOrCommaOrRightConstant, i - 1); //Ожидалась закрывающая скобка, запятая или правая константа размерности dim
  588. state = State.E;
  589. }
  590. break;
  591. }
  592. case State.L8:
  593. {
  594. if ((ch >= '0') && (ch <= '9'))
  595. {
  596. state = State.L7;
  597. int_numb_right = int_numb_right + ch;
  598. }
  599. else
  600. {
  601. error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
  602. state = State.E;
  603. }
  604. break;
  605. }
  606. case State.L9:
  607. {
  608. if (ch == ' ')
  609. state = State.L9;
  610. else if (ch == ')')
  611. state = State.L10;
  612. else if (ch == ',')
  613. state = State.L1;
  614.  
  615. else
  616. {
  617. error = new KindsofErrors(Error.CloseBracketOrComma, i - 1);
  618. state = State.E;
  619. }
  620. break;
  621. }
  622. case State.L10:
  623. {
  624. if (ch == ' ')
  625. state = State.L11;
  626. else if (ch == ',')
  627. state = State.D;
  628. else
  629. {
  630. error = new KindsofErrors(Error.IntegerWithoutMinusOrSpace, i - 1);
  631. state = State.E;
  632. }
  633. break;
  634. }
  635. case State.L11:
  636. {
  637. if (ch == ' ')
  638. state = State.L11;
  639. else if (ch == 'b')
  640. state = State.B11;
  641. else if (ch == 'f')
  642. state = State.FL11;
  643. else if (ch == 'c')
  644. state = State.C11;
  645. else if (ch == ',')
  646. state = State.D;
  647. else
  648. {
  649. error = new KindsofErrors(Error.TypesOfDataOrSpaceOrComma, i - 1);
  650. state = State.E;
  651. }
  652. break;
  653. }
  654. case State.D2:
  655. {
  656. if (ch == ' ')
  657. state = State.D2;
  658. else if (((ch >= 'a') && (ch <= 'z')) || (ch == '_'))
  659. {
  660. id = id + ch;
  661. state = State.D3;
  662. }
  663. else
  664. {
  665. error = new KindsofErrors(Error.ID, i - 1);
  666. state = State.E;
  667. }
  668. break;
  669. }
  670. case State.D3:
  671. {
  672. if (((ch >= 'a') && (ch <= 'z')) || (ch == '_') || ((ch >= '0') && (ch <= '9')))
  673. if (id.Length < maxlen)
  674. {
  675. id = id + ch;
  676. state = State.D3;
  677. }
  678. else
  679. {
  680. error = new KindsofErrors(Error.IDLength, i - 1);
  681. state = State.E;
  682.  
  683. }
  684.  
  685.  
  686. else if (ch == '(')
  687. {
  688. if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
  689. {
  690. error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
  691. state = State.E;
  692. }
  693. else
  694. {
  695. list.AddLastID(id);
  696. state = State.D5;
  697. }
  698. id = "";
  699. }
  700. else if (ch == ')')
  701. {
  702. if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
  703. {
  704. error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
  705. state = State.E;
  706. }
  707. else
  708. {
  709. list.AddLastID(id);
  710. state = State.G1;
  711. }
  712. id = "";
  713.  
  714. }
  715. else if (ch == ',')
  716. {
  717. if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
  718. {
  719. error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
  720. state = State.E;
  721. }
  722. else
  723. {
  724. list.AddLastID(id);
  725. state = State.D2;
  726. }
  727. id = "";
  728. }
  729. else if (ch == ' ')
  730. {
  731. if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
  732. {
  733. error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
  734. state = State.E;
  735. }
  736. else
  737. {
  738. list.AddLastID(id);
  739. state = State.D4;
  740. }
  741. id = "";
  742. }
  743. else
  744. {
  745. error = new KindsofErrors(Error.BracketOrComma, i - 1);
  746. state = State.E;
  747. }
  748. break;
  749. }
  750. case State.D4:
  751. {
  752. if (ch == ' ')
  753. state = State.D4;
  754. else if (ch == ',')
  755. state = State.D2;
  756. else if (ch == '(')
  757. state = State.D5;
  758. else if (ch == ')')
  759. state = State.G1;
  760. else
  761. {
  762. error = new KindsofErrors(Error.OpenBracketOrComma, i - 1);
  763. state = State.E;
  764. }
  765. break;
  766. }
  767. case State.D5:
  768. {
  769. if (ch == ' ')
  770. state = State.D5;
  771. else if ((ch >= '0') && (ch <= '9'))
  772. {
  773. state = State.D7;
  774. int_numb_left = int_numb_left + ch;
  775.  
  776. }
  777. else if (ch == '-')
  778. {
  779. state = State.D6;
  780. int_numb_left = int_numb_left + ch;
  781. }
  782. else //Вставить проверку на максдлину числа(в диапазоне от -30к до 30к)
  783. {
  784. error = new KindsofErrors(Error.Integer, i - 1);
  785. state = State.E;
  786. }
  787. break;
  788. }
  789. case State.D6:
  790. {
  791. if ((ch >= '0') && (ch <= '9'))
  792. {
  793. state = State.D7;
  794. int_numb_left = int_numb_left + ch;
  795. }
  796. else
  797. {
  798. error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
  799. state = State.E;
  800. }
  801. break;
  802. }
  803. case State.D7:
  804. {
  805. if ((ch >= '0') && (ch <= '9'))
  806. {
  807. state = State.D7;
  808. int_numb_left = int_numb_left + ch;
  809. }
  810. else if (ch == ' ')
  811. {
  812. TryParse(int_numb_left, out int int_numb_left1);
  813. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  814. {
  815. if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
  816. {
  817. delta = int_numb_left1 * delta;
  818. state = State.D8;
  819. }
  820. else
  821. {
  822. error = new KindsofErrors(Error.Integer, i - 1);
  823. state = State.E;
  824. }
  825. }
  826. else
  827. {
  828. error = new KindsofErrors(Error.Integer, i - 1);
  829. state = State.E;
  830. }
  831. //int_numb_left = "";
  832. }
  833. else if (ch == ',')
  834. {
  835. TryParse(int_numb_left, out int int_numb_left1);
  836. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  837. {
  838. if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
  839. {
  840. delta = int_numb_left1 * delta;
  841. state = State.D5;
  842. }
  843. else
  844. {
  845. error = new KindsofErrors(Error.Integer, i - 1);
  846. state = State.E;
  847. }
  848. }
  849. else
  850. {
  851. error = new KindsofErrors(Error.Integer, i - 1);
  852. state = State.E;
  853. }
  854. int_numb_left = "";
  855. }
  856. else if (ch == ':')
  857. {
  858. TryParse(int_numb_left, out int int_numb_left1);
  859. if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
  860. {
  861. delta = int_numb_left1 * delta;
  862. state = State.D9;
  863. }
  864. else
  865. {
  866. error = new KindsofErrors(Error.Integer, i - 1);
  867. state = State.E;
  868. }
  869. //int_numb_left = "";
  870. }
  871. else
  872. {
  873. error = new KindsofErrors(Error.CommaOrRightConstant, i - 1); //Ожидалась запятая или правая константа размерности dim
  874. state = State.E;
  875. }
  876. break;
  877. }
  878.  
  879. case State.D8:
  880. {
  881. if (ch == ' ')
  882. state = State.D8;
  883. else if (ch == ',')
  884. state = State.D5;
  885. else if (ch == ':')
  886. state = State.D9;
  887. else
  888. {
  889. error = new KindsofErrors(Error.CommaOrTwoPoints, i - 1);
  890. state = State.E;
  891. }
  892. break;
  893. }
  894. case State.D9:
  895. {
  896. if (ch == ' ')
  897. state = State.D9;
  898. else if ((ch >= '0') && (ch <= '9'))
  899. {
  900. state = State.D11;
  901. int_numb_right = int_numb_right + ch;
  902.  
  903. }
  904. else if (ch == '-')
  905. {
  906. state = State.D10;
  907. int_numb_right = int_numb_right + ch;
  908. }
  909. else
  910. {
  911. error = new KindsofErrors(Error.Integer, i - 1);
  912. state = State.E;
  913. }
  914. break;
  915. }
  916. case State.D10:
  917. {
  918. if ((ch >= '0') && (ch <= '9'))
  919. {
  920. int_numb_right = int_numb_right + ch;
  921. state = State.D11;
  922. }
  923. else
  924. {
  925. error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
  926. state = State.E;
  927. }
  928. break;
  929. }
  930. case State.D11:
  931. {
  932. if ((ch >= '0') && (ch <= '9'))
  933. {
  934. int_numb_right = int_numb_right + ch;
  935. state = State.D11;
  936. }
  937. else if (ch == ' ')
  938. {
  939. TryParse(int_numb_left, out int int_numb_left1); TryParse(int_numb_right, out int int_numb_right1);
  940. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  941. {
  942. if (((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint)))
  943. {
  944. if (int_numb_left1 < int_numb_right1)
  945. {
  946. delta = (int_numb_right1 - int_numb_left1 + 1) * delta;
  947. state = State.D12;
  948. }
  949. else
  950. {
  951. error = new KindsofErrors(Error.IsMoreThan, i - 1);
  952. state = State.E;
  953. }
  954. }
  955. else{
  956. error = new KindsofErrors(Error.Integer, i - 1);
  957. state = State.E;
  958. }
  959. }
  960. else{
  961. error = new KindsofErrors(Error.Integer, i - 1);
  962. state = State.E;
  963. }
  964. int_numb_right = "";
  965. int_numb_left = "";
  966. }
  967. else if (ch == ')')
  968. {
  969. TryParse(int_numb_left, out int int_numb_left1); TryParse(int_numb_right, out int int_numb_right1);
  970. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  971. {
  972. if (((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint)))
  973. {
  974. if (int_numb_left1 < int_numb_right1)
  975. {
  976. delta = (int_numb_right1 - int_numb_left1 + 1) * delta;
  977. state = State.D13;
  978. }
  979. else
  980. {
  981. error = new KindsofErrors(Error.IsMoreThan, i - 1);
  982. state = State.E;
  983. }
  984. }
  985. else
  986. {
  987. error = new KindsofErrors(Error.Integer, i - 1);
  988. state = State.E;
  989. }
  990. }
  991. else
  992. {
  993. error = new KindsofErrors(Error.Integer, i - 1);
  994. state = State.E;
  995. }
  996. int_numb_right = "";
  997. int_numb_left = "";
  998. }
  999. else if (ch == ',')
  1000. {
  1001. TryParse(int_numb_left, out int int_numb_left1); TryParse(int_numb_right, out int int_numb_right1);
  1002. if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
  1003. {
  1004. if (((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint)))
  1005. {
  1006.  
  1007. if ((int_numb_left1 < int_numb_right1))
  1008. {
  1009. delta = (int_numb_right1 - int_numb_left1 + 1) * delta;
  1010. state = State.D5;
  1011. }
  1012. else
  1013. {
  1014. error = new KindsofErrors(Error.IsMoreThan, i - 1);
  1015. state = State.E;
  1016. }
  1017. }
  1018. else
  1019. {
  1020. error = new KindsofErrors(Error.Integer, i - 1);
  1021. state = State.E;
  1022. }
  1023. }
  1024. else
  1025. {
  1026. error = new KindsofErrors(Error.Integer, i - 1);
  1027. state = State.E;
  1028. }
  1029. int_numb_right = "";
  1030. int_numb_left = "";
  1031. }
  1032. else
  1033. {
  1034. error = new KindsofErrors(Error.CloseBracketOrComma, i - 1);
  1035. state = State.E;
  1036. }
  1037. break;
  1038. }
  1039. case State.D12:
  1040. {
  1041.  
  1042. if (ch == ' ')
  1043. state = State.D12;
  1044. else if (ch == ')')
  1045. state = State.D13;
  1046. else if (ch == ',')
  1047. state = State.D5;
  1048. else
  1049. {
  1050. error = new KindsofErrors(Error.CloseBracketOrComma, i - 1);
  1051. state = State.E;
  1052. }
  1053. break;
  1054. }
  1055. case State.D13:
  1056. {
  1057.  
  1058. if (ch == ' ')
  1059. state = State.D13;
  1060. else if (ch == ')')
  1061. state = State.G1;
  1062. else if (ch == ',')
  1063. state = State.D2;
  1064. else
  1065. {
  1066. error = new KindsofErrors(Error.CloseBracketOrComma, i - 1);
  1067. state = State.E;
  1068. }
  1069. break;
  1070. }
  1071. case State.G1:
  1072. {
  1073. if (ch == ' ')
  1074. state = State.G1;
  1075. else if (ch == 'b')
  1076. {
  1077. type = type + ch;
  1078. state = State.B11;
  1079. }
  1080. else if (ch == 'f')
  1081. {
  1082. type = type + ch;
  1083. state = State.FL11;
  1084. }
  1085. else if (ch == 'c')
  1086. {
  1087. type = type + ch;
  1088. state = State.C11;
  1089. }
  1090. else
  1091. {
  1092. error = new KindsofErrors(Error.TypesOfData, i - 1);
  1093. state = State.E;
  1094. }
  1095. break;
  1096. }
  1097. case State.FL11:
  1098. {
  1099. if (ch == 'l')
  1100. {
  1101. type = type + ch;
  1102. state = State.FL22;
  1103. }
  1104. else
  1105. {
  1106. error = new KindsofErrors(Error.TypesOfDataFloat, i - 2);
  1107. state = State.E;
  1108. }
  1109. break;
  1110. }
  1111. case State.FL22:
  1112. {
  1113. if (ch == 'o')
  1114. {
  1115. type = type + ch;
  1116. state = State.FL33;
  1117. }
  1118. else
  1119. {
  1120. error = new KindsofErrors(Error.TypesOfDataFloat, i - 3);
  1121. state = State.E;
  1122. }
  1123. break;
  1124. }
  1125. case State.FL33:
  1126. {
  1127. if (ch == 'a')
  1128. {
  1129. type = type + ch;
  1130. state = State.FL44;
  1131. }
  1132. else
  1133. {
  1134. error = new KindsofErrors(Error.TypesOfDataFloat, i - 4);
  1135. state = State.E;
  1136. }
  1137. break;
  1138. }
  1139. case State.FL44:
  1140. {
  1141. if (ch == 't')
  1142. {
  1143. type = type + ch;
  1144. state = State.F00;
  1145. }
  1146. else
  1147. {
  1148. error = new KindsofErrors(Error.TypesOfDataFloat, i - 5);
  1149. state = State.E;
  1150. }
  1151. break;
  1152. }
  1153. case State.B11:
  1154. {
  1155. if (ch == 'i')
  1156. {
  1157. type = type + ch;
  1158. state = State.B22;
  1159. }
  1160. else
  1161. {
  1162. error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 1);
  1163. state = State.E;
  1164. }
  1165. break;
  1166. }
  1167. case State.B22:
  1168. {
  1169. if (ch == 'n')
  1170. {
  1171. type = type + ch;
  1172. state = State.B33;
  1173. }
  1174. else
  1175. {
  1176. error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 2);
  1177. state = State.E;
  1178. }
  1179. break;
  1180. }
  1181. case State.B33:
  1182. {
  1183. if (ch == ' ')
  1184. {
  1185. type = type + ch;
  1186. state = State.B44;
  1187. }
  1188. else
  1189. {
  1190. error = new KindsofErrors(Error.Space, i - 1);
  1191. state = State.E;
  1192. }
  1193. break;
  1194. }
  1195. case State.B44:
  1196. {
  1197. if (ch == ' ')
  1198. state = State.B44;
  1199. else if (ch == 'f')
  1200. {
  1201. type = type + ch;
  1202. state = State.B55;
  1203. }
  1204. else
  1205. {
  1206. error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 1);
  1207. state = State.E;
  1208. }
  1209. break;
  1210. }
  1211. case State.B55:
  1212. {
  1213. if (ch == 'i')
  1214. {
  1215. type = type + ch;
  1216. state = State.B66;
  1217. }
  1218. else
  1219. {
  1220. error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 2);
  1221. state = State.E;
  1222. }
  1223. break;
  1224. }
  1225. case State.B66:
  1226. {
  1227. if (ch == 'x')
  1228. {
  1229. type = type + ch;
  1230. state = State.B77;
  1231. }
  1232. else
  1233. {
  1234. error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 3);
  1235. state = State.E;
  1236. }
  1237. break;
  1238. }
  1239. case State.B77:
  1240. {
  1241. if (ch == 'e')
  1242. {
  1243. type = type + ch;
  1244. state = State.B88;
  1245. }
  1246. else
  1247. {
  1248. error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 4);
  1249. state = State.E;
  1250. }
  1251. break;
  1252. }
  1253. case State.B88:
  1254. {
  1255. if (ch == 'd')
  1256. {
  1257. type = type + ch;
  1258. state = State.F00;
  1259. }
  1260. else
  1261. {
  1262. error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 5);
  1263. state = State.E;
  1264. }
  1265. break;
  1266. }
  1267. case State.C11:
  1268. {
  1269. if (ch == 'h')
  1270. {
  1271. type = type + ch;
  1272. state = State.C22;
  1273. }
  1274.  
  1275. else
  1276. {
  1277. error = new KindsofErrors(Error.TypesOfDataChar, i - 1);
  1278. state = State.E;
  1279. }
  1280. break;
  1281. }
  1282. case State.C22:
  1283. {
  1284. if (ch == 'a')
  1285. {
  1286. type = type + ch;
  1287. state = State.C33;
  1288. }
  1289. else
  1290. {
  1291. error = new KindsofErrors(Error.TypesOfDataChar, i - 2);
  1292. state = State.E;
  1293. }
  1294. break;
  1295. }
  1296. case State.C33:
  1297. {
  1298. if (ch == 'r')
  1299. {
  1300. type = type + ch;
  1301. state = State.C44;
  1302. }
  1303. else
  1304. {
  1305. error = new KindsofErrors(Error.TypesOfDataChar, i - 3);
  1306. state = State.E;
  1307. }
  1308. break;
  1309. }
  1310. case State.C44:
  1311. {
  1312. if (ch == ' ')
  1313. state = State.C44;
  1314. else if (ch == '(')
  1315. state = State.C55;
  1316. else
  1317. {
  1318. error = new KindsofErrors(Error.TypesOfDataChar, i - 1);
  1319. state = State.E;
  1320. }
  1321. break;
  1322. }
  1323. case State.C55:
  1324. {
  1325. if (ch == ' ')
  1326. state = State.C55;
  1327. else if ((ch >= '0') && (ch <= '9'))
  1328. {
  1329. int_numb_char = int_numb_char + ch;
  1330. state = State.C77;
  1331. }
  1332. else if (ch == '-')
  1333. {
  1334. int_numb_char = int_numb_char + ch;
  1335. state = State.C66;
  1336. }
  1337. else
  1338. {
  1339. error = new KindsofErrors(Error.Integer, i - 1);
  1340. state = State.E;
  1341. }
  1342. break;
  1343. }
  1344. case State.C66:
  1345. {
  1346. if ((ch >= '0') && (ch <= '9'))
  1347. {
  1348. int_numb_char = int_numb_char + ch;
  1349. state = State.C77;
  1350. }
  1351. else
  1352. {
  1353. error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
  1354. state = State.E;
  1355. }
  1356. break;
  1357. }
  1358. case State.C77:
  1359. {
  1360. if ((ch >= '0') && (ch <= '9'))
  1361. {
  1362. int_numb_char = int_numb_char + ch;
  1363. state = State.C77;
  1364. }
  1365. else if (ch == ' ')
  1366. {
  1367. TryParse(int_numb_char, out int int_numb_char1);
  1368. if (((int_numb_char == "0") && (int_numb_char1 == 0)) || ((int_numb_char != "0") && (int_numb_char1 != 0)))
  1369. {
  1370. if ((int_numb_char1 > minint) && (int_numb_char1 < maxint))
  1371. {
  1372. state = State.C88;
  1373. }
  1374. else
  1375. {
  1376. error = new KindsofErrors(Error.Integer, i - 1);
  1377. state = State.E;
  1378. }
  1379. }
  1380. else
  1381. {
  1382. error = new KindsofErrors(Error.Integer, i - 1);
  1383. state = State.E;
  1384. }
  1385. int_numb_char = "";
  1386. }
  1387. else if (ch == ')')
  1388. {
  1389. TryParse(int_numb_char, out int int_numb_char1);
  1390. if (((int_numb_char == "0") && (int_numb_char1 == 0)) || ((int_numb_char != "0") && (int_numb_char1 != 0)))
  1391. {
  1392. if ((int_numb_char1 > minint) && (int_numb_char1 < maxint))
  1393. {
  1394. state = State.F00;
  1395. }
  1396. else
  1397. {
  1398. error = new KindsofErrors(Error.Integer, i - 1);
  1399. state = State.E;
  1400. }
  1401. }
  1402. else
  1403. {
  1404. error = new KindsofErrors(Error.Integer, i - 1);
  1405. state = State.E;
  1406. }
  1407. int_numb_char = "";
  1408. }
  1409. else
  1410. {
  1411. error = new KindsofErrors(Error.CloseBracket, i - 1); //Ожидалась )
  1412. state = State.E;
  1413. }
  1414. break;
  1415. }
  1416. case State.C88:
  1417. {
  1418. if (ch == ')')
  1419. state = State.F00;
  1420. else
  1421. {
  1422. error = new KindsofErrors(Error.CloseBracket, i - 1); //Ожидалась )
  1423. state = State.E;
  1424. }
  1425. break;
  1426. }
  1427. case State.F00:
  1428. {
  1429. if (ch == ' ')
  1430. {
  1431. list.AddType(type, delta);
  1432. type = "";
  1433. delta = 1;
  1434. state = State.F00;
  1435. }
  1436. else if (ch == ';')
  1437. {
  1438. list.AddType(type, delta);
  1439. type = "";
  1440. delta = 1;
  1441. state = State.F;
  1442. }
  1443. else if (ch == ',')
  1444. {
  1445. list.AddType(type, delta);
  1446. type = "";
  1447. delta = 1;
  1448. state = State.D;
  1449. }
  1450. else
  1451. {
  1452. error = new KindsofErrors(Error.CommaOrEndLine, i - 1);
  1453. state = State.E;
  1454. }
  1455. break;
  1456. }
  1457. }
  1458. }
  1459. }
  1460.  
  1461. }
  1462. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement