/jaspyon/rlib/parsing/pypackrat.py

https://bitbucket.org/santagada/jaspyon · Python · 3132 lines · 3124 code · 1 blank · 7 comment · 710 complexity · 122778248a578102a2c5d8c79f554b2b MD5 · raw file

Large files are truncated click here to view the full file

  1. from jaspyon.rlib.parsing.tree import Nonterminal, Symbol
  2. from makepackrat import PackratParser, BacktrackException, Status
  3. class Parser(object):
  4. def NAME(self):
  5. return self._NAME().result
  6. def _NAME(self):
  7. _key = self._pos
  8. _status = self._dict_NAME.get(_key, None)
  9. if _status is None:
  10. _status = self._dict_NAME[_key] = Status()
  11. else:
  12. _statusstatus = _status.status
  13. if _statusstatus == _status.NORMAL:
  14. self._pos = _status.pos
  15. return _status
  16. elif _statusstatus == _status.ERROR:
  17. raise BacktrackException(_status.error)
  18. _startingpos = self._pos
  19. try:
  20. _result = None
  21. _error = None
  22. _result = self._regex1074651696()
  23. assert _status.status != _status.LEFTRECURSION
  24. _status.status = _status.NORMAL
  25. _status.pos = self._pos
  26. _status.result = _result
  27. _status.error = _error
  28. return _status
  29. except BacktrackException, _exc:
  30. _status.pos = -1
  31. _status.result = None
  32. _error = _exc.error
  33. _status.error = _error
  34. _status.status = _status.ERROR
  35. raise BacktrackException(_error)
  36. def SPACE(self):
  37. return self._SPACE().result
  38. def _SPACE(self):
  39. _key = self._pos
  40. _status = self._dict_SPACE.get(_key, None)
  41. if _status is None:
  42. _status = self._dict_SPACE[_key] = Status()
  43. else:
  44. _statusstatus = _status.status
  45. if _statusstatus == _status.NORMAL:
  46. self._pos = _status.pos
  47. return _status
  48. elif _statusstatus == _status.ERROR:
  49. raise BacktrackException(_status.error)
  50. _startingpos = self._pos
  51. try:
  52. _result = None
  53. _error = None
  54. _result = self.__chars__(' ')
  55. assert _status.status != _status.LEFTRECURSION
  56. _status.status = _status.NORMAL
  57. _status.pos = self._pos
  58. _status.result = _result
  59. _status.error = _error
  60. return _status
  61. except BacktrackException, _exc:
  62. _status.pos = -1
  63. _status.result = None
  64. _error = _exc.error
  65. _status.error = _error
  66. _status.status = _status.ERROR
  67. raise BacktrackException(_error)
  68. def COMMENT(self):
  69. return self._COMMENT().result
  70. def _COMMENT(self):
  71. _key = self._pos
  72. _status = self._dict_COMMENT.get(_key, None)
  73. if _status is None:
  74. _status = self._dict_COMMENT[_key] = Status()
  75. else:
  76. _statusstatus = _status.status
  77. if _statusstatus == _status.NORMAL:
  78. self._pos = _status.pos
  79. return _status
  80. elif _statusstatus == _status.ERROR:
  81. raise BacktrackException(_status.error)
  82. _startingpos = self._pos
  83. try:
  84. _result = None
  85. _error = None
  86. _result = self._regex528667127()
  87. assert _status.status != _status.LEFTRECURSION
  88. _status.status = _status.NORMAL
  89. _status.pos = self._pos
  90. _status.result = _result
  91. _status.error = _error
  92. return _status
  93. except BacktrackException, _exc:
  94. _status.pos = -1
  95. _status.result = None
  96. _error = _exc.error
  97. _status.error = _error
  98. _status.status = _status.ERROR
  99. raise BacktrackException(_error)
  100. def IGNORE(self):
  101. return self._IGNORE().result
  102. def _IGNORE(self):
  103. _key = self._pos
  104. _status = self._dict_IGNORE.get(_key, None)
  105. if _status is None:
  106. _status = self._dict_IGNORE[_key] = Status()
  107. else:
  108. _statusstatus = _status.status
  109. if _statusstatus == _status.NORMAL:
  110. self._pos = _status.pos
  111. return _status
  112. elif _statusstatus == _status.ERROR:
  113. raise BacktrackException(_status.error)
  114. _startingpos = self._pos
  115. try:
  116. _result = None
  117. _error = None
  118. _result = self._regex1979538501()
  119. assert _status.status != _status.LEFTRECURSION
  120. _status.status = _status.NORMAL
  121. _status.pos = self._pos
  122. _status.result = _result
  123. _status.error = _error
  124. return _status
  125. except BacktrackException, _exc:
  126. _status.pos = -1
  127. _status.result = None
  128. _error = _exc.error
  129. _status.error = _error
  130. _status.status = _status.ERROR
  131. raise BacktrackException(_error)
  132. def newline(self):
  133. return self._newline().result
  134. def _newline(self):
  135. _key = self._pos
  136. _status = self._dict_newline.get(_key, None)
  137. if _status is None:
  138. _status = self._dict_newline[_key] = Status()
  139. else:
  140. _statusstatus = _status.status
  141. if _statusstatus == _status.NORMAL:
  142. self._pos = _status.pos
  143. return _status
  144. elif _statusstatus == _status.ERROR:
  145. raise BacktrackException(_status.error)
  146. elif (_statusstatus == _status.INPROGRESS or
  147. _statusstatus == _status.LEFTRECURSION):
  148. _status.status = _status.LEFTRECURSION
  149. if _status.result is not None:
  150. self._pos = _status.pos
  151. return _status
  152. else:
  153. raise BacktrackException(None)
  154. elif _statusstatus == _status.SOMESOLUTIONS:
  155. _status.status = _status.INPROGRESS
  156. _startingpos = self._pos
  157. try:
  158. _result = None
  159. _error = None
  160. while 1:
  161. _choice0 = self._pos
  162. try:
  163. _call_status = self._COMMENT()
  164. _result = _call_status.result
  165. _error = _call_status.error
  166. break
  167. except BacktrackException, _exc:
  168. _error = self._combine_errors(_error, _exc.error)
  169. self._pos = _choice0
  170. _choice1 = self._pos
  171. try:
  172. _result = self._regex299149370()
  173. break
  174. except BacktrackException, _exc:
  175. _error = self._combine_errors(_error, _exc.error)
  176. self._pos = _choice1
  177. raise BacktrackException(_error)
  178. _result = self._regex299149370()
  179. break
  180. if _status.status == _status.LEFTRECURSION:
  181. if _status.result is not None:
  182. if _status.pos >= self._pos:
  183. _status.status = _status.NORMAL
  184. self._pos = _status.pos
  185. return _status
  186. _status.pos = self._pos
  187. _status.status = _status.SOMESOLUTIONS
  188. _status.result = _result
  189. _status.error = _error
  190. self._pos = _startingpos
  191. return self._newline()
  192. _status.status = _status.NORMAL
  193. _status.pos = self._pos
  194. _status.result = _result
  195. _status.error = _error
  196. return _status
  197. except BacktrackException, _exc:
  198. _status.pos = -1
  199. _status.result = None
  200. _error = self._combine_errors(_error, _exc.error)
  201. _status.error = _error
  202. _status.status = _status.ERROR
  203. raise BacktrackException(_error)
  204. def REGEX(self):
  205. return self._REGEX().result
  206. def _REGEX(self):
  207. _key = self._pos
  208. _status = self._dict_REGEX.get(_key, None)
  209. if _status is None:
  210. _status = self._dict_REGEX[_key] = Status()
  211. else:
  212. _statusstatus = _status.status
  213. if _statusstatus == _status.NORMAL:
  214. self._pos = _status.pos
  215. return _status
  216. elif _statusstatus == _status.ERROR:
  217. raise BacktrackException(_status.error)
  218. _startingpos = self._pos
  219. try:
  220. _result = None
  221. _error = None
  222. _result = self._regex1006631623()
  223. r = _result
  224. _result = (Symbol('REGEX', r, None))
  225. assert _status.status != _status.LEFTRECURSION
  226. _status.status = _status.NORMAL
  227. _status.pos = self._pos
  228. _status.result = _result
  229. _status.error = _error
  230. return _status
  231. except BacktrackException, _exc:
  232. _status.pos = -1
  233. _status.result = None
  234. _error = _exc.error
  235. _status.error = _error
  236. _status.status = _status.ERROR
  237. raise BacktrackException(_error)
  238. def QUOTE(self):
  239. return self._QUOTE().result
  240. def _QUOTE(self):
  241. _key = self._pos
  242. _status = self._dict_QUOTE.get(_key, None)
  243. if _status is None:
  244. _status = self._dict_QUOTE[_key] = Status()
  245. else:
  246. _statusstatus = _status.status
  247. if _statusstatus == _status.NORMAL:
  248. self._pos = _status.pos
  249. return _status
  250. elif _statusstatus == _status.ERROR:
  251. raise BacktrackException(_status.error)
  252. _startingpos = self._pos
  253. try:
  254. _result = None
  255. _error = None
  256. _result = self._regex1124192327()
  257. r = _result
  258. _result = (Symbol('QUOTE', r, None))
  259. assert _status.status != _status.LEFTRECURSION
  260. _status.status = _status.NORMAL
  261. _status.pos = self._pos
  262. _status.result = _result
  263. _status.error = _error
  264. return _status
  265. except BacktrackException, _exc:
  266. _status.pos = -1
  267. _status.result = None
  268. _error = _exc.error
  269. _status.error = _error
  270. _status.status = _status.ERROR
  271. raise BacktrackException(_error)
  272. def PYTHONCODE(self):
  273. return self._PYTHONCODE().result
  274. def _PYTHONCODE(self):
  275. _key = self._pos
  276. _status = self._dict_PYTHONCODE.get(_key, None)
  277. if _status is None:
  278. _status = self._dict_PYTHONCODE[_key] = Status()
  279. else:
  280. _statusstatus = _status.status
  281. if _statusstatus == _status.NORMAL:
  282. self._pos = _status.pos
  283. return _status
  284. elif _statusstatus == _status.ERROR:
  285. raise BacktrackException(_status.error)
  286. _startingpos = self._pos
  287. try:
  288. _result = None
  289. _error = None
  290. _result = self._regex291086639()
  291. r = _result
  292. _result = (Symbol('PYTHONCODE', r, None))
  293. assert _status.status != _status.LEFTRECURSION
  294. _status.status = _status.NORMAL
  295. _status.pos = self._pos
  296. _status.result = _result
  297. _status.error = _error
  298. return _status
  299. except BacktrackException, _exc:
  300. _status.pos = -1
  301. _status.result = None
  302. _error = _exc.error
  303. _status.error = _error
  304. _status.status = _status.ERROR
  305. raise BacktrackException(_error)
  306. def EOF(self):
  307. return self._EOF().result
  308. def _EOF(self):
  309. _key = self._pos
  310. _status = self._dict_EOF.get(_key, None)
  311. if _status is None:
  312. _status = self._dict_EOF[_key] = Status()
  313. else:
  314. _statusstatus = _status.status
  315. if _statusstatus == _status.NORMAL:
  316. self._pos = _status.pos
  317. return _status
  318. elif _statusstatus == _status.ERROR:
  319. raise BacktrackException(_status.error)
  320. elif (_statusstatus == _status.INPROGRESS or
  321. _statusstatus == _status.LEFTRECURSION):
  322. _status.status = _status.LEFTRECURSION
  323. if _status.result is not None:
  324. self._pos = _status.pos
  325. return _status
  326. else:
  327. raise BacktrackException(None)
  328. elif _statusstatus == _status.SOMESOLUTIONS:
  329. _status.status = _status.INPROGRESS
  330. _startingpos = self._pos
  331. try:
  332. _result = None
  333. _error = None
  334. _choice0 = self._pos
  335. _stored_result1 = _result
  336. try:
  337. _result = self.__any__()
  338. except BacktrackException:
  339. self._pos = _choice0
  340. _result = _stored_result1
  341. else:
  342. raise BacktrackException(None)
  343. if _status.status == _status.LEFTRECURSION:
  344. if _status.result is not None:
  345. if _status.pos >= self._pos:
  346. _status.status = _status.NORMAL
  347. self._pos = _status.pos
  348. return _status
  349. _status.pos = self._pos
  350. _status.status = _status.SOMESOLUTIONS
  351. _status.result = _result
  352. _status.error = _error
  353. self._pos = _startingpos
  354. return self._EOF()
  355. _status.status = _status.NORMAL
  356. _status.pos = self._pos
  357. _status.result = _result
  358. _status.error = _error
  359. return _status
  360. except BacktrackException, _exc:
  361. _status.pos = -1
  362. _status.result = None
  363. _error = _exc.error
  364. _status.error = _error
  365. _status.status = _status.ERROR
  366. raise BacktrackException(_error)
  367. def file(self):
  368. return self._file().result
  369. def _file(self):
  370. _key = self._pos
  371. _status = self._dict_file.get(_key, None)
  372. if _status is None:
  373. _status = self._dict_file[_key] = Status()
  374. else:
  375. _statusstatus = _status.status
  376. if _statusstatus == _status.NORMAL:
  377. self._pos = _status.pos
  378. return _status
  379. elif _statusstatus == _status.ERROR:
  380. raise BacktrackException(_status.error)
  381. elif (_statusstatus == _status.INPROGRESS or
  382. _statusstatus == _status.LEFTRECURSION):
  383. _status.status = _status.LEFTRECURSION
  384. if _status.result is not None:
  385. self._pos = _status.pos
  386. return _status
  387. else:
  388. raise BacktrackException(None)
  389. elif _statusstatus == _status.SOMESOLUTIONS:
  390. _status.status = _status.INPROGRESS
  391. _startingpos = self._pos
  392. try:
  393. _result = None
  394. _error = None
  395. _all0 = []
  396. while 1:
  397. _choice1 = self._pos
  398. try:
  399. _call_status = self._IGNORE()
  400. _result = _call_status.result
  401. _error = _call_status.error
  402. _all0.append(_result)
  403. except BacktrackException, _exc:
  404. _error = self._combine_errors(_error, _exc.error)
  405. self._pos = _choice1
  406. break
  407. _result = _all0
  408. _call_status = self._list()
  409. _result = _call_status.result
  410. _error = self._combine_errors(_error, _call_status.error)
  411. _before_discard2 = _result
  412. _call_status = self._EOF()
  413. _result = _call_status.result
  414. _error = self._combine_errors(_error, _call_status.error)
  415. _result = _before_discard2
  416. if _status.status == _status.LEFTRECURSION:
  417. if _status.result is not None:
  418. if _status.pos >= self._pos:
  419. _status.status = _status.NORMAL
  420. self._pos = _status.pos
  421. return _status
  422. _status.pos = self._pos
  423. _status.status = _status.SOMESOLUTIONS
  424. _status.result = _result
  425. _status.error = _error
  426. self._pos = _startingpos
  427. return self._file()
  428. _status.status = _status.NORMAL
  429. _status.pos = self._pos
  430. _status.result = _result
  431. _status.error = _error
  432. return _status
  433. except BacktrackException, _exc:
  434. _status.pos = -1
  435. _status.result = None
  436. _error = self._combine_errors(_error, _exc.error)
  437. _status.error = _error
  438. _status.status = _status.ERROR
  439. raise BacktrackException(_error)
  440. def list(self):
  441. return self._list().result
  442. def _list(self):
  443. _key = self._pos
  444. _status = self._dict_list.get(_key, None)
  445. if _status is None:
  446. _status = self._dict_list[_key] = Status()
  447. else:
  448. _statusstatus = _status.status
  449. if _statusstatus == _status.NORMAL:
  450. self._pos = _status.pos
  451. return _status
  452. elif _statusstatus == _status.ERROR:
  453. raise BacktrackException(_status.error)
  454. elif (_statusstatus == _status.INPROGRESS or
  455. _statusstatus == _status.LEFTRECURSION):
  456. _status.status = _status.LEFTRECURSION
  457. if _status.result is not None:
  458. self._pos = _status.pos
  459. return _status
  460. else:
  461. raise BacktrackException(None)
  462. elif _statusstatus == _status.SOMESOLUTIONS:
  463. _status.status = _status.INPROGRESS
  464. _startingpos = self._pos
  465. try:
  466. _result = None
  467. _error = None
  468. _all0 = []
  469. _call_status = self._production()
  470. _result = _call_status.result
  471. _error = _call_status.error
  472. _all0.append(_result)
  473. while 1:
  474. _choice1 = self._pos
  475. try:
  476. _call_status = self._production()
  477. _result = _call_status.result
  478. _error = self._combine_errors(_error, _call_status.error)
  479. _all0.append(_result)
  480. except BacktrackException, _exc:
  481. _error = self._combine_errors(_error, _exc.error)
  482. self._pos = _choice1
  483. break
  484. _result = _all0
  485. content = _result
  486. _result = (Nonterminal('list', content))
  487. if _status.status == _status.LEFTRECURSION:
  488. if _status.result is not None:
  489. if _status.pos >= self._pos:
  490. _status.status = _status.NORMAL
  491. self._pos = _status.pos
  492. return _status
  493. _status.pos = self._pos
  494. _status.status = _status.SOMESOLUTIONS
  495. _status.result = _result
  496. _status.error = _error
  497. self._pos = _startingpos
  498. return self._list()
  499. _status.status = _status.NORMAL
  500. _status.pos = self._pos
  501. _status.result = _result
  502. _status.error = _error
  503. return _status
  504. except BacktrackException, _exc:
  505. _status.pos = -1
  506. _status.result = None
  507. _error = self._combine_errors(_error, _exc.error)
  508. _status.error = _error
  509. _status.status = _status.ERROR
  510. raise BacktrackException(_error)
  511. def production(self):
  512. return self._production().result
  513. def _production(self):
  514. _key = self._pos
  515. _status = self._dict_production.get(_key, None)
  516. if _status is None:
  517. _status = self._dict_production[_key] = Status()
  518. else:
  519. _statusstatus = _status.status
  520. if _statusstatus == _status.NORMAL:
  521. self._pos = _status.pos
  522. return _status
  523. elif _statusstatus == _status.ERROR:
  524. raise BacktrackException(_status.error)
  525. elif (_statusstatus == _status.INPROGRESS or
  526. _statusstatus == _status.LEFTRECURSION):
  527. _status.status = _status.LEFTRECURSION
  528. if _status.result is not None:
  529. self._pos = _status.pos
  530. return _status
  531. else:
  532. raise BacktrackException(None)
  533. elif _statusstatus == _status.SOMESOLUTIONS:
  534. _status.status = _status.INPROGRESS
  535. _startingpos = self._pos
  536. try:
  537. _result = None
  538. _error = None
  539. _call_status = self._NAME()
  540. _result = _call_status.result
  541. _error = _call_status.error
  542. name = _result
  543. _all0 = []
  544. while 1:
  545. _choice1 = self._pos
  546. try:
  547. _call_status = self._SPACE()
  548. _result = _call_status.result
  549. _error = self._combine_errors(_error, _call_status.error)
  550. _all0.append(_result)
  551. except BacktrackException, _exc:
  552. _error = self._combine_errors(_error, _exc.error)
  553. self._pos = _choice1
  554. break
  555. _result = _all0
  556. _call_status = self._productionargs()
  557. _result = _call_status.result
  558. _error = self._combine_errors(_error, _call_status.error)
  559. args = _result
  560. _result = self.__chars__(':')
  561. _all2 = []
  562. while 1:
  563. _choice3 = self._pos
  564. try:
  565. _call_status = self._IGNORE()
  566. _result = _call_status.result
  567. _error = self._combine_errors(_error, _call_status.error)
  568. _all2.append(_result)
  569. except BacktrackException, _exc:
  570. _error = self._combine_errors(_error, _exc.error)
  571. self._pos = _choice3
  572. break
  573. _result = _all2
  574. _call_status = self._or_()
  575. _result = _call_status.result
  576. _error = self._combine_errors(_error, _call_status.error)
  577. what = _result
  578. _all4 = []
  579. while 1:
  580. _choice5 = self._pos
  581. try:
  582. _call_status = self._IGNORE()
  583. _result = _call_status.result
  584. _error = self._combine_errors(_error, _call_status.error)
  585. _all4.append(_result)
  586. except BacktrackException, _exc:
  587. _error = self._combine_errors(_error, _exc.error)
  588. self._pos = _choice5
  589. break
  590. _result = _all4
  591. _result = self.__chars__(';')
  592. _all6 = []
  593. while 1:
  594. _choice7 = self._pos
  595. try:
  596. _call_status = self._IGNORE()
  597. _result = _call_status.result
  598. _error = self._combine_errors(_error, _call_status.error)
  599. _all6.append(_result)
  600. except BacktrackException, _exc:
  601. _error = self._combine_errors(_error, _exc.error)
  602. self._pos = _choice7
  603. break
  604. _result = _all6
  605. _result = (Nonterminal('production', [name, args, what]))
  606. if _status.status == _status.LEFTRECURSION:
  607. if _status.result is not None:
  608. if _status.pos >= self._pos:
  609. _status.status = _status.NORMAL
  610. self._pos = _status.pos
  611. return _status
  612. _status.pos = self._pos
  613. _status.status = _status.SOMESOLUTIONS
  614. _status.result = _result
  615. _status.error = _error
  616. self._pos = _startingpos
  617. return self._production()
  618. _status.status = _status.NORMAL
  619. _status.pos = self._pos
  620. _status.result = _result
  621. _status.error = _error
  622. return _status
  623. except BacktrackException, _exc:
  624. _status.pos = -1
  625. _status.result = None
  626. _error = self._combine_errors(_error, _exc.error)
  627. _status.error = _error
  628. _status.status = _status.ERROR
  629. raise BacktrackException(_error)
  630. def productionargs(self):
  631. return self._productionargs().result
  632. def _productionargs(self):
  633. _key = self._pos
  634. _status = self._dict_productionargs.get(_key, None)
  635. if _status is None:
  636. _status = self._dict_productionargs[_key] = Status()
  637. else:
  638. _statusstatus = _status.status
  639. if _statusstatus == _status.NORMAL:
  640. self._pos = _status.pos
  641. return _status
  642. elif _statusstatus == _status.ERROR:
  643. raise BacktrackException(_status.error)
  644. elif (_statusstatus == _status.INPROGRESS or
  645. _statusstatus == _status.LEFTRECURSION):
  646. _status.status = _status.LEFTRECURSION
  647. if _status.result is not None:
  648. self._pos = _status.pos
  649. return _status
  650. else:
  651. raise BacktrackException(None)
  652. elif _statusstatus == _status.SOMESOLUTIONS:
  653. _status.status = _status.INPROGRESS
  654. _startingpos = self._pos
  655. try:
  656. _result = None
  657. _error = None
  658. while 1:
  659. _choice0 = self._pos
  660. try:
  661. _result = self.__chars__('(')
  662. _all1 = []
  663. while 1:
  664. _choice2 = self._pos
  665. try:
  666. _call_status = self._IGNORE()
  667. _result = _call_status.result
  668. _error = _call_status.error
  669. _all1.append(_result)
  670. except BacktrackException, _exc:
  671. _error = self._combine_errors(_error, _exc.error)
  672. self._pos = _choice2
  673. break
  674. _result = _all1
  675. _all3 = []
  676. while 1:
  677. _choice4 = self._pos
  678. try:
  679. _call_status = self._NAME()
  680. _result = _call_status.result
  681. _error = self._combine_errors(_error, _call_status.error)
  682. _before_discard5 = _result
  683. _all6 = []
  684. while 1:
  685. _choice7 = self._pos
  686. try:
  687. _call_status = self._IGNORE()
  688. _result = _call_status.result
  689. _error = self._combine_errors(_error, _call_status.error)
  690. _all6.append(_result)
  691. except BacktrackException, _exc:
  692. _error = self._combine_errors(_error, _exc.error)
  693. self._pos = _choice7
  694. break
  695. _result = _all6
  696. _result = self.__chars__(',')
  697. _all8 = []
  698. while 1:
  699. _choice9 = self._pos
  700. try:
  701. _call_status = self._IGNORE()
  702. _result = _call_status.result
  703. _error = self._combine_errors(_error, _call_status.error)
  704. _all8.append(_result)
  705. except BacktrackException, _exc:
  706. _error = self._combine_errors(_error, _exc.error)
  707. self._pos = _choice9
  708. break
  709. _result = _all8
  710. _result = _before_discard5
  711. _all3.append(_result)
  712. except BacktrackException, _exc:
  713. _error = self._combine_errors(_error, _exc.error)
  714. self._pos = _choice4
  715. break
  716. _result = _all3
  717. args = _result
  718. _call_status = self._NAME()
  719. _result = _call_status.result
  720. _error = self._combine_errors(_error, _call_status.error)
  721. arg = _result
  722. _all10 = []
  723. while 1:
  724. _choice11 = self._pos
  725. try:
  726. _call_status = self._IGNORE()
  727. _result = _call_status.result
  728. _error = self._combine_errors(_error, _call_status.error)
  729. _all10.append(_result)
  730. except BacktrackException, _exc:
  731. _error = self._combine_errors(_error, _exc.error)
  732. self._pos = _choice11
  733. break
  734. _result = _all10
  735. _result = self.__chars__(')')
  736. _all12 = []
  737. while 1:
  738. _choice13 = self._pos
  739. try:
  740. _call_status = self._IGNORE()
  741. _result = _call_status.result
  742. _error = self._combine_errors(_error, _call_status.error)
  743. _all12.append(_result)
  744. except BacktrackException, _exc:
  745. _error = self._combine_errors(_error, _exc.error)
  746. self._pos = _choice13
  747. break
  748. _result = _all12
  749. _result = (Nonterminal('productionargs', args + [arg]))
  750. break
  751. except BacktrackException, _exc:
  752. _error = self._combine_errors(_error, _exc.error)
  753. self._pos = _choice0
  754. _choice14 = self._pos
  755. try:
  756. _result = (Nonterminal('productionargs', []))
  757. break
  758. except BacktrackException, _exc:
  759. _error = self._combine_errors(_error, _exc.error)
  760. self._pos = _choice14
  761. raise BacktrackException(_error)
  762. _result = (Nonterminal('productionargs', []))
  763. break
  764. if _status.status == _status.LEFTRECURSION:
  765. if _status.result is not None:
  766. if _status.pos >= self._pos:
  767. _status.status = _status.NORMAL
  768. self._pos = _status.pos
  769. return _status
  770. _status.pos = self._pos
  771. _status.status = _status.SOMESOLUTIONS
  772. _status.result = _result
  773. _status.error = _error
  774. self._pos = _startingpos
  775. return self._productionargs()
  776. _status.status = _status.NORMAL
  777. _status.pos = self._pos
  778. _status.result = _result
  779. _status.error = _error
  780. return _status
  781. except BacktrackException, _exc:
  782. _status.pos = -1
  783. _status.result = None
  784. _error = self._combine_errors(_error, _exc.error)
  785. _status.error = _error
  786. _status.status = _status.ERROR
  787. raise BacktrackException(_error)
  788. def or_(self):
  789. return self._or_().result
  790. def _or_(self):
  791. _key = self._pos
  792. _status = self._dict_or_.get(_key, None)
  793. if _status is None:
  794. _status = self._dict_or_[_key] = Status()
  795. else:
  796. _statusstatus = _status.status
  797. if _statusstatus == _status.NORMAL:
  798. self._pos = _status.pos
  799. return _status
  800. elif _statusstatus == _status.ERROR:
  801. raise BacktrackException(_status.error)
  802. elif (_statusstatus == _status.INPROGRESS or
  803. _statusstatus == _status.LEFTRECURSION):
  804. _status.status = _status.LEFTRECURSION
  805. if _status.result is not None:
  806. self._pos = _status.pos
  807. return _status
  808. else:
  809. raise BacktrackException(None)
  810. elif _statusstatus == _status.SOMESOLUTIONS:
  811. _status.status = _status.INPROGRESS
  812. _startingpos = self._pos
  813. try:
  814. _result = None
  815. _error = None
  816. while 1:
  817. _choice0 = self._pos
  818. try:
  819. _all1 = []
  820. _call_status = self._commands()
  821. _result = _call_status.result
  822. _error = _call_status.error
  823. _before_discard2 = _result
  824. _result = self.__chars__('|')
  825. _all3 = []
  826. while 1:
  827. _choice4 = self._pos
  828. try:
  829. _call_status = self._IGNORE()
  830. _result = _call_status.result
  831. _error = self._combine_errors(_error, _call_status.error)
  832. _all3.append(_result)
  833. except BacktrackException, _exc:
  834. _error = self._combine_errors(_error, _exc.error)
  835. self._pos = _choice4
  836. break
  837. _result = _all3
  838. _result = _before_discard2
  839. _all1.append(_result)
  840. while 1:
  841. _choice5 = self._pos
  842. try:
  843. _call_status = self._commands()
  844. _result = _call_status.result
  845. _error = self._combine_errors(_error, _call_status.error)
  846. _before_discard6 = _result
  847. _result = self.__chars__('|')
  848. _all7 = []
  849. while 1:
  850. _choice8 = self._pos
  851. try:
  852. _call_status = self._IGNORE()
  853. _result = _call_status.result
  854. _error = self._combine_errors(_error, _call_status.error)
  855. _all7.append(_result)
  856. except BacktrackException, _exc:
  857. _error = self._combine_errors(_error, _exc.error)
  858. self._pos = _choice8
  859. break
  860. _result = _all7
  861. _result = _before_discard6
  862. _all1.append(_result)
  863. except BacktrackException, _exc:
  864. _error = self._combine_errors(_error, _exc.error)
  865. self._pos = _choice5
  866. break
  867. _result = _all1
  868. l = _result
  869. _call_status = self._commands()
  870. _result = _call_status.result
  871. _error = self._combine_errors(_error, _call_status.error)
  872. last = _result
  873. _result = (Nonterminal('or', l + [last]))
  874. break
  875. except BacktrackException, _exc:
  876. _error = self._combine_errors(_error, _exc.error)
  877. self._pos = _choice0
  878. _choice9 = self._pos
  879. try:
  880. _call_status = self._commands()
  881. _result = _call_status.result
  882. _error = self._combine_errors(_error, _call_status.error)
  883. break
  884. except BacktrackException, _exc:
  885. _error = self._combine_errors(_error, _exc.error)
  886. self._pos = _choice9
  887. raise BacktrackException(_error)
  888. _call_status = self._commands()
  889. _result = _call_status.result
  890. _error = self._combine_errors(_error, _call_status.error)
  891. break
  892. if _status.status == _status.LEFTRECURSION:
  893. if _status.result is not None:
  894. if _status.pos >= self._pos:
  895. _status.status = _status.NORMAL
  896. self._pos = _status.pos
  897. return _status
  898. _status.pos = self._pos
  899. _status.status = _status.SOMESOLUTIONS
  900. _status.result = _result
  901. _status.error = _error
  902. self._pos = _startingpos
  903. return self._or_()
  904. _status.status = _status.NORMAL
  905. _status.pos = self._pos
  906. _status.result = _result
  907. _status.error = _error
  908. return _status
  909. except BacktrackException, _exc:
  910. _status.pos = -1
  911. _status.result = None
  912. _error = self._combine_errors(_error, _exc.error)
  913. _status.error = _error
  914. _status.status = _status.ERROR
  915. raise BacktrackException(_error)
  916. def commands(self):
  917. return self._commands().result
  918. def _commands(self):
  919. _key = self._pos
  920. _status = self._dict_commands.get(_key, None)
  921. if _status is None:
  922. _status = self._dict_commands[_key] = Status()
  923. else:
  924. _statusstatus = _status.status
  925. if _statusstatus == _status.NORMAL:
  926. self._pos = _status.pos
  927. return _status
  928. elif _statusstatus == _status.ERROR:
  929. raise BacktrackException(_status.error)
  930. elif (_statusstatus == _status.INPROGRESS or
  931. _statusstatus == _status.LEFTRECURSION):
  932. _status.status = _status.LEFTRECURSION
  933. if _status.result is not None:
  934. self._pos = _status.pos
  935. return _status
  936. else:
  937. raise BacktrackException(None)
  938. elif _statusstatus == _status.SOMESOLUTIONS:
  939. _status.status = _status.INPROGRESS
  940. _startingpos = self._pos
  941. try:
  942. _result = None
  943. _error = None
  944. while 1:
  945. _choice0 = self._pos
  946. try:
  947. _call_status = self._command()
  948. _result = _call_status.result
  949. _error = _call_status.error
  950. cmd = _result
  951. _call_status = self._newline()
  952. _result = _call_status.result
  953. _error = self._combine_errors(_error, _call_status.error)
  954. _all1 = []
  955. _call_status = self._command()
  956. _result = _call_status.result
  957. _error = self._combine_errors(_error, _call_status.error)
  958. _before_discard2 = _result
  959. _call_status = self._newline()
  960. _result = _call_status.result
  961. _error = self._combine_errors(_error, _call_status.error)
  962. _result = _before_discard2
  963. _all1.append(_result)
  964. while 1:
  965. _choice3 = self._pos
  966. try:
  967. _call_status = self._command()
  968. _result = _call_status.result
  969. _error = self._combine_errors(_error, _call_status.error)
  970. _before_discard4 = _result
  971. _call_status = self._newline()
  972. _result = _call_status.result
  973. _error = self._combine_errors(_error, _call_status.error)
  974. _result = _before_discard4
  975. _all1.append(_result)
  976. except BacktrackException, _exc:
  977. _error = self._combine_errors(_error, _exc.error)
  978. self._pos = _choice3
  979. break
  980. _result = _all1
  981. cmds = _result
  982. _result = (Nonterminal('commands', [cmd] + cmds))
  983. break
  984. except BacktrackException, _exc:
  985. _error = self._combine_errors(_error, _exc.error)
  986. self._pos = _choice0
  987. _choice5 = self._pos
  988. try:
  989. _call_status = self._command()
  990. _result = _call_status.result
  991. _error = self._combine_errors(_error, _call_status.error)
  992. break
  993. except BacktrackException, _exc:
  994. _error = self._combine_errors(_error, _exc.error)
  995. self._pos = _choice5
  996. raise BacktrackException(_error)
  997. _call_status = self._command()
  998. _result = _call_status.result
  999. _error = self._combine_errors(_error, _call_status.error)
  1000. break
  1001. if _status.status == _status.LEFTRECURSION:
  1002. if _status.result is not None:
  1003. if _status.pos >= self._pos:
  1004. _status.status = _status.NORMAL
  1005. self._pos = _status.pos
  1006. return _status
  1007. _status.pos = self._pos
  1008. _status.status = _status.SOMESOLUTIONS
  1009. _status.result = _result
  1010. _status.error = _error
  1011. self._pos = _startingpos
  1012. return self._commands()
  1013. _status.status = _status.NORMAL
  1014. _status.pos = self._pos
  1015. _status.result = _result
  1016. _status.error = _error
  1017. return _status
  1018. except BacktrackException, _exc:
  1019. _status.pos = -1
  1020. _status.result = None
  1021. _error = self._combine_errors(_error, _exc.error)
  1022. _status.error = _error
  1023. _status.status = _status.ERROR
  1024. raise BacktrackException(_error)
  1025. def command(self):
  1026. return self._command().result
  1027. def _command(self):
  1028. _key = self._pos
  1029. _status = self._dict_command.get(_key, None)
  1030. if _status is None:
  1031. _status = self._dict_command[_key] = Status()
  1032. else:
  1033. _statusstatus = _status.status
  1034. if _statusstatus == _status.NORMAL:
  1035. self._pos = _status.pos
  1036. return _status
  1037. elif _statusstatus == _status.ERROR:
  1038. raise BacktrackException(_status.error)
  1039. elif (_statusstatus == _status.INPROGRESS or
  1040. _statusstatus == _status.LEFTRECURSION):
  1041. _status.status = _status.LEFTRECURSION
  1042. if _status.result is not None:
  1043. self._pos = _status.pos
  1044. return _status
  1045. else:
  1046. raise BacktrackException(None)
  1047. elif _statusstatus == _status.SOMESOLUTIONS:
  1048. _status.status = _status.INPROGRESS
  1049. _startingpos = self._pos
  1050. try:
  1051. _result = None
  1052. _error = None
  1053. _call_status = self._simplecommand()
  1054. _result = _call_status.result
  1055. _error = _call_status.error
  1056. if _status.status == _status.LEFTRECURSION:
  1057. if _status.result is not None:
  1058. if _status.pos >= self._pos:
  1059. _status.status = _status.NORMAL
  1060. self._pos = _status.pos
  1061. return _status
  1062. _status.pos = self._pos
  1063. _status.status = _status.SOMESOLUTIONS
  1064. _status.result = _result
  1065. _status.error = _error
  1066. self._pos = _startingpos
  1067. return self._command()
  1068. _status.status = _status.NORMAL
  1069. _status.pos = self._pos
  1070. _status.result = _result
  1071. _status.error = _error
  1072. return _status
  1073. except BacktrackException, _exc:
  1074. _status.pos = -1
  1075. _status.result = None
  1076. _error = self._combine_errors(_error, _exc.error)
  1077. _status.error = _error
  1078. _status.status = _status.ERROR
  1079. raise BacktrackException(_error)
  1080. def simplecommand(self):
  1081. return self._simplecommand().result
  1082. def _simplecommand(self):
  1083. _key = self._pos
  1084. _status = self._dict_simplecommand.get(_key, None)
  1085. if _status is None:
  1086. _status = self._dict_simplecommand[_key] = Status()
  1087. else:
  1088. _statusstatus = _status.status
  1089. if _statusstatus == _status.NORMAL:
  1090. self._pos = _status.pos
  1091. return _status
  1092. elif _statusstatus == _status.ERROR:
  1093. raise BacktrackException(_status.error)
  1094. elif (_statusstatus == _status.INPROGRESS or
  1095. _statusstatus == _status.LEFTRECURSION):
  1096. _status.status = _status.LEFTRECURSION
  1097. if _status.result is not None:
  1098. self._pos = _status.pos
  1099. return _status
  1100. else:
  1101. raise BacktrackException(None)
  1102. elif _statusstatus == _status.SOMESOLUTIONS:
  1103. _status.status = _status.INPROGRESS
  1104. _startingpos = self._pos
  1105. try:
  1106. _result = None
  1107. _error = None
  1108. while 1:
  1109. _choice0 = self._pos
  1110. try:
  1111. _call_status = self._return_()
  1112. _result = _call_status.result
  1113. _error = _call_status.error
  1114. break
  1115. except BacktrackException, _exc:
  1116. _error = self._combine_errors(_error, _exc.error)
  1117. self._pos = _choice0
  1118. _choice1 = self._pos
  1119. try:
  1120. _call_status = self._if_()
  1121. _result = _call_status.result
  1122. _error = self._combine_errors(_error, _call_status.error)
  1123. break
  1124. except BacktrackException, _exc:
  1125. _error = self._combine_errors(_error, _exc.error)
  1126. self._pos = _choice1
  1127. _choice2 = self._pos
  1128. try:
  1129. _call_status = self._named_command()
  1130. _result = _call_status.result
  1131. _error = self._combine_errors(_error, _call_status.error)
  1132. break
  1133. except BacktrackException, _exc:
  1134. _error = self._combine_errors(_error, _exc.error)
  1135. self._pos = _choice2
  1136. _choice3 = self._pos
  1137. try:
  1138. _call_status = self._repetition()
  1139. _result = _call_status.result
  1140. _error = self._combine_errors(_error, _call_status.error)
  1141. break
  1142. except BacktrackException, _exc:
  1143. _error = self._combine_errors(_error, _exc.error)
  1144. self._pos = _choice3
  1145. _choice4 = self._pos
  1146. try:
  1147. _call_status = self._choose()
  1148. _result = _call_status.result
  1149. _error = self._combine_errors(_error, _call_status.error)
  1150. break
  1151. except BacktrackException, _exc:
  1152. _error = self._combine_errors(_error, _exc.error)
  1153. self._pos = _choice4
  1154. _choice5 = self._pos
  1155. try:
  1156. _call_status = self._negation()
  1157. _result = _call_status.result
  1158. _error = self._combine_errors(_error, _call_status.error)
  1159. break
  1160. except BacktrackException, _exc:
  1161. _error = self._combine_errors(_error, _exc.error)
  1162. self._pos = _choice5
  1163. raise BacktrackException(_error)
  1164. _call_status = self._negation()
  1165. _result = _call_status.result
  1166. _error = self._combine_errors(_error, _call_status.error)
  1167. break
  1168. if _status.status == _status.LEFTRECURSION:
  1169. if _status.result is not None:
  1170. if _status.pos >= self._pos:
  1171. _status.status = _status.NORMAL
  1172. self._pos = _status.pos
  1173. return _status
  1174. _status.pos = self._pos
  1175. _status.status = _status.SOMESOLUTIONS
  1176. _status.result = _result
  1177. _status.error = _error
  1178. self._pos = _startingpos
  1179. return self._simplecommand()
  1180. _status.status = _status.NORMAL
  1181. _status.pos = self._pos
  1182. _status.result = _result
  1183. _status.error = _error
  1184. return _status
  1185. except Backtrac