PageRenderTime 66ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/jaspyon/rlib/parsing/pypackrat.py

https://bitbucket.org/santagada/jaspyon
Python | 3132 lines | 3125 code | 1 blank | 6 comment | 704 complexity | 122778248a578102a2c5d8c79f554b2b MD5 | raw 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 BacktrackException, _exc:
  1186. _status.pos = -1
  1187. _status.result = None
  1188. _error = self._combine_errors(_error, _exc.error)
  1189. _status.error = _error
  1190. _status.status = _status.ERROR
  1191. raise BacktrackException(_error)
  1192. def return_(self):
  1193. return self._return_().result
  1194. def _return_(self):
  1195. _key = self._pos
  1196. _status = self._dict_return_.get(_key, None)
  1197. if _status is None:
  1198. _status = self._dict_return_[_key] = Status()
  1199. else:
  1200. _statusstatus = _status.status
  1201. if _statusstatus == _status.NORMAL:
  1202. self._pos = _status.pos
  1203. return _status
  1204. elif _statusstatus == _status.ERROR:
  1205. raise BacktrackException(_status.error)
  1206. elif (_statusstatus == _status.INPROGRESS or
  1207. _statusstatus == _status.LEFTRECURSION):
  1208. _status.status = _status.LEFTRECURSION
  1209. if _status.result is not None:
  1210. self._pos = _status.pos
  1211. return _status
  1212. else:
  1213. raise BacktrackException(None)
  1214. elif _statusstatus == _status.SOMESOLUTIONS:
  1215. _status.status = _status.INPROGRESS
  1216. _startingpos = self._pos
  1217. try:
  1218. _result = None
  1219. _error = None
  1220. _result = self.__chars__('return')
  1221. _all0 = []
  1222. while 1:
  1223. _choice1 = self._pos
  1224. try:
  1225. _call_status = self._SPACE()
  1226. _result = _call_status.result
  1227. _error = _call_status.error
  1228. _all0.append(_result)
  1229. except BacktrackException, _exc:
  1230. _error = self._combine_errors(_error, _exc.error)
  1231. self._pos = _choice1
  1232. break
  1233. _result = _all0
  1234. _call_status = self._PYTHONCODE()
  1235. _result = _call_status.result
  1236. _error = self._combine_errors(_error, _call_status.error)
  1237. code = _result
  1238. _all2 = []
  1239. while 1:
  1240. _choice3 = self._pos
  1241. try:
  1242. _call_status = self._IGNORE()
  1243. _result = _call_status.result
  1244. _error = self._combine_errors(_error, _call_status.error)
  1245. _all2.append(_result)
  1246. except BacktrackException, _exc:
  1247. _error = self._combine_errors(_error, _exc.error)
  1248. self._pos = _choice3
  1249. break
  1250. _result = _all2
  1251. _result = (Nonterminal('return', [code]))
  1252. if _status.status == _status.LEFTRECURSION:
  1253. if _status.result is not None:
  1254. if _status.pos >= self._pos:
  1255. _status.status = _status.NORMAL
  1256. self._pos = _status.pos
  1257. return _status
  1258. _status.pos = self._pos
  1259. _status.status = _status.SOMESOLUTIONS
  1260. _status.result = _result
  1261. _status.error = _error
  1262. self._pos = _startingpos
  1263. return self._return_()
  1264. _status.status = _status.NORMAL
  1265. _status.pos = self._pos
  1266. _status.result = _result
  1267. _status.error = _error
  1268. return _status
  1269. except BacktrackException, _exc:
  1270. _status.pos = -1
  1271. _status.result = None
  1272. _error = self._combine_errors(_error, _exc.error)
  1273. _status.error = _error
  1274. _status.status = _status.ERROR
  1275. raise BacktrackException(_error)
  1276. def if_(self):
  1277. return self._if_().result
  1278. def _if_(self):
  1279. _key = self._pos
  1280. _status = self._dict_if_.get(_key, None)
  1281. if _status is None:
  1282. _status = self._dict_if_[_key] = Status()
  1283. else:
  1284. _statusstatus = _status.status
  1285. if _statusstatus == _status.NORMAL:
  1286. self._pos = _status.pos
  1287. return _status
  1288. elif _statusstatus == _status.ERROR:
  1289. raise BacktrackException(_status.error)
  1290. elif (_statusstatus == _status.INPROGRESS or
  1291. _statusstatus == _status.LEFTRECURSION):
  1292. _status.status = _status.LEFTRECURSION
  1293. if _status.result is not None:
  1294. self._pos = _status.pos
  1295. return _status
  1296. else:
  1297. raise BacktrackException(None)
  1298. elif _statusstatus == _status.SOMESOLUTIONS:
  1299. _status.status = _status.INPROGRESS
  1300. _startingpos = self._pos
  1301. try:
  1302. _result = None
  1303. _error = None
  1304. while 1:
  1305. _choice0 = self._pos
  1306. try:
  1307. _result = self.__chars__('do')
  1308. _call_status = self._newline()
  1309. _result = _call_status.result
  1310. _error = _call_status.error
  1311. _call_status = self._command()
  1312. _result = _call_status.result
  1313. _error = self._combine_errors(_error, _call_status.error)
  1314. cmd = _result
  1315. _all1 = []
  1316. while 1:
  1317. _choice2 = self._pos
  1318. try:
  1319. _call_status = self._SPACE()
  1320. _result = _call_status.result
  1321. _error = self._combine_errors(_error, _call_status.error)
  1322. _all1.append(_result)
  1323. except BacktrackException, _exc:
  1324. _error = self._combine_errors(_error, _exc.error)
  1325. self._pos = _choice2
  1326. break
  1327. _result = _all1
  1328. _result = self.__chars__('if')
  1329. _all3 = []
  1330. while 1:
  1331. _choice4 = self._pos
  1332. try:
  1333. _call_status = self._SPACE()
  1334. _result = _call_status.result
  1335. _error = self._combine_errors(_error, _call_status.error)
  1336. _all3.append(_result)
  1337. except BacktrackException, _exc:
  1338. _error = self._combine_errors(_error, _exc.error)
  1339. self._pos = _choice4
  1340. break
  1341. _result = _all3
  1342. _call_status = self._PYTHONCODE()
  1343. _result = _call_status.result
  1344. _error = self._combine_errors(_error, _call_status.error)
  1345. condition = _result
  1346. _all5 = []
  1347. while 1:
  1348. _choice6 = self._pos
  1349. try:
  1350. _call_status = self._IGNORE()
  1351. _result = _call_status.result
  1352. _error = self._combine_errors(_error, _call_status.error)
  1353. _all5.append(_result)
  1354. except BacktrackException, _exc:
  1355. _error = self._combine_errors(_error, _exc.error)
  1356. self._pos = _choice6
  1357. break
  1358. _result = _all5
  1359. _result = (Nonterminal('if', [cmd, condition]))
  1360. break
  1361. except BacktrackException, _exc:
  1362. _error = self._combine_errors(_error, _exc.error)
  1363. self._pos = _choice0
  1364. _choice7 = self._pos
  1365. try:
  1366. _result = self.__chars__('if')
  1367. _all8 = []
  1368. while 1:
  1369. _choice9 = self._pos
  1370. try:
  1371. _call_status = self._SPACE()
  1372. _result = _call_status.result
  1373. _error = self._combine_errors(_error, _call_status.error)
  1374. _all8.append(_result)
  1375. except BacktrackException, _exc:
  1376. _error = self._combine_errors(_error, _exc.error)
  1377. self._pos = _choice9
  1378. break
  1379. _result = _all8
  1380. _call_status = self._PYTHONCODE()
  1381. _result = _call_status.result
  1382. _error = self._combine_errors(_error, _call_status.error)
  1383. condition = _result
  1384. _all10 = []
  1385. while 1:
  1386. _choice11 = self._pos
  1387. try:
  1388. _call_status = self._IGNORE()
  1389. _result = _call_status.result
  1390. _error = self._combine_errors(_error, _call_status.error)
  1391. _all10.append(_result)
  1392. except BacktrackException, _exc:
  1393. _error = self._combine_errors(_error, _exc.error)
  1394. self._pos = _choice11
  1395. break
  1396. _result = _all10
  1397. _result = (Nonterminal('if', [condition]))
  1398. break
  1399. except BacktrackException, _exc:
  1400. _error = self._combine_errors(_error, _exc.error)
  1401. self._pos = _choice7
  1402. raise BacktrackException(_error)
  1403. _result = self.__chars__('if')
  1404. _all12 = []
  1405. while 1:
  1406. _choice13 = self._pos
  1407. try:
  1408. _call_status = self._SPACE()
  1409. _result = _call_status.result
  1410. _error = self._combine_errors(_error, _call_status.error)
  1411. _all12.append(_result)
  1412. except BacktrackException, _exc:
  1413. _error = self._combine_errors(_error, _exc.error)
  1414. self._pos = _choice13
  1415. break
  1416. _result = _all12
  1417. _call_status = self._PYTHONCODE()
  1418. _result = _call_status.result
  1419. _error = self._combine_errors(_error, _call_status.error)
  1420. condition = _result
  1421. _all14 = []
  1422. while 1:
  1423. _choice15 = self._pos
  1424. try:
  1425. _call_status = self._IGNORE()
  1426. _result = _call_status.result
  1427. _error = self._combine_errors(_error, _call_status.error)
  1428. _all14.append(_result)
  1429. except BacktrackException, _exc:
  1430. _error = self._combine_errors(_error, _exc.error)
  1431. self._pos = _choice15
  1432. break
  1433. _result = _all14
  1434. _result = (Nonterminal('if', [condition]))
  1435. break
  1436. if _status.status == _status.LEFTRECURSION:
  1437. if _status.result is not None:
  1438. if _status.pos >= self._pos:
  1439. _status.status = _status.NORMAL
  1440. self._pos = _status.pos
  1441. return _status
  1442. _status.pos = self._pos
  1443. _status.status = _status.SOMESOLUTIONS
  1444. _status.result = _result
  1445. _status.error = _error
  1446. self._pos = _startingpos
  1447. return self._if_()
  1448. _status.status = _status.NORMAL
  1449. _status.pos = self._pos
  1450. _status.result = _result
  1451. _status.error = _error
  1452. return _status
  1453. except BacktrackException, _exc:
  1454. _status.pos = -1
  1455. _status.result = None
  1456. _error = self._combine_errors(_error, _exc.error)
  1457. _status.error = _error
  1458. _status.status = _status.ERROR
  1459. raise BacktrackException(_error)
  1460. def choose(self):
  1461. return self._choose().result
  1462. def _choose(self):
  1463. _key = self._pos
  1464. _status = self._dict_choose.get(_key, None)
  1465. if _status is None:
  1466. _status = self._dict_choose[_key] = Status()
  1467. else:
  1468. _statusstatus = _status.status
  1469. if _statusstatus == _status.NORMAL:
  1470. self._pos = _status.pos
  1471. return _status
  1472. elif _statusstatus == _status.ERROR:
  1473. raise BacktrackException(_status.error)
  1474. elif (_statusstatus == _status.INPROGRESS or
  1475. _statusstatus == _status.LEFTRECURSION):
  1476. _status.status = _status.LEFTRECURSION
  1477. if _status.result is not None:
  1478. self._pos = _status.pos
  1479. return _status
  1480. else:
  1481. raise BacktrackException(None)
  1482. elif _statusstatus == _status.SOMESOLUTIONS:
  1483. _status.status = _status.INPROGRESS
  1484. _startingpos = self._pos
  1485. try:
  1486. _result = None
  1487. _error = None
  1488. _result = self.__chars__('choose')
  1489. _all0 = []
  1490. while 1:
  1491. _choice1 = self._pos
  1492. try:
  1493. _call_status = self._SPACE()
  1494. _result = _call_status.result
  1495. _error = _call_status.error
  1496. _all0.append(_result)
  1497. except BacktrackException, _exc:
  1498. _error = self._combine_errors(_error, _exc.error)
  1499. self._pos = _choice1
  1500. break
  1501. _result = _all0
  1502. _call_status = self._NAME()
  1503. _result = _call_status.result
  1504. _error = self._combine_errors(_error, _call_status.error)
  1505. name = _result
  1506. _all2 = []
  1507. while 1:
  1508. _choice3 = self._pos
  1509. try:
  1510. _call_status = self._SPACE()
  1511. _result = _call_status.result
  1512. _error = self._combine_errors(_error, _call_status.error)
  1513. _all2.append(_result)
  1514. except BacktrackException, _exc:
  1515. _error = self._combine_errors(_error, _exc.error)
  1516. self._pos = _choice3
  1517. break
  1518. _result = _all2
  1519. _result = self.__chars__('in')
  1520. _all4 = []
  1521. while 1:
  1522. _choice5 = self._pos
  1523. try:
  1524. _call_status = self._SPACE()
  1525. _result = _call_status.result
  1526. _error = self._combine_errors(_error, _call_status.error)
  1527. _all4.append(_result)
  1528. except BacktrackException, _exc:
  1529. _error = self._combine_errors(_error, _exc.error)
  1530. self._pos = _choice5
  1531. break
  1532. _result = _all4
  1533. _call_status = self._PYTHONCODE()
  1534. _result = _call_status.result
  1535. _error = self._combine_errors(_error, _call_status.error)
  1536. expr = _result
  1537. _all6 = []
  1538. while 1:
  1539. _choice7 = self._pos
  1540. try:
  1541. _call_status = self._IGNORE()
  1542. _result = _call_status.result
  1543. _error = self._combine_errors(_error, _call_status.error)
  1544. _all6.append(_result)
  1545. except BacktrackException, _exc:
  1546. _error = self._combine_errors(_error, _exc.error)
  1547. self._pos = _choice7
  1548. break
  1549. _result = _all6
  1550. _call_status = self._commands()
  1551. _result = _call_status.result
  1552. _error = self._combine_errors(_error, _call_status.error)
  1553. cmds = _result
  1554. _result = (Nonterminal('choose', [name, expr, cmds]))
  1555. if _status.status == _status.LEFTRECURSION:
  1556. if _status.result is not None:
  1557. if _status.pos >= self._pos:
  1558. _status.status = _status.NORMAL
  1559. self._pos = _status.pos
  1560. return _status
  1561. _status.pos = self._pos
  1562. _status.status = _status.SOMESOLUTIONS
  1563. _status.result = _result
  1564. _status.error = _error
  1565. self._pos = _startingpos
  1566. return self._choose()
  1567. _status.status = _status.NORMAL
  1568. _status.pos = self._pos
  1569. _status.result = _result
  1570. _status.error = _error
  1571. return _status
  1572. except BacktrackException, _exc:
  1573. _status.pos = -1
  1574. _status.result = None
  1575. _error = self._combine_errors(_error, _exc.error)
  1576. _status.error = _error
  1577. _status.status = _status.ERROR
  1578. raise BacktrackException(_error)
  1579. def commandchain(self):
  1580. return self._commandchain().result
  1581. def _commandchain(self):
  1582. _key = self._pos
  1583. _status = self._dict_commandchain.get(_key, None)
  1584. if _status is None:
  1585. _status = self._dict_commandchain[_key] = Status()
  1586. else:
  1587. _statusstatus = _status.status
  1588. if _statusstatus == _status.NORMAL:
  1589. self._pos = _status.pos
  1590. return _status
  1591. elif _statusstatus == _status.ERROR:
  1592. raise BacktrackException(_status.error)
  1593. elif (_statusstatus == _status.INPROGRESS or
  1594. _statusstatus == _status.LEFTRECURSION):
  1595. _status.status = _status.LEFTRECURSION
  1596. if _status.result is not None:
  1597. self._pos = _status.pos
  1598. return _status
  1599. else:
  1600. raise BacktrackException(None)
  1601. elif _statusstatus == _status.SOMESOLUTIONS:
  1602. _status.status = _status.INPROGRESS
  1603. _startingpos = self._pos
  1604. try:
  1605. _result = None
  1606. _error = None
  1607. _all0 = []
  1608. _call_status = self._simplecommand()
  1609. _result = _call_status.result
  1610. _error = _call_status.error
  1611. _all0.append(_result)
  1612. while 1:
  1613. _choice1 = self._pos
  1614. try:
  1615. _call_status = self._simplecommand()
  1616. _result = _call_status.result
  1617. _error = self._combine_errors(_error, _call_status.error)
  1618. _all0.append(_result)
  1619. except BacktrackException, _exc:
  1620. _error = self._combine_errors(_error, _exc.error)
  1621. self._pos = _choice1
  1622. break
  1623. _result = _all0
  1624. result = _result
  1625. _result = (Nonterminal('commands', result))
  1626. if _status.status == _status.LEFTRECURSION:
  1627. if _status.result is not None:
  1628. if _status.pos >= self._pos:
  1629. _status.status = _status.NORMAL
  1630. self._pos = _status.pos
  1631. return _status
  1632. _status.pos = self._pos
  1633. _status.status = _status.SOMESOLUTIONS
  1634. _status.result = _result
  1635. _status.error = _error
  1636. self._pos = _startingpos
  1637. return self._commandchain()
  1638. _status.status = _status.NORMAL
  1639. _status.pos = self._pos
  1640. _status.result = _result
  1641. _status.error = _error
  1642. return _status
  1643. except BacktrackException, _exc:
  1644. _status.pos = -1
  1645. _status.result = None
  1646. _error = self._combine_errors(_error, _exc.error)
  1647. _status.error = _error
  1648. _status.status = _status.ERROR
  1649. raise BacktrackException(_error)
  1650. def named_command(self):
  1651. return self._named_command().result
  1652. def _named_command(self):
  1653. _key = self._pos
  1654. _status = self._dict_named_command.get(_key, None)
  1655. if _status is None:
  1656. _status = self._dict_named_command[_key] = Status()
  1657. else:
  1658. _statusstatus = _status.status
  1659. if _statusstatus == _status.NORMAL:
  1660. self._pos = _status.pos
  1661. return _status
  1662. elif _statusstatus == _status.ERROR:
  1663. raise BacktrackException(_status.error)
  1664. elif (_statusstatus == _status.INPROGRESS or
  1665. _statusstatus == _status.LEFTRECURSION):
  1666. _status.status = _status.LEFTRECURSION
  1667. if _status.result is not None:
  1668. self._pos = _status.pos
  1669. return _status
  1670. else:
  1671. raise BacktrackException(None)
  1672. elif _statusstatus == _status.SOMESOLUTIONS:
  1673. _status.status = _status.INPROGRESS
  1674. _startingpos = self._pos
  1675. try:
  1676. _result = None
  1677. _error = None
  1678. _call_status = self._NAME()
  1679. _result = _call_status.result
  1680. _error = _call_status.error
  1681. name = _result
  1682. _all0 = []
  1683. while 1:
  1684. _choice1 = self._pos
  1685. try:
  1686. _call_status = self._SPACE()
  1687. _result = _call_status.result
  1688. _error = self._combine_errors(_error, _call_status.error)
  1689. _all0.append(_result)
  1690. except BacktrackException, _exc:
  1691. _error = self._combine_errors(_error, _exc.error)
  1692. self._pos = _choice1
  1693. break
  1694. _result = _all0
  1695. _result = self.__chars__('=')
  1696. _all2 = []
  1697. while 1:
  1698. _choice3 = self._pos
  1699. try:
  1700. _call_status = self._SPACE()
  1701. _result = _call_status.result
  1702. _error = self._combine_errors(_error, _call_status.error)
  1703. _all2.append(_result)
  1704. except BacktrackException, _exc:
  1705. _error = self._combine_errors(_error, _exc.error)
  1706. self._pos = _choice3
  1707. break
  1708. _result = _all2
  1709. _call_status = self._command()
  1710. _result = _call_status.result
  1711. _error = self._combine_errors(_error, _call_status.error)
  1712. cmd = _result
  1713. _result = (Nonterminal('named_command', [name, cmd]))
  1714. if _status.status == _status.LEFTRECURSION:
  1715. if _status.result is not None:
  1716. if _status.pos >= self._pos:
  1717. _status.status = _status.NORMAL
  1718. self._pos = _status.pos
  1719. return _status
  1720. _status.pos = self._pos
  1721. _status.status = _status.SOMESOLUTIONS
  1722. _status.result = _result
  1723. _status.error = _error
  1724. self._pos = _startingpos
  1725. return self._named_command()
  1726. _status.status = _status.NORMAL
  1727. _status.pos = self._pos
  1728. _status.result = _result
  1729. _status.error = _error
  1730. return _status
  1731. except BacktrackException, _exc:
  1732. _status.pos = -1
  1733. _status.result = None
  1734. _error = self._combine_errors(_error, _exc.error)
  1735. _status.error = _error
  1736. _status.status = _status.ERROR
  1737. raise BacktrackException(_error)
  1738. def repetition(self):
  1739. return self._repetition().result
  1740. def _repetition(self):
  1741. _key = self._pos
  1742. _status = self._dict_repetition.get(_key, None)
  1743. if _status is None:
  1744. _status = self._dict_repetition[_key] = Status()
  1745. else:
  1746. _statusstatus = _status.status
  1747. if _statusstatus == _status.NORMAL:
  1748. self._pos = _status.pos
  1749. return _status
  1750. elif _statusstatus == _status.ERROR:
  1751. raise BacktrackException(_status.error)
  1752. elif (_statusstatus == _status.INPROGRESS or
  1753. _statusstatus == _status.LEFTRECURSION):
  1754. _status.status = _status.LEFTRECURSION
  1755. if _status.result is not None:
  1756. self._pos = _status.pos
  1757. return _status
  1758. else:
  1759. raise BacktrackException(None)
  1760. elif _statusstatus == _status.SOMESOLUTIONS:
  1761. _status.status = _status.INPROGRESS
  1762. _startingpos = self._pos
  1763. try:
  1764. _result = None
  1765. _error = None
  1766. while 1:
  1767. _choice0 = self._pos
  1768. try:
  1769. _call_status = self._enclosed()
  1770. _result = _call_status.result
  1771. _error = _call_status.error
  1772. what = _result
  1773. _all1 = []
  1774. while 1:
  1775. _choice2 = self._pos
  1776. try:
  1777. _call_status = self._SPACE()
  1778. _result = _call_status.result
  1779. _error = self._combine_errors(_error, _call_status.error)
  1780. _all1.append(_result)
  1781. except BacktrackException, _exc:
  1782. _error = self._combine_errors(_error, _exc.error)
  1783. self._pos = _choice2
  1784. break
  1785. _result = _all1
  1786. _result = self.__chars__('?')
  1787. _all3 = []
  1788. while 1:
  1789. _choice4 = self._pos
  1790. try:
  1791. _call_status = self._IGNORE()
  1792. _result = _call_status.result
  1793. _error = self._combine_errors(_error, _call_status.error)
  1794. _all3.append(_result)
  1795. except BacktrackException, _exc:
  1796. _error = self._combine_errors(_error, _exc.error)
  1797. self._pos = _choice4
  1798. break
  1799. _result = _all3
  1800. _result = (Nonterminal('maybe', [what]))
  1801. break
  1802. except BacktrackException, _exc:
  1803. _error = self._combine_errors(_error, _exc.error)
  1804. self._pos = _choice0
  1805. _choice5 = self._pos
  1806. try:
  1807. _call_status = self._enclosed()
  1808. _result = _call_status.result
  1809. _error = self._combine_errors(_error, _call_status.error)
  1810. what = _result
  1811. _all6 = []
  1812. while 1:
  1813. _choice7 = self._pos
  1814. try:
  1815. _call_status = self._SPACE()
  1816. _result = _call_status.result
  1817. _error = self._combine_errors(_error, _call_status.error)
  1818. _all6.append(_result)
  1819. except BacktrackException, _exc:
  1820. _error = self._combine_errors(_error, _exc.error)
  1821. self._pos = _choice7
  1822. break
  1823. _result = _all6
  1824. while 1:
  1825. _choice8 = self._pos
  1826. try:
  1827. _result = self.__chars__('*')
  1828. break
  1829. except BacktrackException, _exc:
  1830. _error = self._combine_errors(_error, _exc.error)
  1831. self._pos = _choice8
  1832. _choice9 = self._pos
  1833. try:
  1834. _result = self.__chars__('+')
  1835. break
  1836. except BacktrackException, _exc:
  1837. _error = self._combine_errors(_error, _exc.error)
  1838. self._pos = _choice9
  1839. raise BacktrackException(_error)
  1840. _result = self.__chars__('+')
  1841. break
  1842. repetition = _result
  1843. _all10 = []
  1844. while 1:
  1845. _choice11 = self._pos
  1846. try:
  1847. _call_status = self._IGNORE()
  1848. _result = _call_status.result
  1849. _error = self._combine_errors(_error, _call_status.error)
  1850. _all10.append(_result)
  1851. except BacktrackException, _exc:
  1852. _error = self._combine_errors(_error, _exc.error)
  1853. self._pos = _choice11
  1854. break
  1855. _result = _all10
  1856. _result = (Nonterminal('repetition', [repetition, what]))
  1857. break
  1858. except BacktrackException, _exc:
  1859. _error = self._combine_errors(_error, _exc.error)
  1860. self._pos = _choice5
  1861. raise BacktrackException(_error)
  1862. _call_status = self._enclosed()
  1863. _result = _call_status.result
  1864. _error = self._combine_errors(_error, _call_status.error)
  1865. what = _result
  1866. _all12 = []
  1867. while 1:
  1868. _choice13 = self._pos
  1869. try:
  1870. _call_status = self._SPACE()
  1871. _result = _call_status.result
  1872. _error = self._combine_errors(_error, _call_status.error)
  1873. _all12.append(_result)
  1874. except BacktrackException, _exc:
  1875. _error = self._combine_errors(_error, _exc.error)
  1876. self._pos = _choice13
  1877. break
  1878. _result = _all12
  1879. while 1:
  1880. _choice14 = self._pos
  1881. try:
  1882. _result = self.__chars__('*')
  1883. break
  1884. except BacktrackException, _exc:
  1885. _error = self._combine_errors(_error, _exc.error)
  1886. self._pos = _choice14
  1887. _choice15 = self._pos
  1888. try:
  1889. _result = self.__chars__('+')
  1890. break
  1891. except BacktrackException, _exc:
  1892. _error = self._combine_errors(_error, _exc.error)
  1893. self._pos = _choice15
  1894. raise BacktrackException(_error)
  1895. _result = self.__chars__('+')
  1896. break
  1897. repetition = _result
  1898. _all16 = []
  1899. while 1:
  1900. _choice17 = self._pos
  1901. try:
  1902. _call_status = self._IGNORE()
  1903. _result = _call_status.result
  1904. _error = self._combine_errors(_error, _call_status.error)
  1905. _all16.append(_result)
  1906. except BacktrackException, _exc:
  1907. _error = self._combine_errors(_error, _exc.error)
  1908. self._pos = _choice17
  1909. break
  1910. _result = _all16
  1911. _result = (Nonterminal('repetition', [repetition, what]))
  1912. break
  1913. if _status.status == _status.LEFTRECURSION:
  1914. if _status.result is not None:
  1915. if _status.pos >= self._pos:
  1916. _status.status = _status.NORMAL
  1917. self._pos = _status.pos
  1918. return _status
  1919. _status.pos = self._pos
  1920. _status.status = _status.SOMESOLUTIONS
  1921. _status.result = _result
  1922. _status.error = _error
  1923. self._pos = _startingpos
  1924. return self._repetition()
  1925. _status.status = _status.NORMAL
  1926. _status.pos = self._pos
  1927. _status.result = _result
  1928. _status.error = _error
  1929. return _status
  1930. except BacktrackException, _exc:
  1931. _status.pos = -1
  1932. _status.result = None
  1933. _error = self._combine_errors(_error, _exc.error)
  1934. _status.error = _error
  1935. _status.status = _status.ERROR
  1936. raise BacktrackException(_error)
  1937. def negation(self):
  1938. return self._negation().result
  1939. def _negation(self):
  1940. _key = self._pos
  1941. _status = self._dict_negation.get(_key, None)
  1942. if _status is None:
  1943. _status = self._dict_negation[_key] = Status()
  1944. else:
  1945. _statusstatus = _status.status
  1946. if _statusstatus == _status.NORMAL:
  1947. self._pos = _status.pos
  1948. return _status
  1949. elif _statusstatus == _status.ERROR:
  1950. raise BacktrackException(_status.error)
  1951. elif (_statusstatus == _status.INPROGRESS or
  1952. _statusstatus == _status.LEFTRECURSION):
  1953. _status.status = _status.LEFTRECURSION
  1954. if _status.result is not None:
  1955. self._pos = _status.pos
  1956. return _status
  1957. else:
  1958. raise BacktrackException(None)
  1959. elif _statusstatus == _status.SOMESOLUTIONS:
  1960. _status.status = _status.INPROGRESS
  1961. _startingpos = self._pos
  1962. try:
  1963. _result = None
  1964. _error = None
  1965. while 1:
  1966. _choice0 = self._pos
  1967. try:
  1968. _result = self.__chars__('!')
  1969. _all1 = []
  1970. while 1:
  1971. _choice2 = self._pos
  1972. try:
  1973. _call_status = self._SPACE()
  1974. _result = _call_status.result
  1975. _error = _call_status.error
  1976. _all1.append(_result)
  1977. except BacktrackException, _exc:
  1978. _error = self._combine_errors(_error, _exc.error)
  1979. self._pos = _choice2
  1980. break
  1981. _result = _all1
  1982. _call_status = self._negation()
  1983. _result = _call_status.result
  1984. _error = self._combine_errors(_error, _call_status.error)
  1985. what = _result
  1986. _all3 = []
  1987. while 1:
  1988. _choice4 = self._pos
  1989. try:
  1990. _call_status = self._IGNORE()
  1991. _result = _call_status.result
  1992. _error = self._combine_errors(_error, _call_status.error)
  1993. _all3.append(_result)
  1994. except BacktrackException, _exc:
  1995. _error = self._combine_errors(_error, _exc.error)
  1996. self._pos = _choice4
  1997. break
  1998. _result = _all3
  1999. _result = (Nonterminal('negation', [what]))
  2000. break
  2001. except BacktrackException, _exc:
  2002. _error = self._combine_errors(_error, _exc.error)
  2003. self._pos = _choice0
  2004. _choice5 = self._pos
  2005. try:
  2006. _call_status = self._enclosed()
  2007. _result = _call_status.result
  2008. _error = self._combine_errors(_error, _call_status.error)
  2009. break
  2010. except BacktrackException, _exc:
  2011. _error = self._combine_errors(_error, _exc.error)
  2012. self._pos = _choice5
  2013. raise BacktrackException(_error)
  2014. _call_status = self._enclosed()
  2015. _result = _call_status.result
  2016. _error = self._combine_errors(_error, _call_status.error)
  2017. break
  2018. if _status.status == _status.LEFTRECURSION:
  2019. if _status.result is not None:
  2020. if _status.pos >= self._pos:
  2021. _status.status = _status.NORMAL
  2022. self._pos = _status.pos
  2023. return _status
  2024. _status.pos = self._pos
  2025. _status.status = _status.SOMESOLUTIONS
  2026. _status.result = _result
  2027. _status.error = _error
  2028. self._pos = _startingpos
  2029. return self._negation()
  2030. _status.status = _status.NORMAL
  2031. _status.pos = self._pos
  2032. _status.result = _result
  2033. _status.error = _error
  2034. return _status
  2035. except BacktrackException, _exc:
  2036. _status.pos = -1
  2037. _status.result = None
  2038. _error = self._combine_errors(_error, _exc.error)
  2039. _status.error = _error
  2040. _status.status = _status.ERROR
  2041. raise BacktrackException(_error)
  2042. def enclosed(self):
  2043. return self._enclosed().result
  2044. def _enclosed(self):
  2045. _key = self._pos
  2046. _status = self._dict_enclosed.get(_key, None)
  2047. if _status is None:
  2048. _status = self._dict_enclosed[_key] = Status()
  2049. else:
  2050. _statusstatus = _status.status
  2051. if _statusstatus == _status.NORMAL:
  2052. self._pos = _status.pos
  2053. return _status
  2054. elif _statusstatus == _status.ERROR:
  2055. raise BacktrackException(_status.error)
  2056. elif (_statusstatus == _status.INPROGRESS or
  2057. _statusstatus == _status.LEFTRECURSION):
  2058. _status.status = _status.LEFTRECURSION
  2059. if _status.result is not None:
  2060. self._pos = _status.pos
  2061. return _status
  2062. else:
  2063. raise BacktrackException(None)
  2064. elif _statusstatus == _status.SOMESOLUTIONS:
  2065. _status.status = _status.INPROGRESS
  2066. _startingpos = self._pos
  2067. try:
  2068. _result = None
  2069. _error = None
  2070. while 1:
  2071. _choice0 = self._pos
  2072. try:
  2073. _result = self.__chars__('<')
  2074. _all1 = []
  2075. while 1:
  2076. _choice2 = self._pos
  2077. try:
  2078. _call_status = self._IGNORE()
  2079. _result = _call_status.result
  2080. _error = _call_status.error
  2081. _all1.append(_result)
  2082. except BacktrackException, _exc:
  2083. _error = self._combine_errors(_error, _exc.error)
  2084. self._pos = _choice2
  2085. break
  2086. _result = _all1
  2087. _call_status = self._primary()
  2088. _result = _call_status.result
  2089. _error = self._combine_errors(_error, _call_status.error)
  2090. what = _result
  2091. _all3 = []
  2092. while 1:
  2093. _choice4 = self._pos
  2094. try:
  2095. _call_status = self._IGNORE()
  2096. _result = _call_status.result
  2097. _error = self._combine_errors(_error, _call_status.error)
  2098. _all3.append(_result)
  2099. except BacktrackException, _exc:
  2100. _error = self._combine_errors(_error, _exc.error)
  2101. self._pos = _choice4
  2102. break
  2103. _result = _all3
  2104. _result = self.__chars__('>')
  2105. _all5 = []
  2106. while 1:
  2107. _choice6 = self._pos
  2108. try:
  2109. _call_status = self._IGNORE()
  2110. _result = _call_status.result
  2111. _error = self._combine_errors(_error, _call_status.error)
  2112. _all5.append(_result)
  2113. except BacktrackException, _exc:
  2114. _error = self._combine_errors(_error, _exc.error)
  2115. self._pos = _choice6
  2116. break
  2117. _result = _all5
  2118. _result = (Nonterminal('exclusive', [what]))
  2119. break
  2120. except BacktrackException, _exc:
  2121. _error = self._combine_errors(_error, _exc.error)
  2122. self._pos = _choice0
  2123. _choice7 = self._pos
  2124. try:
  2125. _result = self.__chars__('[')
  2126. _all8 = []
  2127. while 1:
  2128. _choice9 = self._pos
  2129. try:
  2130. _call_status = self._IGNORE()
  2131. _result = _call_status.result
  2132. _error = self._combine_errors(_error, _call_status.error)
  2133. _all8.append(_result)
  2134. except BacktrackException, _exc:
  2135. _error = self._combine_errors(_error, _exc.error)
  2136. self._pos = _choice9
  2137. break
  2138. _result = _all8
  2139. _call_status = self._or_()
  2140. _result = _call_status.result
  2141. _error = self._combine_errors(_error, _call_status.error)
  2142. what = _result
  2143. _all10 = []
  2144. while 1:
  2145. _choice11 = self._pos
  2146. try:
  2147. _call_status = self._IGNORE()
  2148. _result = _call_status.result
  2149. _error = self._combine_errors(_error, _call_status.error)
  2150. _all10.append(_result)
  2151. except BacktrackException, _exc:
  2152. _error = self._combine_errors(_error, _exc.error)
  2153. self._pos = _choice11
  2154. break
  2155. _result = _all10
  2156. _result = self.__chars__(']')
  2157. _all12 = []
  2158. while 1:
  2159. _choice13 = self._pos
  2160. try:
  2161. _call_status = self._IGNORE()
  2162. _result = _call_status.result
  2163. _error = self._combine_errors(_error, _call_status.error)
  2164. _all12.append(_result)
  2165. except BacktrackException, _exc:
  2166. _error = self._combine_errors(_error, _exc.error)
  2167. self._pos = _choice13
  2168. break
  2169. _result = _all12
  2170. _result = (Nonterminal('ignore', [what]))
  2171. break
  2172. except BacktrackException, _exc:
  2173. _error = self._combine_errors(_error, _exc.error)
  2174. self._pos = _choice7
  2175. _choice14 = self._pos
  2176. try:
  2177. _before_discard15 = _result
  2178. _result = self.__chars__('(')
  2179. _all16 = []
  2180. while 1:
  2181. _choice17 = self._pos
  2182. try:
  2183. _call_status = self._IGNORE()
  2184. _result = _call_status.result
  2185. _error = self._combine_errors(_error, _call_status.error)
  2186. _all16.append(_result)
  2187. except BacktrackException, _exc:
  2188. _error = self._combine_errors(_error, _exc.error)
  2189. self._pos = _choice17
  2190. break
  2191. _result = _all16
  2192. _result = _before_discard15
  2193. _call_status = self._or_()
  2194. _result = _call_status.result
  2195. _error = self._combine_errors(_error, _call_status.error)
  2196. _before_discard18 = _result
  2197. _result = self.__chars__(')')
  2198. _all19 = []
  2199. while 1:
  2200. _choice20 = self._pos
  2201. try:
  2202. _call_status = self._IGNORE()
  2203. _result = _call_status.result
  2204. _error = self._combine_errors(_error, _call_status.error)
  2205. _all19.append(_result)
  2206. except BacktrackException, _exc:
  2207. _error = self._combine_errors(_error, _exc.error)
  2208. self._pos = _choice20
  2209. break
  2210. _result = _all19
  2211. _result = _before_discard18
  2212. break
  2213. except BacktrackException, _exc:
  2214. _error = self._combine_errors(_error, _exc.error)
  2215. self._pos = _choice14
  2216. _choice21 = self._pos
  2217. try:
  2218. _call_status = self._primary()
  2219. _result = _call_status.result
  2220. _error = self._combine_errors(_error, _call_status.error)
  2221. break
  2222. except BacktrackException, _exc:
  2223. _error = self._combine_errors(_error, _exc.error)
  2224. self._pos = _choice21
  2225. raise BacktrackException(_error)
  2226. _call_status = self._primary()
  2227. _result = _call_status.result
  2228. _error = self._combine_errors(_error, _call_status.error)
  2229. break
  2230. if _status.status == _status.LEFTRECURSION:
  2231. if _status.result is not None:
  2232. if _status.pos >= self._pos:
  2233. _status.status = _status.NORMAL
  2234. self._pos = _status.pos
  2235. return _status
  2236. _status.pos = self._pos
  2237. _status.status = _status.SOMESOLUTIONS
  2238. _status.result = _result
  2239. _status.error = _error
  2240. self._pos = _startingpos
  2241. return self._enclosed()
  2242. _status.status = _status.NORMAL
  2243. _status.pos = self._pos
  2244. _status.result = _result
  2245. _status.error = _error
  2246. return _status
  2247. except BacktrackException, _exc:
  2248. _status.pos = -1
  2249. _status.result = None
  2250. _error = self._combine_errors(_error, _exc.error)
  2251. _status.error = _error
  2252. _status.status = _status.ERROR
  2253. raise BacktrackException(_error)
  2254. def primary(self):
  2255. return self._primary().result
  2256. def _primary(self):
  2257. _key = self._pos
  2258. _status = self._dict_primary.get(_key, None)
  2259. if _status is None:
  2260. _status = self._dict_primary[_key] = Status()
  2261. else:
  2262. _statusstatus = _status.status
  2263. if _statusstatus == _status.NORMAL:
  2264. self._pos = _status.pos
  2265. return _status
  2266. elif _statusstatus == _status.ERROR:
  2267. raise BacktrackException(_status.error)
  2268. elif (_statusstatus == _status.INPROGRESS or
  2269. _statusstatus == _status.LEFTRECURSION):
  2270. _status.status = _status.LEFTRECURSION
  2271. if _status.result is not None:
  2272. self._pos = _status.pos
  2273. return _status
  2274. else:
  2275. raise BacktrackException(None)
  2276. elif _statusstatus == _status.SOMESOLUTIONS:
  2277. _status.status = _status.INPROGRESS
  2278. _startingpos = self._pos
  2279. try:
  2280. _result = None
  2281. _error = None
  2282. while 1:
  2283. _choice0 = self._pos
  2284. try:
  2285. _call_status = self._call()
  2286. _result = _call_status.result
  2287. _error = _call_status.error
  2288. break
  2289. except BacktrackException, _exc:
  2290. _error = self._combine_errors(_error, _exc.error)
  2291. self._pos = _choice0
  2292. _choice1 = self._pos
  2293. try:
  2294. _call_status = self._REGEX()
  2295. _result = _call_status.result
  2296. _error = self._combine_errors(_error, _call_status.error)
  2297. _before_discard2 = _result
  2298. _all3 = []
  2299. while 1:
  2300. _choice4 = self._pos
  2301. try:
  2302. _call_status = self._IGNORE()
  2303. _result = _call_status.result
  2304. _error = self._combine_errors(_error, _call_status.error)
  2305. _all3.append(_result)
  2306. except BacktrackException, _exc:
  2307. _error = self._combine_errors(_error, _exc.error)
  2308. self._pos = _choice4
  2309. break
  2310. _result = _all3
  2311. _result = _before_discard2
  2312. break
  2313. except BacktrackException, _exc:
  2314. _error = self._combine_errors(_error, _exc.error)
  2315. self._pos = _choice1
  2316. _choice5 = self._pos
  2317. try:
  2318. _call_status = self._QUOTE()
  2319. _result = _call_status.result
  2320. _error = self._combine_errors(_error, _call_status.error)
  2321. _before_discard6 = _result
  2322. _all7 = []
  2323. while 1:
  2324. _choice8 = self._pos
  2325. try:
  2326. _call_status = self._IGNORE()
  2327. _result = _call_status.result
  2328. _error = self._combine_errors(_error, _call_status.error)
  2329. _all7.append(_result)
  2330. except BacktrackException, _exc:
  2331. _error = self._combine_errors(_error, _exc.error)
  2332. self._pos = _choice8
  2333. break
  2334. _result = _all7
  2335. _result = _before_discard6
  2336. break
  2337. except BacktrackException, _exc:
  2338. _error = self._combine_errors(_error, _exc.error)
  2339. self._pos = _choice5
  2340. raise BacktrackException(_error)
  2341. _call_status = self._QUOTE()
  2342. _result = _call_status.result
  2343. _error = self._combine_errors(_error, _call_status.error)
  2344. _before_discard9 = _result
  2345. _all10 = []
  2346. while 1:
  2347. _choice11 = self._pos
  2348. try:
  2349. _call_status = self._IGNORE()
  2350. _result = _call_status.result
  2351. _error = self._combine_errors(_error, _call_status.error)
  2352. _all10.append(_result)
  2353. except BacktrackException, _exc:
  2354. _error = self._combine_errors(_error, _exc.error)
  2355. self._pos = _choice11
  2356. break
  2357. _result = _all10
  2358. _result = _before_discard9
  2359. break
  2360. if _status.status == _status.LEFTRECURSION:
  2361. if _status.result is not None:
  2362. if _status.pos >= self._pos:
  2363. _status.status = _status.NORMAL
  2364. self._pos = _status.pos
  2365. return _status
  2366. _status.pos = self._pos
  2367. _status.status = _status.SOMESOLUTIONS
  2368. _status.result = _result
  2369. _status.error = _error
  2370. self._pos = _startingpos
  2371. return self._primary()
  2372. _status.status = _status.NORMAL
  2373. _status.pos = self._pos
  2374. _status.result = _result
  2375. _status.error = _error
  2376. return _status
  2377. except BacktrackException, _exc:
  2378. _status.pos = -1
  2379. _status.result = None
  2380. _error = self._combine_errors(_error, _exc.error)
  2381. _status.error = _error
  2382. _status.status = _status.ERROR
  2383. raise BacktrackException(_error)
  2384. def call(self):
  2385. return self._call().result
  2386. def _call(self):
  2387. _key = self._pos
  2388. _status = self._dict_call.get(_key, None)
  2389. if _status is None:
  2390. _status = self._dict_call[_key] = Status()
  2391. else:
  2392. _statusstatus = _status.status
  2393. if _statusstatus == _status.NORMAL:
  2394. self._pos = _status.pos
  2395. return _status
  2396. elif _statusstatus == _status.ERROR:
  2397. raise BacktrackException(_status.error)
  2398. elif (_statusstatus == _status.INPROGRESS or
  2399. _statusstatus == _status.LEFTRECURSION):
  2400. _status.status = _status.LEFTRECURSION
  2401. if _status.result is not None:
  2402. self._pos = _status.pos
  2403. return _status
  2404. else:
  2405. raise BacktrackException(None)
  2406. elif _statusstatus == _status.SOMESOLUTIONS:
  2407. _status.status = _status.INPROGRESS
  2408. _startingpos = self._pos
  2409. try:
  2410. _result = None
  2411. _error = None
  2412. _call_status = self._NAME()
  2413. _result = _call_status.result
  2414. _error = _call_status.error
  2415. x = _result
  2416. _call_status = self._arguments()
  2417. _result = _call_status.result
  2418. _error = self._combine_errors(_error, _call_status.error)
  2419. args = _result
  2420. _all0 = []
  2421. while 1:
  2422. _choice1 = self._pos
  2423. try:
  2424. _call_status = self._IGNORE()
  2425. _result = _call_status.result
  2426. _error = self._combine_errors(_error, _call_status.error)
  2427. _all0.append(_result)
  2428. except BacktrackException, _exc:
  2429. _error = self._combine_errors(_error, _exc.error)
  2430. self._pos = _choice1
  2431. break
  2432. _result = _all0
  2433. _result = (Nonterminal("call", [x, args]))
  2434. if _status.status == _status.LEFTRECURSION:
  2435. if _status.result is not None:
  2436. if _status.pos >= self._pos:
  2437. _status.status = _status.NORMAL
  2438. self._pos = _status.pos
  2439. return _status
  2440. _status.pos = self._pos
  2441. _status.status = _status.SOMESOLUTIONS
  2442. _status.result = _result
  2443. _status.error = _error
  2444. self._pos = _startingpos
  2445. return self._call()
  2446. _status.status = _status.NORMAL
  2447. _status.pos = self._pos
  2448. _status.result = _result
  2449. _status.error = _error
  2450. return _status
  2451. except BacktrackException, _exc:
  2452. _status.pos = -1
  2453. _status.result = None
  2454. _error = self._combine_errors(_error, _exc.error)
  2455. _status.error = _error
  2456. _status.status = _status.ERROR
  2457. raise BacktrackException(_error)
  2458. def arguments(self):
  2459. return self._arguments().result
  2460. def _arguments(self):
  2461. _key = self._pos
  2462. _status = self._dict_arguments.get(_key, None)
  2463. if _status is None:
  2464. _status = self._dict_arguments[_key] = Status()
  2465. else:
  2466. _statusstatus = _status.status
  2467. if _statusstatus == _status.NORMAL:
  2468. self._pos = _status.pos
  2469. return _status
  2470. elif _statusstatus == _status.ERROR:
  2471. raise BacktrackException(_status.error)
  2472. elif (_statusstatus == _status.INPROGRESS or
  2473. _statusstatus == _status.LEFTRECURSION):
  2474. _status.status = _status.LEFTRECURSION
  2475. if _status.result is not None:
  2476. self._pos = _status.pos
  2477. return _status
  2478. else:
  2479. raise BacktrackException(None)
  2480. elif _statusstatus == _status.SOMESOLUTIONS:
  2481. _status.status = _status.INPROGRESS
  2482. _startingpos = self._pos
  2483. try:
  2484. _result = None
  2485. _error = None
  2486. while 1:
  2487. _choice0 = self._pos
  2488. try:
  2489. _result = self.__chars__('(')
  2490. _all1 = []
  2491. while 1:
  2492. _choice2 = self._pos
  2493. try:
  2494. _call_status = self._IGNORE()
  2495. _result = _call_status.result
  2496. _error = _call_status.error
  2497. _all1.append(_result)
  2498. except BacktrackException, _exc:
  2499. _error = self._combine_errors(_error, _exc.error)
  2500. self._pos = _choice2
  2501. break
  2502. _result = _all1
  2503. _all3 = []
  2504. while 1:
  2505. _choice4 = self._pos
  2506. try:
  2507. _call_status = self._PYTHONCODE()
  2508. _result = _call_status.result
  2509. _error = self._combine_errors(_error, _call_status.error)
  2510. _before_discard5 = _result
  2511. _all6 = []
  2512. while 1:
  2513. _choice7 = self._pos
  2514. try:
  2515. _call_status = self._IGNORE()
  2516. _result = _call_status.result
  2517. _error = self._combine_errors(_error, _call_status.error)
  2518. _all6.append(_result)
  2519. except BacktrackException, _exc:
  2520. _error = self._combine_errors(_error, _exc.error)
  2521. self._pos = _choice7
  2522. break
  2523. _result = _all6
  2524. _result = self.__chars__(',')
  2525. _all8 = []
  2526. while 1:
  2527. _choice9 = self._pos
  2528. try:
  2529. _call_status = self._IGNORE()
  2530. _result = _call_status.result
  2531. _error = self._combine_errors(_error, _call_status.error)
  2532. _all8.append(_result)
  2533. except BacktrackException, _exc:
  2534. _error = self._combine_errors(_error, _exc.error)
  2535. self._pos = _choice9
  2536. break
  2537. _result = _all8
  2538. _result = _before_discard5
  2539. _all3.append(_result)
  2540. except BacktrackException, _exc:
  2541. _error = self._combine_errors(_error, _exc.error)
  2542. self._pos = _choice4
  2543. break
  2544. _result = _all3
  2545. args = _result
  2546. _call_status = self._PYTHONCODE()
  2547. _result = _call_status.result
  2548. _error = self._combine_errors(_error, _call_status.error)
  2549. last = _result
  2550. _result = self.__chars__(')')
  2551. _all10 = []
  2552. while 1:
  2553. _choice11 = self._pos
  2554. try:
  2555. _call_status = self._IGNORE()
  2556. _result = _call_status.result
  2557. _error = self._combine_errors(_error, _call_status.error)
  2558. _all10.append(_result)
  2559. except BacktrackException, _exc:
  2560. _error = self._combine_errors(_error, _exc.error)
  2561. self._pos = _choice11
  2562. break
  2563. _result = _all10
  2564. _result = (Nonterminal("args", args + [last]))
  2565. break
  2566. except BacktrackException, _exc:
  2567. _error = self._combine_errors(_error, _exc.error)
  2568. self._pos = _choice0
  2569. _choice12 = self._pos
  2570. try:
  2571. _result = (Nonterminal("args", []))
  2572. break
  2573. except BacktrackException, _exc:
  2574. _error = self._combine_errors(_error, _exc.error)
  2575. self._pos = _choice12
  2576. raise BacktrackException(_error)
  2577. _result = (Nonterminal("args", []))
  2578. break
  2579. if _status.status == _status.LEFTRECURSION:
  2580. if _status.result is not None:
  2581. if _status.pos >= self._pos:
  2582. _status.status = _status.NORMAL
  2583. self._pos = _status.pos
  2584. return _status
  2585. _status.pos = self._pos
  2586. _status.status = _status.SOMESOLUTIONS
  2587. _status.result = _result
  2588. _status.error = _error
  2589. self._pos = _startingpos
  2590. return self._arguments()
  2591. _status.status = _status.NORMAL
  2592. _status.pos = self._pos
  2593. _status.result = _result
  2594. _status.error = _error
  2595. return _status
  2596. except BacktrackException, _exc:
  2597. _status.pos = -1
  2598. _status.result = None
  2599. _error = self._combine_errors(_error, _exc.error)
  2600. _status.error = _error
  2601. _status.status = _status.ERROR
  2602. raise BacktrackException(_error)
  2603. def __init__(self, inputstream):
  2604. self._dict_NAME = {}
  2605. self._dict_SPACE = {}
  2606. self._dict_COMMENT = {}
  2607. self._dict_IGNORE = {}
  2608. self._dict_newline = {}
  2609. self._dict_REGEX = {}
  2610. self._dict_QUOTE = {}
  2611. self._dict_PYTHONCODE = {}
  2612. self._dict_EOF = {}
  2613. self._dict_file = {}
  2614. self._dict_list = {}
  2615. self._dict_production = {}
  2616. self._dict_productionargs = {}
  2617. self._dict_or_ = {}
  2618. self._dict_commands = {}
  2619. self._dict_command = {}
  2620. self._dict_simplecommand = {}
  2621. self._dict_return_ = {}
  2622. self._dict_if_ = {}
  2623. self._dict_choose = {}
  2624. self._dict_commandchain = {}
  2625. self._dict_named_command = {}
  2626. self._dict_repetition = {}
  2627. self._dict_negation = {}
  2628. self._dict_enclosed = {}
  2629. self._dict_primary = {}
  2630. self._dict_call = {}
  2631. self._dict_arguments = {}
  2632. self._pos = 0
  2633. self._inputstream = inputstream
  2634. def _regex299149370(self):
  2635. _choice13 = self._pos
  2636. _runner = self._Runner(self._inputstream, self._pos)
  2637. _i = _runner.recognize_299149370(self._pos)
  2638. if _runner.last_matched_state == -1:
  2639. self._pos = _choice13
  2640. raise BacktrackException
  2641. _upto = _runner.last_matched_index + 1
  2642. _pos = self._pos
  2643. assert _pos >= 0
  2644. assert _upto >= 0
  2645. _result = self._inputstream[_pos: _upto]
  2646. self._pos = _upto
  2647. return _result
  2648. def _regex1006631623(self):
  2649. _choice14 = self._pos
  2650. _runner = self._Runner(self._inputstream, self._pos)
  2651. _i = _runner.recognize_1006631623(self._pos)
  2652. if _runner.last_matched_state == -1:
  2653. self._pos = _choice14
  2654. raise BacktrackException
  2655. _upto = _runner.last_matched_index + 1
  2656. _pos = self._pos
  2657. assert _pos >= 0
  2658. assert _upto >= 0
  2659. _result = self._inputstream[_pos: _upto]
  2660. self._pos = _upto
  2661. return _result
  2662. def _regex528667127(self):
  2663. _choice15 = self._pos
  2664. _runner = self._Runner(self._inputstream, self._pos)
  2665. _i = _runner.recognize_528667127(self._pos)
  2666. if _runner.last_matched_state == -1:
  2667. self._pos = _choice15
  2668. raise BacktrackException
  2669. _upto = _runner.last_matched_index + 1
  2670. _pos = self._pos
  2671. assert _pos >= 0
  2672. assert _upto >= 0
  2673. _result = self._inputstream[_pos: _upto]
  2674. self._pos = _upto
  2675. return _result
  2676. def _regex291086639(self):
  2677. _choice16 = self._pos
  2678. _runner = self._Runner(self._inputstream, self._pos)
  2679. _i = _runner.recognize_291086639(self._pos)
  2680. if _runner.last_matched_state == -1:
  2681. self._pos = _choice16
  2682. raise BacktrackException
  2683. _upto = _runner.last_matched_index + 1
  2684. _pos = self._pos
  2685. assert _pos >= 0
  2686. assert _upto >= 0
  2687. _result = self._inputstream[_pos: _upto]
  2688. self._pos = _upto
  2689. return _result
  2690. def _regex1074651696(self):
  2691. _choice17 = self._pos
  2692. _runner = self._Runner(self._inputstream, self._pos)
  2693. _i = _runner.recognize_1074651696(self._pos)
  2694. if _runner.last_matched_state == -1:
  2695. self._pos = _choice17
  2696. raise BacktrackException
  2697. _upto = _runner.last_matched_index + 1
  2698. _pos = self._pos
  2699. assert _pos >= 0
  2700. assert _upto >= 0
  2701. _result = self._inputstream[_pos: _upto]
  2702. self._pos = _upto
  2703. return _result
  2704. def _regex1124192327(self):
  2705. _choice18 = self._pos
  2706. _runner = self._Runner(self._inputstream, self._pos)
  2707. _i = _runner.recognize_1124192327(self._pos)
  2708. if _runner.last_matched_state == -1:
  2709. self._pos = _choice18
  2710. raise BacktrackException
  2711. _upto = _runner.last_matched_index + 1
  2712. _pos = self._pos
  2713. assert _pos >= 0
  2714. assert _upto >= 0
  2715. _result = self._inputstream[_pos: _upto]
  2716. self._pos = _upto
  2717. return _result
  2718. def _regex1979538501(self):
  2719. _choice19 = self._pos
  2720. _runner = self._Runner(self._inputstream, self._pos)
  2721. _i = _runner.recognize_1979538501(self._pos)
  2722. if _runner.last_matched_state == -1:
  2723. self._pos = _choice19
  2724. raise BacktrackException
  2725. _upto = _runner.last_matched_index + 1
  2726. _pos = self._pos
  2727. assert _pos >= 0
  2728. assert _upto >= 0
  2729. _result = self._inputstream[_pos: _upto]
  2730. self._pos = _upto
  2731. return _result
  2732. class _Runner(object):
  2733. def __init__(self, text, pos):
  2734. self.text = text
  2735. self.pos = pos
  2736. self.last_matched_state = -1
  2737. self.last_matched_index = -1
  2738. self.state = -1
  2739. def recognize_299149370(runner, i):
  2740. #auto-generated code, don't edit
  2741. assert i >= 0
  2742. input = runner.text
  2743. state = 0
  2744. while 1:
  2745. if state == 0:
  2746. runner.last_matched_index = i - 1
  2747. runner.last_matched_state = state
  2748. try:
  2749. char = input[i]
  2750. i += 1
  2751. except IndexError:
  2752. runner.state = 0
  2753. return i
  2754. if char == '\n':
  2755. state = 1
  2756. elif char == ' ':
  2757. state = 2
  2758. else:
  2759. break
  2760. if state == 1:
  2761. runner.last_matched_index = i - 1
  2762. runner.last_matched_state = state
  2763. try:
  2764. char = input[i]
  2765. i += 1
  2766. except IndexError:
  2767. runner.state = 1
  2768. return i
  2769. if char == '\n':
  2770. state = 1
  2771. continue
  2772. elif char == ' ':
  2773. state = 1
  2774. continue
  2775. else:
  2776. break
  2777. if state == 2:
  2778. try:
  2779. char = input[i]
  2780. i += 1
  2781. except IndexError:
  2782. runner.state = 2
  2783. return ~i
  2784. if char == '\n':
  2785. state = 1
  2786. continue
  2787. elif char == ' ':
  2788. state = 2
  2789. continue
  2790. else:
  2791. break
  2792. runner.last_matched_state = state
  2793. runner.last_matched_index = i - 1
  2794. runner.state = state
  2795. if i == len(input):
  2796. return i
  2797. else:
  2798. return ~i
  2799. break
  2800. runner.state = state
  2801. return ~i
  2802. def recognize_1006631623(runner, i):
  2803. #auto-generated code, don't edit
  2804. assert i >= 0
  2805. input = runner.text
  2806. state = 0
  2807. while 1:
  2808. if state == 0:
  2809. try:
  2810. char = input[i]
  2811. i += 1
  2812. except IndexError:
  2813. runner.state = 0
  2814. return ~i
  2815. if char == '`':
  2816. state = 3
  2817. else:
  2818. break
  2819. if state == 2:
  2820. try:
  2821. char = input[i]
  2822. i += 1
  2823. except IndexError:
  2824. runner.state = 2
  2825. return ~i
  2826. if '\x00' <= char <= '\xff':
  2827. state = 3
  2828. else:
  2829. break
  2830. if state == 3:
  2831. try:
  2832. char = input[i]
  2833. i += 1
  2834. except IndexError:
  2835. runner.state = 3
  2836. return ~i
  2837. if char == '`':
  2838. state = 1
  2839. elif char == '\\':
  2840. state = 2
  2841. continue
  2842. elif ']' <= char <= '_':
  2843. state = 3
  2844. continue
  2845. elif '\x00' <= char <= '[':
  2846. state = 3
  2847. continue
  2848. elif 'a' <= char <= '\xff':
  2849. state = 3
  2850. continue
  2851. else:
  2852. break
  2853. runner.last_matched_state = state
  2854. runner.last_matched_index = i - 1
  2855. runner.state = state
  2856. if i == len(input):
  2857. return i
  2858. else:
  2859. return ~i
  2860. break
  2861. runner.state = state
  2862. return ~i
  2863. def recognize_528667127(runner, i):
  2864. #auto-generated code, don't edit
  2865. assert i >= 0
  2866. input = runner.text
  2867. state = 0
  2868. while 1:
  2869. if state == 0:
  2870. try:
  2871. char = input[i]
  2872. i += 1
  2873. except IndexError:
  2874. runner.state = 0
  2875. return ~i
  2876. if char == ' ':
  2877. state = 0
  2878. continue
  2879. elif char == '#':
  2880. state = 2
  2881. else:
  2882. break
  2883. if state == 1:
  2884. runner.last_matched_index = i - 1
  2885. runner.last_matched_state = state
  2886. try:
  2887. char = input[i]
  2888. i += 1
  2889. except IndexError:
  2890. runner.state = 1
  2891. return i
  2892. if char == ' ':
  2893. state = 0
  2894. continue
  2895. elif char == '#':
  2896. state = 2
  2897. else:
  2898. break
  2899. if state == 2:
  2900. try:
  2901. char = input[i]
  2902. i += 1
  2903. except IndexError:
  2904. runner.state = 2
  2905. return ~i
  2906. if char == '\n':
  2907. state = 1
  2908. continue
  2909. elif '\x00' <= char <= '\t':
  2910. state = 2
  2911. continue
  2912. elif '\x0b' <= char <= '\xff':
  2913. state = 2
  2914. continue
  2915. else:
  2916. break
  2917. runner.last_matched_state = state
  2918. runner.last_matched_index = i - 1
  2919. runner.state = state
  2920. if i == len(input):
  2921. return i
  2922. else:
  2923. return ~i
  2924. break
  2925. runner.state = state
  2926. return ~i
  2927. def recognize_291086639(runner, i):
  2928. #auto-generated code, don't edit
  2929. assert i >= 0
  2930. input = runner.text
  2931. state = 0
  2932. while 1:
  2933. if state == 0:
  2934. try:
  2935. char = input[i]
  2936. i += 1
  2937. except IndexError:
  2938. runner.state = 0
  2939. return ~i
  2940. if char == '{':
  2941. state = 2
  2942. else:
  2943. break
  2944. if state == 2:
  2945. try:
  2946. char = input[i]
  2947. i += 1
  2948. except IndexError:
  2949. runner.state = 2
  2950. return ~i
  2951. if char == '}':
  2952. state = 1
  2953. elif '\x00' <= char <= '\t':
  2954. state = 2
  2955. continue
  2956. elif '\x0b' <= char <= '|':
  2957. state = 2
  2958. continue
  2959. elif '~' <= char <= '\xff':
  2960. state = 2
  2961. continue
  2962. else:
  2963. break
  2964. runner.last_matched_state = state
  2965. runner.last_matched_index = i - 1
  2966. runner.state = state
  2967. if i == len(input):
  2968. return i
  2969. else:
  2970. return ~i
  2971. break
  2972. runner.state = state
  2973. return ~i
  2974. def recognize_1074651696(runner, i):
  2975. #auto-generated code, don't edit
  2976. assert i >= 0
  2977. input = runner.text
  2978. state = 0
  2979. while 1:
  2980. if state == 0:
  2981. try:
  2982. char = input[i]
  2983. i += 1
  2984. except IndexError:
  2985. runner.state = 0
  2986. return ~i
  2987. if char == '_':
  2988. state = 1
  2989. elif 'A' <= char <= 'Z':
  2990. state = 1
  2991. elif 'a' <= char <= 'z':
  2992. state = 1
  2993. else:
  2994. break
  2995. if state == 1:
  2996. runner.last_matched_index = i - 1
  2997. runner.last_matched_state = state
  2998. try:
  2999. char = input[i]
  3000. i += 1
  3001. except IndexError:
  3002. runner.state = 1
  3003. return i
  3004. if char == '_':
  3005. state = 1
  3006. continue
  3007. elif '0' <= char <= '9':
  3008. state = 1
  3009. continue
  3010. elif 'A' <= char <= 'Z':
  3011. state = 1
  3012. continue
  3013. elif 'a' <= char <= 'z':
  3014. state = 1
  3015. continue
  3016. else:
  3017. break
  3018. runner.last_matched_state = state
  3019. runner.last_matched_index = i - 1
  3020. runner.state = state
  3021. if i == len(input):
  3022. return i
  3023. else:
  3024. return ~i
  3025. break
  3026. runner.state = state
  3027. return ~i
  3028. def recognize_1124192327(runner, i):
  3029. #auto-generated code, don't edit
  3030. assert i >= 0
  3031. input = runner.text
  3032. state = 0
  3033. while 1:
  3034. if state == 0:
  3035. try:
  3036. char = input[i]
  3037. i += 1
  3038. except IndexError:
  3039. runner.state = 0
  3040. return ~i
  3041. if char == "'":
  3042. state = 1
  3043. else:
  3044. break
  3045. if state == 1:
  3046. try:
  3047. char = input[i]
  3048. i += 1
  3049. except IndexError:
  3050. runner.state = 1
  3051. return ~i
  3052. if '\x00' <= char <= '&':
  3053. state = 1
  3054. continue
  3055. elif '(' <= char <= '\xff':
  3056. state = 1
  3057. continue
  3058. elif char == "'":
  3059. state = 2
  3060. else:
  3061. break
  3062. runner.last_matched_state = state
  3063. runner.last_matched_index = i - 1
  3064. runner.state = state
  3065. if i == len(input):
  3066. return i
  3067. else:
  3068. return ~i
  3069. break
  3070. runner.state = state
  3071. return ~i
  3072. def recognize_1979538501(runner, i):
  3073. #auto-generated code, don't edit
  3074. assert i >= 0
  3075. input = runner.text
  3076. state = 0
  3077. while 1:
  3078. if state == 0:
  3079. try:
  3080. char = input[i]
  3081. i += 1
  3082. except IndexError:
  3083. runner.state = 0
  3084. return ~i
  3085. if char == '#':
  3086. state = 1
  3087. elif char == ' ':
  3088. state = 2
  3089. elif char == '\t':
  3090. state = 2
  3091. elif char == '\n':
  3092. state = 2
  3093. else:
  3094. break
  3095. if state == 1:
  3096. try:
  3097. char = input[i]
  3098. i += 1
  3099. except IndexError:
  3100. runner.state = 1
  3101. return ~i
  3102. if '\x00' <= char <= '\t':
  3103. state = 1
  3104. continue
  3105. elif '\x0b' <= char <= '\xff':
  3106. state = 1
  3107. continue
  3108. elif char == '\n':
  3109. state = 2
  3110. else:
  3111. break
  3112. runner.last_matched_state = state
  3113. runner.last_matched_index = i - 1
  3114. runner.state = state
  3115. if i == len(input):
  3116. return i
  3117. else:
  3118. return ~i
  3119. break
  3120. runner.state = state
  3121. return ~i
  3122. class PyPackratSyntaxParser(PackratParser):
  3123. def __init__(self, stream):
  3124. self.init_parser(stream)
  3125. forbidden = dict.fromkeys(("__weakref__ __doc__ "
  3126. "__dict__ __module__").split())
  3127. initthere = "__init__" in PyPackratSyntaxParser.__dict__
  3128. for key, value in Parser.__dict__.iteritems():
  3129. if key not in PyPackratSyntaxParser.__dict__ and key not in forbidden:
  3130. setattr(PyPackratSyntaxParser, key, value)
  3131. PyPackratSyntaxParser.init_parser = Parser.__init__.im_func