Best Python code snippet using robotframework-anywherelibrary
pypackrat.py
Source:pypackrat.py
1from rpython.rlib.parsing.tree import Nonterminal, Symbol2from rpython.rlib.parsing.makepackrat import PackratParser, BacktrackException, Status3class Parser(object):4 def NAME(self):5 return self._NAME().result6 def _NAME(self):7 _key = self._pos8 _status = self._dict_NAME.get(_key, None)9 if _status is None:10 _status = self._dict_NAME[_key] = Status()11 else:12 _statusstatus = _status.status13 if _statusstatus == _status.NORMAL:14 self._pos = _status.pos15 return _status16 elif _statusstatus == _status.ERROR:17 raise BacktrackException(_status.error)18 _startingpos = self._pos19 try:20 _result = None21 _error = None22 _result = self._regex1074651696()23 assert _status.status != _status.LEFTRECURSION24 _status.status = _status.NORMAL25 _status.pos = self._pos26 _status.result = _result27 _status.error = _error28 return _status29 except BacktrackException, _exc:30 _status.pos = -131 _status.result = None32 _error = _exc.error33 _status.error = _error34 _status.status = _status.ERROR35 raise BacktrackException(_error)36 def SPACE(self):37 return self._SPACE().result38 def _SPACE(self):39 _key = self._pos40 _status = self._dict_SPACE.get(_key, None)41 if _status is None:42 _status = self._dict_SPACE[_key] = Status()43 else:44 _statusstatus = _status.status45 if _statusstatus == _status.NORMAL:46 self._pos = _status.pos47 return _status48 elif _statusstatus == _status.ERROR:49 raise BacktrackException(_status.error)50 _startingpos = self._pos51 try:52 _result = None53 _error = None54 _result = self.__chars__(' ')55 assert _status.status != _status.LEFTRECURSION56 _status.status = _status.NORMAL57 _status.pos = self._pos58 _status.result = _result59 _status.error = _error60 return _status61 except BacktrackException, _exc:62 _status.pos = -163 _status.result = None64 _error = _exc.error65 _status.error = _error66 _status.status = _status.ERROR67 raise BacktrackException(_error)68 def COMMENT(self):69 return self._COMMENT().result70 def _COMMENT(self):71 _key = self._pos72 _status = self._dict_COMMENT.get(_key, None)73 if _status is None:74 _status = self._dict_COMMENT[_key] = Status()75 else:76 _statusstatus = _status.status77 if _statusstatus == _status.NORMAL:78 self._pos = _status.pos79 return _status80 elif _statusstatus == _status.ERROR:81 raise BacktrackException(_status.error)82 _startingpos = self._pos83 try:84 _result = None85 _error = None86 _result = self._regex528667127()87 assert _status.status != _status.LEFTRECURSION88 _status.status = _status.NORMAL89 _status.pos = self._pos90 _status.result = _result91 _status.error = _error92 return _status93 except BacktrackException, _exc:94 _status.pos = -195 _status.result = None96 _error = _exc.error97 _status.error = _error98 _status.status = _status.ERROR99 raise BacktrackException(_error)100 def IGNORE(self):101 return self._IGNORE().result102 def _IGNORE(self):103 _key = self._pos104 _status = self._dict_IGNORE.get(_key, None)105 if _status is None:106 _status = self._dict_IGNORE[_key] = Status()107 else:108 _statusstatus = _status.status109 if _statusstatus == _status.NORMAL:110 self._pos = _status.pos111 return _status112 elif _statusstatus == _status.ERROR:113 raise BacktrackException(_status.error)114 _startingpos = self._pos115 try:116 _result = None117 _error = None118 _result = self._regex1979538501()119 assert _status.status != _status.LEFTRECURSION120 _status.status = _status.NORMAL121 _status.pos = self._pos122 _status.result = _result123 _status.error = _error124 return _status125 except BacktrackException, _exc:126 _status.pos = -1127 _status.result = None128 _error = _exc.error129 _status.error = _error130 _status.status = _status.ERROR131 raise BacktrackException(_error)132 def newline(self):133 return self._newline().result134 def _newline(self):135 _key = self._pos136 _status = self._dict_newline.get(_key, None)137 if _status is None:138 _status = self._dict_newline[_key] = Status()139 else:140 _statusstatus = _status.status141 if _statusstatus == _status.NORMAL:142 self._pos = _status.pos143 return _status144 elif _statusstatus == _status.ERROR:145 raise BacktrackException(_status.error)146 elif (_statusstatus == _status.INPROGRESS or147 _statusstatus == _status.LEFTRECURSION):148 _status.status = _status.LEFTRECURSION149 if _status.result is not None:150 self._pos = _status.pos151 return _status152 else:153 raise BacktrackException(None)154 elif _statusstatus == _status.SOMESOLUTIONS:155 _status.status = _status.INPROGRESS156 _startingpos = self._pos157 try:158 _result = None159 _error = None160 while 1:161 _choice0 = self._pos162 try:163 _call_status = self._COMMENT()164 _result = _call_status.result165 _error = _call_status.error166 break167 except BacktrackException, _exc:168 _error = self._combine_errors(_error, _exc.error)169 self._pos = _choice0170 _choice1 = self._pos171 try:172 _result = self._regex299149370()173 break174 except BacktrackException, _exc:175 _error = self._combine_errors(_error, _exc.error)176 self._pos = _choice1177 raise BacktrackException(_error)178 _result = self._regex299149370()179 break180 if _status.status == _status.LEFTRECURSION:181 if _status.result is not None:182 if _status.pos >= self._pos:183 _status.status = _status.NORMAL184 self._pos = _status.pos185 return _status186 _status.pos = self._pos187 _status.status = _status.SOMESOLUTIONS188 _status.result = _result189 _status.error = _error190 self._pos = _startingpos191 return self._newline()192 _status.status = _status.NORMAL193 _status.pos = self._pos194 _status.result = _result195 _status.error = _error196 return _status197 except BacktrackException, _exc:198 _status.pos = -1199 _status.result = None200 _error = self._combine_errors(_error, _exc.error)201 _status.error = _error202 _status.status = _status.ERROR203 raise BacktrackException(_error)204 def REGEX(self):205 return self._REGEX().result206 def _REGEX(self):207 _key = self._pos208 _status = self._dict_REGEX.get(_key, None)209 if _status is None:210 _status = self._dict_REGEX[_key] = Status()211 else:212 _statusstatus = _status.status213 if _statusstatus == _status.NORMAL:214 self._pos = _status.pos215 return _status216 elif _statusstatus == _status.ERROR:217 raise BacktrackException(_status.error)218 _startingpos = self._pos219 try:220 _result = None221 _error = None222 _result = self._regex1006631623()223 r = _result224 _result = (Symbol('REGEX', r, None))225 assert _status.status != _status.LEFTRECURSION226 _status.status = _status.NORMAL227 _status.pos = self._pos228 _status.result = _result229 _status.error = _error230 return _status231 except BacktrackException, _exc:232 _status.pos = -1233 _status.result = None234 _error = _exc.error235 _status.error = _error236 _status.status = _status.ERROR237 raise BacktrackException(_error)238 def QUOTE(self):239 return self._QUOTE().result240 def _QUOTE(self):241 _key = self._pos242 _status = self._dict_QUOTE.get(_key, None)243 if _status is None:244 _status = self._dict_QUOTE[_key] = Status()245 else:246 _statusstatus = _status.status247 if _statusstatus == _status.NORMAL:248 self._pos = _status.pos249 return _status250 elif _statusstatus == _status.ERROR:251 raise BacktrackException(_status.error)252 _startingpos = self._pos253 try:254 _result = None255 _error = None256 _result = self._regex1124192327()257 r = _result258 _result = (Symbol('QUOTE', r, None))259 assert _status.status != _status.LEFTRECURSION260 _status.status = _status.NORMAL261 _status.pos = self._pos262 _status.result = _result263 _status.error = _error264 return _status265 except BacktrackException, _exc:266 _status.pos = -1267 _status.result = None268 _error = _exc.error269 _status.error = _error270 _status.status = _status.ERROR271 raise BacktrackException(_error)272 def PYTHONCODE(self):273 return self._PYTHONCODE().result274 def _PYTHONCODE(self):275 _key = self._pos276 _status = self._dict_PYTHONCODE.get(_key, None)277 if _status is None:278 _status = self._dict_PYTHONCODE[_key] = Status()279 else:280 _statusstatus = _status.status281 if _statusstatus == _status.NORMAL:282 self._pos = _status.pos283 return _status284 elif _statusstatus == _status.ERROR:285 raise BacktrackException(_status.error)286 _startingpos = self._pos287 try:288 _result = None289 _error = None290 _result = self._regex291086639()291 r = _result292 _result = (Symbol('PYTHONCODE', r, None))293 assert _status.status != _status.LEFTRECURSION294 _status.status = _status.NORMAL295 _status.pos = self._pos296 _status.result = _result297 _status.error = _error298 return _status299 except BacktrackException, _exc:300 _status.pos = -1301 _status.result = None302 _error = _exc.error303 _status.error = _error304 _status.status = _status.ERROR305 raise BacktrackException(_error)306 def EOF(self):307 return self._EOF().result308 def _EOF(self):309 _key = self._pos310 _status = self._dict_EOF.get(_key, None)311 if _status is None:312 _status = self._dict_EOF[_key] = Status()313 else:314 _statusstatus = _status.status315 if _statusstatus == _status.NORMAL:316 self._pos = _status.pos317 return _status318 elif _statusstatus == _status.ERROR:319 raise BacktrackException(_status.error)320 elif (_statusstatus == _status.INPROGRESS or321 _statusstatus == _status.LEFTRECURSION):322 _status.status = _status.LEFTRECURSION323 if _status.result is not None:324 self._pos = _status.pos325 return _status326 else:327 raise BacktrackException(None)328 elif _statusstatus == _status.SOMESOLUTIONS:329 _status.status = _status.INPROGRESS330 _startingpos = self._pos331 try:332 _result = None333 _error = None334 _choice0 = self._pos335 _stored_result1 = _result336 try:337 _result = self.__any__()338 except BacktrackException:339 self._pos = _choice0340 _result = _stored_result1341 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.NORMAL347 self._pos = _status.pos348 return _status349 _status.pos = self._pos350 _status.status = _status.SOMESOLUTIONS351 _status.result = _result352 _status.error = _error353 self._pos = _startingpos354 return self._EOF()355 _status.status = _status.NORMAL356 _status.pos = self._pos357 _status.result = _result358 _status.error = _error359 return _status360 except BacktrackException, _exc:361 _status.pos = -1362 _status.result = None363 _error = _exc.error364 _status.error = _error365 _status.status = _status.ERROR366 raise BacktrackException(_error)367 def file(self):368 return self._file().result369 def _file(self):370 _key = self._pos371 _status = self._dict_file.get(_key, None)372 if _status is None:373 _status = self._dict_file[_key] = Status()374 else:375 _statusstatus = _status.status376 if _statusstatus == _status.NORMAL:377 self._pos = _status.pos378 return _status379 elif _statusstatus == _status.ERROR:380 raise BacktrackException(_status.error)381 elif (_statusstatus == _status.INPROGRESS or382 _statusstatus == _status.LEFTRECURSION):383 _status.status = _status.LEFTRECURSION384 if _status.result is not None:385 self._pos = _status.pos386 return _status387 else:388 raise BacktrackException(None)389 elif _statusstatus == _status.SOMESOLUTIONS:390 _status.status = _status.INPROGRESS391 _startingpos = self._pos392 try:393 _result = None394 _error = None395 _all0 = []396 while 1:397 _choice1 = self._pos398 try:399 _call_status = self._IGNORE()400 _result = _call_status.result401 _error = _call_status.error402 _all0.append(_result)403 except BacktrackException, _exc:404 _error = self._combine_errors(_error, _exc.error)405 self._pos = _choice1406 break407 _result = _all0408 _call_status = self._list()409 _result = _call_status.result410 _error = self._combine_errors(_error, _call_status.error)411 _before_discard2 = _result412 _call_status = self._EOF()413 _result = _call_status.result414 _error = self._combine_errors(_error, _call_status.error)415 _result = _before_discard2416 if _status.status == _status.LEFTRECURSION:417 if _status.result is not None:418 if _status.pos >= self._pos:419 _status.status = _status.NORMAL420 self._pos = _status.pos421 return _status422 _status.pos = self._pos423 _status.status = _status.SOMESOLUTIONS424 _status.result = _result425 _status.error = _error426 self._pos = _startingpos427 return self._file()428 _status.status = _status.NORMAL429 _status.pos = self._pos430 _status.result = _result431 _status.error = _error432 return _status433 except BacktrackException, _exc:434 _status.pos = -1435 _status.result = None436 _error = self._combine_errors(_error, _exc.error)437 _status.error = _error438 _status.status = _status.ERROR439 raise BacktrackException(_error)440 def list(self):441 return self._list().result442 def _list(self):443 _key = self._pos444 _status = self._dict_list.get(_key, None)445 if _status is None:446 _status = self._dict_list[_key] = Status()447 else:448 _statusstatus = _status.status449 if _statusstatus == _status.NORMAL:450 self._pos = _status.pos451 return _status452 elif _statusstatus == _status.ERROR:453 raise BacktrackException(_status.error)454 elif (_statusstatus == _status.INPROGRESS or455 _statusstatus == _status.LEFTRECURSION):456 _status.status = _status.LEFTRECURSION457 if _status.result is not None:458 self._pos = _status.pos459 return _status460 else:461 raise BacktrackException(None)462 elif _statusstatus == _status.SOMESOLUTIONS:463 _status.status = _status.INPROGRESS464 _startingpos = self._pos465 try:466 _result = None467 _error = None468 _all0 = []469 _call_status = self._production()470 _result = _call_status.result471 _error = _call_status.error472 _all0.append(_result)473 while 1:474 _choice1 = self._pos475 try:476 _call_status = self._production()477 _result = _call_status.result478 _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 = _choice1483 break484 _result = _all0485 content = _result486 _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.NORMAL491 self._pos = _status.pos492 return _status493 _status.pos = self._pos494 _status.status = _status.SOMESOLUTIONS495 _status.result = _result496 _status.error = _error497 self._pos = _startingpos498 return self._list()499 _status.status = _status.NORMAL500 _status.pos = self._pos501 _status.result = _result502 _status.error = _error503 return _status504 except BacktrackException, _exc:505 _status.pos = -1506 _status.result = None507 _error = self._combine_errors(_error, _exc.error)508 _status.error = _error509 _status.status = _status.ERROR510 raise BacktrackException(_error)511 def production(self):512 return self._production().result513 def _production(self):514 _key = self._pos515 _status = self._dict_production.get(_key, None)516 if _status is None:517 _status = self._dict_production[_key] = Status()518 else:519 _statusstatus = _status.status520 if _statusstatus == _status.NORMAL:521 self._pos = _status.pos522 return _status523 elif _statusstatus == _status.ERROR:524 raise BacktrackException(_status.error)525 elif (_statusstatus == _status.INPROGRESS or526 _statusstatus == _status.LEFTRECURSION):527 _status.status = _status.LEFTRECURSION528 if _status.result is not None:529 self._pos = _status.pos530 return _status531 else:532 raise BacktrackException(None)533 elif _statusstatus == _status.SOMESOLUTIONS:534 _status.status = _status.INPROGRESS535 _startingpos = self._pos536 try:537 _result = None538 _error = None539 _call_status = self._NAME()540 _result = _call_status.result541 _error = _call_status.error542 name = _result543 _all0 = []544 while 1:545 _choice1 = self._pos546 try:547 _call_status = self._SPACE()548 _result = _call_status.result549 _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 = _choice1554 break555 _result = _all0556 _call_status = self._productionargs()557 _result = _call_status.result558 _error = self._combine_errors(_error, _call_status.error)559 args = _result560 _result = self.__chars__(':')561 _all2 = []562 while 1:563 _choice3 = self._pos564 try:565 _call_status = self._IGNORE()566 _result = _call_status.result567 _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 = _choice3572 break573 _result = _all2574 _call_status = self._or_()575 _result = _call_status.result576 _error = self._combine_errors(_error, _call_status.error)577 what = _result578 _all4 = []579 while 1:580 _choice5 = self._pos581 try:582 _call_status = self._IGNORE()583 _result = _call_status.result584 _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 = _choice5589 break590 _result = _all4591 _result = self.__chars__(';')592 _all6 = []593 while 1:594 _choice7 = self._pos595 try:596 _call_status = self._IGNORE()597 _result = _call_status.result598 _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 = _choice7603 break604 _result = _all6605 _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.NORMAL610 self._pos = _status.pos611 return _status612 _status.pos = self._pos613 _status.status = _status.SOMESOLUTIONS614 _status.result = _result615 _status.error = _error616 self._pos = _startingpos617 return self._production()618 _status.status = _status.NORMAL619 _status.pos = self._pos620 _status.result = _result621 _status.error = _error622 return _status623 except BacktrackException, _exc:624 _status.pos = -1625 _status.result = None626 _error = self._combine_errors(_error, _exc.error)627 _status.error = _error628 _status.status = _status.ERROR629 raise BacktrackException(_error)630 def productionargs(self):631 return self._productionargs().result632 def _productionargs(self):633 _key = self._pos634 _status = self._dict_productionargs.get(_key, None)635 if _status is None:636 _status = self._dict_productionargs[_key] = Status()637 else:638 _statusstatus = _status.status639 if _statusstatus == _status.NORMAL:640 self._pos = _status.pos641 return _status642 elif _statusstatus == _status.ERROR:643 raise BacktrackException(_status.error)644 elif (_statusstatus == _status.INPROGRESS or645 _statusstatus == _status.LEFTRECURSION):646 _status.status = _status.LEFTRECURSION647 if _status.result is not None:648 self._pos = _status.pos649 return _status650 else:651 raise BacktrackException(None)652 elif _statusstatus == _status.SOMESOLUTIONS:653 _status.status = _status.INPROGRESS654 _startingpos = self._pos655 try:656 _result = None657 _error = None658 while 1:659 _choice0 = self._pos660 try:661 _result = self.__chars__('(')662 _all1 = []663 while 1:664 _choice2 = self._pos665 try:666 _call_status = self._IGNORE()667 _result = _call_status.result668 _error = _call_status.error669 _all1.append(_result)670 except BacktrackException, _exc:671 _error = self._combine_errors(_error, _exc.error)672 self._pos = _choice2673 break674 _result = _all1675 _all3 = []676 while 1:677 _choice4 = self._pos678 try:679 _call_status = self._NAME()680 _result = _call_status.result681 _error = self._combine_errors(_error, _call_status.error)682 _before_discard5 = _result683 _all6 = []684 while 1:685 _choice7 = self._pos686 try:687 _call_status = self._IGNORE()688 _result = _call_status.result689 _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 = _choice7694 break695 _result = _all6696 _result = self.__chars__(',')697 _all8 = []698 while 1:699 _choice9 = self._pos700 try:701 _call_status = self._IGNORE()702 _result = _call_status.result703 _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 = _choice9708 break709 _result = _all8710 _result = _before_discard5711 _all3.append(_result)712 except BacktrackException, _exc:713 _error = self._combine_errors(_error, _exc.error)714 self._pos = _choice4715 break716 _result = _all3717 args = _result718 _call_status = self._NAME()719 _result = _call_status.result720 _error = self._combine_errors(_error, _call_status.error)721 arg = _result722 _all10 = []723 while 1:724 _choice11 = self._pos725 try:726 _call_status = self._IGNORE()727 _result = _call_status.result728 _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 = _choice11733 break734 _result = _all10735 _result = self.__chars__(')')736 _all12 = []737 while 1:738 _choice13 = self._pos739 try:740 _call_status = self._IGNORE()741 _result = _call_status.result742 _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 = _choice13747 break748 _result = _all12749 _result = (Nonterminal('productionargs', args + [arg]))750 break751 except BacktrackException, _exc:752 _error = self._combine_errors(_error, _exc.error)753 self._pos = _choice0754 _choice14 = self._pos755 try:756 _result = (Nonterminal('productionargs', []))757 break758 except BacktrackException, _exc:759 _error = self._combine_errors(_error, _exc.error)760 self._pos = _choice14761 raise BacktrackException(_error)762 _result = (Nonterminal('productionargs', []))763 break764 if _status.status == _status.LEFTRECURSION:765 if _status.result is not None:766 if _status.pos >= self._pos:767 _status.status = _status.NORMAL768 self._pos = _status.pos769 return _status770 _status.pos = self._pos771 _status.status = _status.SOMESOLUTIONS772 _status.result = _result773 _status.error = _error774 self._pos = _startingpos775 return self._productionargs()776 _status.status = _status.NORMAL777 _status.pos = self._pos778 _status.result = _result779 _status.error = _error780 return _status781 except BacktrackException, _exc:782 _status.pos = -1783 _status.result = None784 _error = self._combine_errors(_error, _exc.error)785 _status.error = _error786 _status.status = _status.ERROR787 raise BacktrackException(_error)788 def or_(self):789 return self._or_().result790 def _or_(self):791 _key = self._pos792 _status = self._dict_or_.get(_key, None)793 if _status is None:794 _status = self._dict_or_[_key] = Status()795 else:796 _statusstatus = _status.status797 if _statusstatus == _status.NORMAL:798 self._pos = _status.pos799 return _status800 elif _statusstatus == _status.ERROR:801 raise BacktrackException(_status.error)802 elif (_statusstatus == _status.INPROGRESS or803 _statusstatus == _status.LEFTRECURSION):804 _status.status = _status.LEFTRECURSION805 if _status.result is not None:806 self._pos = _status.pos807 return _status808 else:809 raise BacktrackException(None)810 elif _statusstatus == _status.SOMESOLUTIONS:811 _status.status = _status.INPROGRESS812 _startingpos = self._pos813 try:814 _result = None815 _error = None816 while 1:817 _choice0 = self._pos818 try:819 _all1 = []820 _call_status = self._commands()821 _result = _call_status.result822 _error = _call_status.error823 _before_discard2 = _result824 _result = self.__chars__('|')825 _all3 = []826 while 1:827 _choice4 = self._pos828 try:829 _call_status = self._IGNORE()830 _result = _call_status.result831 _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 = _choice4836 break837 _result = _all3838 _result = _before_discard2839 _all1.append(_result)840 while 1:841 _choice5 = self._pos842 try:843 _call_status = self._commands()844 _result = _call_status.result845 _error = self._combine_errors(_error, _call_status.error)846 _before_discard6 = _result847 _result = self.__chars__('|')848 _all7 = []849 while 1:850 _choice8 = self._pos851 try:852 _call_status = self._IGNORE()853 _result = _call_status.result854 _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 = _choice8859 break860 _result = _all7861 _result = _before_discard6862 _all1.append(_result)863 except BacktrackException, _exc:864 _error = self._combine_errors(_error, _exc.error)865 self._pos = _choice5866 break867 _result = _all1868 l = _result869 _call_status = self._commands()870 _result = _call_status.result871 _error = self._combine_errors(_error, _call_status.error)872 last = _result873 _result = (Nonterminal('or', l + [last]))874 break875 except BacktrackException, _exc:876 _error = self._combine_errors(_error, _exc.error)877 self._pos = _choice0878 _choice9 = self._pos879 try:880 _call_status = self._commands()881 _result = _call_status.result882 _error = self._combine_errors(_error, _call_status.error)883 break884 except BacktrackException, _exc:885 _error = self._combine_errors(_error, _exc.error)886 self._pos = _choice9887 raise BacktrackException(_error)888 _call_status = self._commands()889 _result = _call_status.result890 _error = self._combine_errors(_error, _call_status.error)891 break892 if _status.status == _status.LEFTRECURSION:893 if _status.result is not None:894 if _status.pos >= self._pos:895 _status.status = _status.NORMAL896 self._pos = _status.pos897 return _status898 _status.pos = self._pos899 _status.status = _status.SOMESOLUTIONS900 _status.result = _result901 _status.error = _error902 self._pos = _startingpos903 return self._or_()904 _status.status = _status.NORMAL905 _status.pos = self._pos906 _status.result = _result907 _status.error = _error908 return _status909 except BacktrackException, _exc:910 _status.pos = -1911 _status.result = None912 _error = self._combine_errors(_error, _exc.error)913 _status.error = _error914 _status.status = _status.ERROR915 raise BacktrackException(_error)916 def commands(self):917 return self._commands().result918 def _commands(self):919 _key = self._pos920 _status = self._dict_commands.get(_key, None)921 if _status is None:922 _status = self._dict_commands[_key] = Status()923 else:924 _statusstatus = _status.status925 if _statusstatus == _status.NORMAL:926 self._pos = _status.pos927 return _status928 elif _statusstatus == _status.ERROR:929 raise BacktrackException(_status.error)930 elif (_statusstatus == _status.INPROGRESS or931 _statusstatus == _status.LEFTRECURSION):932 _status.status = _status.LEFTRECURSION933 if _status.result is not None:934 self._pos = _status.pos935 return _status936 else:937 raise BacktrackException(None)938 elif _statusstatus == _status.SOMESOLUTIONS:939 _status.status = _status.INPROGRESS940 _startingpos = self._pos941 try:942 _result = None943 _error = None944 while 1:945 _choice0 = self._pos946 try:947 _call_status = self._command()948 _result = _call_status.result949 _error = _call_status.error950 cmd = _result951 _call_status = self._newline()952 _result = _call_status.result953 _error = self._combine_errors(_error, _call_status.error)954 _all1 = []955 _call_status = self._command()956 _result = _call_status.result957 _error = self._combine_errors(_error, _call_status.error)958 _before_discard2 = _result959 _call_status = self._newline()960 _result = _call_status.result961 _error = self._combine_errors(_error, _call_status.error)962 _result = _before_discard2963 _all1.append(_result)964 while 1:965 _choice3 = self._pos966 try:967 _call_status = self._command()968 _result = _call_status.result969 _error = self._combine_errors(_error, _call_status.error)970 _before_discard4 = _result971 _call_status = self._newline()972 _result = _call_status.result973 _error = self._combine_errors(_error, _call_status.error)974 _result = _before_discard4975 _all1.append(_result)976 except BacktrackException, _exc:977 _error = self._combine_errors(_error, _exc.error)978 self._pos = _choice3979 break980 _result = _all1981 cmds = _result982 _result = (Nonterminal('commands', [cmd] + cmds))983 break984 except BacktrackException, _exc:985 _error = self._combine_errors(_error, _exc.error)986 self._pos = _choice0987 _choice5 = self._pos988 try:989 _call_status = self._command()990 _result = _call_status.result991 _error = self._combine_errors(_error, _call_status.error)992 break993 except BacktrackException, _exc:994 _error = self._combine_errors(_error, _exc.error)995 self._pos = _choice5996 raise BacktrackException(_error)997 _call_status = self._command()998 _result = _call_status.result999 _error = self._combine_errors(_error, _call_status.error)1000 break1001 if _status.status == _status.LEFTRECURSION:1002 if _status.result is not None:1003 if _status.pos >= self._pos:1004 _status.status = _status.NORMAL1005 self._pos = _status.pos1006 return _status1007 _status.pos = self._pos1008 _status.status = _status.SOMESOLUTIONS1009 _status.result = _result1010 _status.error = _error1011 self._pos = _startingpos1012 return self._commands()1013 _status.status = _status.NORMAL1014 _status.pos = self._pos1015 _status.result = _result1016 _status.error = _error1017 return _status1018 except BacktrackException, _exc:1019 _status.pos = -11020 _status.result = None1021 _error = self._combine_errors(_error, _exc.error)1022 _status.error = _error1023 _status.status = _status.ERROR1024 raise BacktrackException(_error)1025 def command(self):1026 return self._command().result1027 def _command(self):1028 _key = self._pos1029 _status = self._dict_command.get(_key, None)1030 if _status is None:1031 _status = self._dict_command[_key] = Status()1032 else:1033 _statusstatus = _status.status1034 if _statusstatus == _status.NORMAL:1035 self._pos = _status.pos1036 return _status1037 elif _statusstatus == _status.ERROR:1038 raise BacktrackException(_status.error)1039 elif (_statusstatus == _status.INPROGRESS or1040 _statusstatus == _status.LEFTRECURSION):1041 _status.status = _status.LEFTRECURSION1042 if _status.result is not None:1043 self._pos = _status.pos1044 return _status1045 else:1046 raise BacktrackException(None)1047 elif _statusstatus == _status.SOMESOLUTIONS:1048 _status.status = _status.INPROGRESS1049 _startingpos = self._pos1050 try:1051 _result = None1052 _error = None1053 _call_status = self._simplecommand()1054 _result = _call_status.result1055 _error = _call_status.error1056 if _status.status == _status.LEFTRECURSION:1057 if _status.result is not None:1058 if _status.pos >= self._pos:1059 _status.status = _status.NORMAL1060 self._pos = _status.pos1061 return _status1062 _status.pos = self._pos1063 _status.status = _status.SOMESOLUTIONS1064 _status.result = _result1065 _status.error = _error1066 self._pos = _startingpos1067 return self._command()1068 _status.status = _status.NORMAL1069 _status.pos = self._pos1070 _status.result = _result1071 _status.error = _error1072 return _status1073 except BacktrackException, _exc:1074 _status.pos = -11075 _status.result = None1076 _error = self._combine_errors(_error, _exc.error)1077 _status.error = _error1078 _status.status = _status.ERROR1079 raise BacktrackException(_error)1080 def simplecommand(self):1081 return self._simplecommand().result1082 def _simplecommand(self):1083 _key = self._pos1084 _status = self._dict_simplecommand.get(_key, None)1085 if _status is None:1086 _status = self._dict_simplecommand[_key] = Status()1087 else:1088 _statusstatus = _status.status1089 if _statusstatus == _status.NORMAL:1090 self._pos = _status.pos1091 return _status1092 elif _statusstatus == _status.ERROR:1093 raise BacktrackException(_status.error)1094 elif (_statusstatus == _status.INPROGRESS or1095 _statusstatus == _status.LEFTRECURSION):1096 _status.status = _status.LEFTRECURSION1097 if _status.result is not None:1098 self._pos = _status.pos1099 return _status1100 else:1101 raise BacktrackException(None)1102 elif _statusstatus == _status.SOMESOLUTIONS:1103 _status.status = _status.INPROGRESS1104 _startingpos = self._pos1105 try:1106 _result = None1107 _error = None1108 while 1:1109 _choice0 = self._pos1110 try:1111 _call_status = self._return_()1112 _result = _call_status.result1113 _error = _call_status.error1114 break1115 except BacktrackException, _exc:1116 _error = self._combine_errors(_error, _exc.error)1117 self._pos = _choice01118 _choice1 = self._pos1119 try:1120 _call_status = self._if_()1121 _result = _call_status.result1122 _error = self._combine_errors(_error, _call_status.error)1123 break1124 except BacktrackException, _exc:1125 _error = self._combine_errors(_error, _exc.error)1126 self._pos = _choice11127 _choice2 = self._pos1128 try:1129 _call_status = self._named_command()1130 _result = _call_status.result1131 _error = self._combine_errors(_error, _call_status.error)1132 break1133 except BacktrackException, _exc:1134 _error = self._combine_errors(_error, _exc.error)1135 self._pos = _choice21136 _choice3 = self._pos1137 try:1138 _call_status = self._repetition()1139 _result = _call_status.result1140 _error = self._combine_errors(_error, _call_status.error)1141 break1142 except BacktrackException, _exc:1143 _error = self._combine_errors(_error, _exc.error)1144 self._pos = _choice31145 _choice4 = self._pos1146 try:1147 _call_status = self._choose()1148 _result = _call_status.result1149 _error = self._combine_errors(_error, _call_status.error)1150 break1151 except BacktrackException, _exc:1152 _error = self._combine_errors(_error, _exc.error)1153 self._pos = _choice41154 _choice5 = self._pos1155 try:1156 _call_status = self._negation()1157 _result = _call_status.result1158 _error = self._combine_errors(_error, _call_status.error)1159 break1160 except BacktrackException, _exc:1161 _error = self._combine_errors(_error, _exc.error)1162 self._pos = _choice51163 raise BacktrackException(_error)1164 _call_status = self._negation()1165 _result = _call_status.result1166 _error = self._combine_errors(_error, _call_status.error)1167 break1168 if _status.status == _status.LEFTRECURSION:1169 if _status.result is not None:1170 if _status.pos >= self._pos:1171 _status.status = _status.NORMAL1172 self._pos = _status.pos1173 return _status1174 _status.pos = self._pos1175 _status.status = _status.SOMESOLUTIONS1176 _status.result = _result1177 _status.error = _error1178 self._pos = _startingpos1179 return self._simplecommand()1180 _status.status = _status.NORMAL1181 _status.pos = self._pos1182 _status.result = _result1183 _status.error = _error1184 return _status1185 except BacktrackException, _exc:1186 _status.pos = -11187 _status.result = None1188 _error = self._combine_errors(_error, _exc.error)1189 _status.error = _error1190 _status.status = _status.ERROR1191 raise BacktrackException(_error)1192 def return_(self):1193 return self._return_().result1194 def _return_(self):1195 _key = self._pos1196 _status = self._dict_return_.get(_key, None)1197 if _status is None:1198 _status = self._dict_return_[_key] = Status()1199 else:1200 _statusstatus = _status.status1201 if _statusstatus == _status.NORMAL:1202 self._pos = _status.pos1203 return _status1204 elif _statusstatus == _status.ERROR:1205 raise BacktrackException(_status.error)1206 elif (_statusstatus == _status.INPROGRESS or1207 _statusstatus == _status.LEFTRECURSION):1208 _status.status = _status.LEFTRECURSION1209 if _status.result is not None:1210 self._pos = _status.pos1211 return _status1212 else:1213 raise BacktrackException(None)1214 elif _statusstatus == _status.SOMESOLUTIONS:1215 _status.status = _status.INPROGRESS1216 _startingpos = self._pos1217 try:1218 _result = None1219 _error = None1220 _result = self.__chars__('return')1221 _all0 = []1222 while 1:1223 _choice1 = self._pos1224 try:1225 _call_status = self._SPACE()1226 _result = _call_status.result1227 _error = _call_status.error1228 _all0.append(_result)1229 except BacktrackException, _exc:1230 _error = self._combine_errors(_error, _exc.error)1231 self._pos = _choice11232 break1233 _result = _all01234 _call_status = self._PYTHONCODE()1235 _result = _call_status.result1236 _error = self._combine_errors(_error, _call_status.error)1237 code = _result1238 _all2 = []1239 while 1:1240 _choice3 = self._pos1241 try:1242 _call_status = self._IGNORE()1243 _result = _call_status.result1244 _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 = _choice31249 break1250 _result = _all21251 _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.NORMAL1256 self._pos = _status.pos1257 return _status1258 _status.pos = self._pos1259 _status.status = _status.SOMESOLUTIONS1260 _status.result = _result1261 _status.error = _error1262 self._pos = _startingpos1263 return self._return_()1264 _status.status = _status.NORMAL1265 _status.pos = self._pos1266 _status.result = _result1267 _status.error = _error1268 return _status1269 except BacktrackException, _exc:1270 _status.pos = -11271 _status.result = None1272 _error = self._combine_errors(_error, _exc.error)1273 _status.error = _error1274 _status.status = _status.ERROR1275 raise BacktrackException(_error)1276 def if_(self):1277 return self._if_().result1278 def _if_(self):1279 _key = self._pos1280 _status = self._dict_if_.get(_key, None)1281 if _status is None:1282 _status = self._dict_if_[_key] = Status()1283 else:1284 _statusstatus = _status.status1285 if _statusstatus == _status.NORMAL:1286 self._pos = _status.pos1287 return _status1288 elif _statusstatus == _status.ERROR:1289 raise BacktrackException(_status.error)1290 elif (_statusstatus == _status.INPROGRESS or1291 _statusstatus == _status.LEFTRECURSION):1292 _status.status = _status.LEFTRECURSION1293 if _status.result is not None:1294 self._pos = _status.pos1295 return _status1296 else:1297 raise BacktrackException(None)1298 elif _statusstatus == _status.SOMESOLUTIONS:1299 _status.status = _status.INPROGRESS1300 _startingpos = self._pos1301 try:1302 _result = None1303 _error = None1304 while 1:1305 _choice0 = self._pos1306 try:1307 _result = self.__chars__('do')1308 _call_status = self._newline()1309 _result = _call_status.result1310 _error = _call_status.error1311 _call_status = self._command()1312 _result = _call_status.result1313 _error = self._combine_errors(_error, _call_status.error)1314 cmd = _result1315 _all1 = []1316 while 1:1317 _choice2 = self._pos1318 try:1319 _call_status = self._SPACE()1320 _result = _call_status.result1321 _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 = _choice21326 break1327 _result = _all11328 _result = self.__chars__('if')1329 _all3 = []1330 while 1:1331 _choice4 = self._pos1332 try:1333 _call_status = self._SPACE()1334 _result = _call_status.result1335 _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 = _choice41340 break1341 _result = _all31342 _call_status = self._PYTHONCODE()1343 _result = _call_status.result1344 _error = self._combine_errors(_error, _call_status.error)1345 condition = _result1346 _all5 = []1347 while 1:1348 _choice6 = self._pos1349 try:1350 _call_status = self._IGNORE()1351 _result = _call_status.result1352 _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 = _choice61357 break1358 _result = _all51359 _result = (Nonterminal('if', [cmd, condition]))1360 break1361 except BacktrackException, _exc:1362 _error = self._combine_errors(_error, _exc.error)1363 self._pos = _choice01364 _choice7 = self._pos1365 try:1366 _result = self.__chars__('if')1367 _all8 = []1368 while 1:1369 _choice9 = self._pos1370 try:1371 _call_status = self._SPACE()1372 _result = _call_status.result1373 _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 = _choice91378 break1379 _result = _all81380 _call_status = self._PYTHONCODE()1381 _result = _call_status.result1382 _error = self._combine_errors(_error, _call_status.error)1383 condition = _result1384 _all10 = []1385 while 1:1386 _choice11 = self._pos1387 try:1388 _call_status = self._IGNORE()1389 _result = _call_status.result1390 _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 = _choice111395 break1396 _result = _all101397 _result = (Nonterminal('if', [condition]))1398 break1399 except BacktrackException, _exc:1400 _error = self._combine_errors(_error, _exc.error)1401 self._pos = _choice71402 raise BacktrackException(_error)1403 _result = self.__chars__('if')1404 _all12 = []1405 while 1:1406 _choice13 = self._pos1407 try:1408 _call_status = self._SPACE()1409 _result = _call_status.result1410 _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 = _choice131415 break1416 _result = _all121417 _call_status = self._PYTHONCODE()1418 _result = _call_status.result1419 _error = self._combine_errors(_error, _call_status.error)1420 condition = _result1421 _all14 = []1422 while 1:1423 _choice15 = self._pos1424 try:1425 _call_status = self._IGNORE()1426 _result = _call_status.result1427 _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 = _choice151432 break1433 _result = _all141434 _result = (Nonterminal('if', [condition]))1435 break1436 if _status.status == _status.LEFTRECURSION:1437 if _status.result is not None:1438 if _status.pos >= self._pos:1439 _status.status = _status.NORMAL1440 self._pos = _status.pos1441 return _status1442 _status.pos = self._pos1443 _status.status = _status.SOMESOLUTIONS1444 _status.result = _result1445 _status.error = _error1446 self._pos = _startingpos1447 return self._if_()1448 _status.status = _status.NORMAL1449 _status.pos = self._pos1450 _status.result = _result1451 _status.error = _error1452 return _status1453 except BacktrackException, _exc:1454 _status.pos = -11455 _status.result = None1456 _error = self._combine_errors(_error, _exc.error)1457 _status.error = _error1458 _status.status = _status.ERROR1459 raise BacktrackException(_error)1460 def choose(self):1461 return self._choose().result1462 def _choose(self):1463 _key = self._pos1464 _status = self._dict_choose.get(_key, None)1465 if _status is None:1466 _status = self._dict_choose[_key] = Status()1467 else:1468 _statusstatus = _status.status1469 if _statusstatus == _status.NORMAL:1470 self._pos = _status.pos1471 return _status1472 elif _statusstatus == _status.ERROR:1473 raise BacktrackException(_status.error)1474 elif (_statusstatus == _status.INPROGRESS or1475 _statusstatus == _status.LEFTRECURSION):1476 _status.status = _status.LEFTRECURSION1477 if _status.result is not None:1478 self._pos = _status.pos1479 return _status1480 else:1481 raise BacktrackException(None)1482 elif _statusstatus == _status.SOMESOLUTIONS:1483 _status.status = _status.INPROGRESS1484 _startingpos = self._pos1485 try:1486 _result = None1487 _error = None1488 _result = self.__chars__('choose')1489 _all0 = []1490 while 1:1491 _choice1 = self._pos1492 try:1493 _call_status = self._SPACE()1494 _result = _call_status.result1495 _error = _call_status.error1496 _all0.append(_result)1497 except BacktrackException, _exc:1498 _error = self._combine_errors(_error, _exc.error)1499 self._pos = _choice11500 break1501 _result = _all01502 _call_status = self._NAME()1503 _result = _call_status.result1504 _error = self._combine_errors(_error, _call_status.error)1505 name = _result1506 _all2 = []1507 while 1:1508 _choice3 = self._pos1509 try:1510 _call_status = self._SPACE()1511 _result = _call_status.result1512 _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 = _choice31517 break1518 _result = _all21519 _result = self.__chars__('in')1520 _all4 = []1521 while 1:1522 _choice5 = self._pos1523 try:1524 _call_status = self._SPACE()1525 _result = _call_status.result1526 _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 = _choice51531 break1532 _result = _all41533 _call_status = self._PYTHONCODE()1534 _result = _call_status.result1535 _error = self._combine_errors(_error, _call_status.error)1536 expr = _result1537 _all6 = []1538 while 1:1539 _choice7 = self._pos1540 try:1541 _call_status = self._IGNORE()1542 _result = _call_status.result1543 _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 = _choice71548 break1549 _result = _all61550 _call_status = self._commands()1551 _result = _call_status.result1552 _error = self._combine_errors(_error, _call_status.error)1553 cmds = _result1554 _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.NORMAL1559 self._pos = _status.pos1560 return _status1561 _status.pos = self._pos1562 _status.status = _status.SOMESOLUTIONS1563 _status.result = _result1564 _status.error = _error1565 self._pos = _startingpos1566 return self._choose()1567 _status.status = _status.NORMAL1568 _status.pos = self._pos1569 _status.result = _result1570 _status.error = _error1571 return _status1572 except BacktrackException, _exc:1573 _status.pos = -11574 _status.result = None1575 _error = self._combine_errors(_error, _exc.error)1576 _status.error = _error1577 _status.status = _status.ERROR1578 raise BacktrackException(_error)1579 def commandchain(self):1580 return self._commandchain().result1581 def _commandchain(self):1582 _key = self._pos1583 _status = self._dict_commandchain.get(_key, None)1584 if _status is None:1585 _status = self._dict_commandchain[_key] = Status()1586 else:1587 _statusstatus = _status.status1588 if _statusstatus == _status.NORMAL:1589 self._pos = _status.pos1590 return _status1591 elif _statusstatus == _status.ERROR:1592 raise BacktrackException(_status.error)1593 elif (_statusstatus == _status.INPROGRESS or1594 _statusstatus == _status.LEFTRECURSION):1595 _status.status = _status.LEFTRECURSION1596 if _status.result is not None:1597 self._pos = _status.pos1598 return _status1599 else:1600 raise BacktrackException(None)1601 elif _statusstatus == _status.SOMESOLUTIONS:1602 _status.status = _status.INPROGRESS1603 _startingpos = self._pos1604 try:1605 _result = None1606 _error = None1607 _all0 = []1608 _call_status = self._simplecommand()1609 _result = _call_status.result1610 _error = _call_status.error1611 _all0.append(_result)1612 while 1:1613 _choice1 = self._pos1614 try:1615 _call_status = self._simplecommand()1616 _result = _call_status.result1617 _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 = _choice11622 break1623 _result = _all01624 result = _result1625 _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.NORMAL1630 self._pos = _status.pos1631 return _status1632 _status.pos = self._pos1633 _status.status = _status.SOMESOLUTIONS1634 _status.result = _result1635 _status.error = _error1636 self._pos = _startingpos1637 return self._commandchain()1638 _status.status = _status.NORMAL1639 _status.pos = self._pos1640 _status.result = _result1641 _status.error = _error1642 return _status1643 except BacktrackException, _exc:1644 _status.pos = -11645 _status.result = None1646 _error = self._combine_errors(_error, _exc.error)1647 _status.error = _error1648 _status.status = _status.ERROR1649 raise BacktrackException(_error)1650 def named_command(self):1651 return self._named_command().result1652 def _named_command(self):1653 _key = self._pos1654 _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.status1659 if _statusstatus == _status.NORMAL:1660 self._pos = _status.pos1661 return _status1662 elif _statusstatus == _status.ERROR:1663 raise BacktrackException(_status.error)1664 elif (_statusstatus == _status.INPROGRESS or1665 _statusstatus == _status.LEFTRECURSION):1666 _status.status = _status.LEFTRECURSION1667 if _status.result is not None:1668 self._pos = _status.pos1669 return _status1670 else:1671 raise BacktrackException(None)1672 elif _statusstatus == _status.SOMESOLUTIONS:1673 _status.status = _status.INPROGRESS1674 _startingpos = self._pos1675 try:1676 _result = None1677 _error = None1678 _call_status = self._NAME()1679 _result = _call_status.result1680 _error = _call_status.error1681 name = _result1682 _all0 = []1683 while 1:1684 _choice1 = self._pos1685 try:1686 _call_status = self._SPACE()1687 _result = _call_status.result1688 _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 = _choice11693 break1694 _result = _all01695 _result = self.__chars__('=')1696 _all2 = []1697 while 1:1698 _choice3 = self._pos1699 try:1700 _call_status = self._SPACE()1701 _result = _call_status.result1702 _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 = _choice31707 break1708 _result = _all21709 _call_status = self._command()1710 _result = _call_status.result1711 _error = self._combine_errors(_error, _call_status.error)1712 cmd = _result1713 _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.NORMAL1718 self._pos = _status.pos1719 return _status1720 _status.pos = self._pos1721 _status.status = _status.SOMESOLUTIONS1722 _status.result = _result1723 _status.error = _error1724 self._pos = _startingpos1725 return self._named_command()1726 _status.status = _status.NORMAL1727 _status.pos = self._pos1728 _status.result = _result1729 _status.error = _error1730 return _status1731 except BacktrackException, _exc:1732 _status.pos = -11733 _status.result = None1734 _error = self._combine_errors(_error, _exc.error)1735 _status.error = _error1736 _status.status = _status.ERROR1737 raise BacktrackException(_error)1738 def repetition(self):1739 return self._repetition().result1740 def _repetition(self):1741 _key = self._pos1742 _status = self._dict_repetition.get(_key, None)1743 if _status is None:1744 _status = self._dict_repetition[_key] = Status()1745 else:1746 _statusstatus = _status.status1747 if _statusstatus == _status.NORMAL:1748 self._pos = _status.pos1749 return _status1750 elif _statusstatus == _status.ERROR:1751 raise BacktrackException(_status.error)1752 elif (_statusstatus == _status.INPROGRESS or1753 _statusstatus == _status.LEFTRECURSION):1754 _status.status = _status.LEFTRECURSION1755 if _status.result is not None:1756 self._pos = _status.pos1757 return _status1758 else:1759 raise BacktrackException(None)1760 elif _statusstatus == _status.SOMESOLUTIONS:1761 _status.status = _status.INPROGRESS1762 _startingpos = self._pos1763 try:1764 _result = None1765 _error = None1766 while 1:1767 _choice0 = self._pos1768 try:1769 _call_status = self._enclosed()1770 _result = _call_status.result1771 _error = _call_status.error1772 what = _result1773 _all1 = []1774 while 1:1775 _choice2 = self._pos1776 try:1777 _call_status = self._SPACE()1778 _result = _call_status.result1779 _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 = _choice21784 break1785 _result = _all11786 _result = self.__chars__('?')1787 _all3 = []1788 while 1:1789 _choice4 = self._pos1790 try:1791 _call_status = self._IGNORE()1792 _result = _call_status.result1793 _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 = _choice41798 break1799 _result = _all31800 _result = (Nonterminal('maybe', [what]))1801 break1802 except BacktrackException, _exc:1803 _error = self._combine_errors(_error, _exc.error)1804 self._pos = _choice01805 _choice5 = self._pos1806 try:1807 _call_status = self._enclosed()1808 _result = _call_status.result1809 _error = self._combine_errors(_error, _call_status.error)1810 what = _result1811 _all6 = []1812 while 1:1813 _choice7 = self._pos1814 try:1815 _call_status = self._SPACE()1816 _result = _call_status.result1817 _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 = _choice71822 break1823 _result = _all61824 while 1:1825 _choice8 = self._pos1826 try:1827 _result = self.__chars__('*')1828 break1829 except BacktrackException, _exc:1830 _error = self._combine_errors(_error, _exc.error)1831 self._pos = _choice81832 _choice9 = self._pos1833 try:1834 _result = self.__chars__('+')1835 break1836 except BacktrackException, _exc:1837 _error = self._combine_errors(_error, _exc.error)1838 self._pos = _choice91839 raise BacktrackException(_error)1840 _result = self.__chars__('+')1841 break1842 repetition = _result1843 _all10 = []1844 while 1:1845 _choice11 = self._pos1846 try:1847 _call_status = self._IGNORE()1848 _result = _call_status.result1849 _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 = _choice111854 break1855 _result = _all101856 _result = (Nonterminal('repetition', [repetition, what]))1857 break1858 except BacktrackException, _exc:1859 _error = self._combine_errors(_error, _exc.error)1860 self._pos = _choice51861 raise BacktrackException(_error)1862 _call_status = self._enclosed()1863 _result = _call_status.result1864 _error = self._combine_errors(_error, _call_status.error)1865 what = _result1866 _all12 = []1867 while 1:1868 _choice13 = self._pos1869 try:1870 _call_status = self._SPACE()1871 _result = _call_status.result1872 _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 = _choice131877 break1878 _result = _all121879 while 1:1880 _choice14 = self._pos1881 try:1882 _result = self.__chars__('*')1883 break1884 except BacktrackException, _exc:1885 _error = self._combine_errors(_error, _exc.error)1886 self._pos = _choice141887 _choice15 = self._pos1888 try:1889 _result = self.__chars__('+')1890 break1891 except BacktrackException, _exc:1892 _error = self._combine_errors(_error, _exc.error)1893 self._pos = _choice151894 raise BacktrackException(_error)1895 _result = self.__chars__('+')1896 break1897 repetition = _result1898 _all16 = []1899 while 1:1900 _choice17 = self._pos1901 try:1902 _call_status = self._IGNORE()1903 _result = _call_status.result1904 _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 = _choice171909 break1910 _result = _all161911 _result = (Nonterminal('repetition', [repetition, what]))1912 break1913 if _status.status == _status.LEFTRECURSION:1914 if _status.result is not None:1915 if _status.pos >= self._pos:1916 _status.status = _status.NORMAL1917 self._pos = _status.pos1918 return _status1919 _status.pos = self._pos1920 _status.status = _status.SOMESOLUTIONS1921 _status.result = _result1922 _status.error = _error1923 self._pos = _startingpos1924 return self._repetition()1925 _status.status = _status.NORMAL1926 _status.pos = self._pos1927 _status.result = _result1928 _status.error = _error1929 return _status1930 except BacktrackException, _exc:1931 _status.pos = -11932 _status.result = None1933 _error = self._combine_errors(_error, _exc.error)1934 _status.error = _error1935 _status.status = _status.ERROR1936 raise BacktrackException(_error)1937 def negation(self):1938 return self._negation().result1939 def _negation(self):1940 _key = self._pos1941 _status = self._dict_negation.get(_key, None)1942 if _status is None:1943 _status = self._dict_negation[_key] = Status()1944 else:1945 _statusstatus = _status.status1946 if _statusstatus == _status.NORMAL:1947 self._pos = _status.pos1948 return _status1949 elif _statusstatus == _status.ERROR:1950 raise BacktrackException(_status.error)1951 elif (_statusstatus == _status.INPROGRESS or1952 _statusstatus == _status.LEFTRECURSION):1953 _status.status = _status.LEFTRECURSION1954 if _status.result is not None:1955 self._pos = _status.pos1956 return _status1957 else:1958 raise BacktrackException(None)1959 elif _statusstatus == _status.SOMESOLUTIONS:1960 _status.status = _status.INPROGRESS1961 _startingpos = self._pos1962 try:1963 _result = None1964 _error = None1965 while 1:1966 _choice0 = self._pos1967 try:1968 _result = self.__chars__('!')1969 _all1 = []1970 while 1:1971 _choice2 = self._pos1972 try:1973 _call_status = self._SPACE()1974 _result = _call_status.result1975 _error = _call_status.error1976 _all1.append(_result)1977 except BacktrackException, _exc:1978 _error = self._combine_errors(_error, _exc.error)1979 self._pos = _choice21980 break1981 _result = _all11982 _call_status = self._negation()1983 _result = _call_status.result1984 _error = self._combine_errors(_error, _call_status.error)1985 what = _result1986 _all3 = []1987 while 1:1988 _choice4 = self._pos1989 try:1990 _call_status = self._IGNORE()1991 _result = _call_status.result1992 _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 = _choice41997 break1998 _result = _all31999 _result = (Nonterminal('negation', [what]))2000 break2001 except BacktrackException, _exc:2002 _error = self._combine_errors(_error, _exc.error)2003 self._pos = _choice02004 _choice5 = self._pos2005 try:2006 _call_status = self._enclosed()2007 _result = _call_status.result2008 _error = self._combine_errors(_error, _call_status.error)2009 break2010 except BacktrackException, _exc:2011 _error = self._combine_errors(_error, _exc.error)2012 self._pos = _choice52013 raise BacktrackException(_error)2014 _call_status = self._enclosed()2015 _result = _call_status.result2016 _error = self._combine_errors(_error, _call_status.error)2017 break2018 if _status.status == _status.LEFTRECURSION:2019 if _status.result is not None:2020 if _status.pos >= self._pos:2021 _status.status = _status.NORMAL2022 self._pos = _status.pos2023 return _status2024 _status.pos = self._pos2025 _status.status = _status.SOMESOLUTIONS2026 _status.result = _result2027 _status.error = _error2028 self._pos = _startingpos2029 return self._negation()2030 _status.status = _status.NORMAL2031 _status.pos = self._pos2032 _status.result = _result2033 _status.error = _error2034 return _status2035 except BacktrackException, _exc:2036 _status.pos = -12037 _status.result = None2038 _error = self._combine_errors(_error, _exc.error)2039 _status.error = _error2040 _status.status = _status.ERROR2041 raise BacktrackException(_error)2042 def enclosed(self):2043 return self._enclosed().result2044 def _enclosed(self):2045 _key = self._pos2046 _status = self._dict_enclosed.get(_key, None)2047 if _status is None:2048 _status = self._dict_enclosed[_key] = Status()2049 else:2050 _statusstatus = _status.status2051 if _statusstatus == _status.NORMAL:2052 self._pos = _status.pos2053 return _status2054 elif _statusstatus == _status.ERROR:2055 raise BacktrackException(_status.error)2056 elif (_statusstatus == _status.INPROGRESS or2057 _statusstatus == _status.LEFTRECURSION):2058 _status.status = _status.LEFTRECURSION2059 if _status.result is not None:2060 self._pos = _status.pos2061 return _status2062 else:2063 raise BacktrackException(None)2064 elif _statusstatus == _status.SOMESOLUTIONS:2065 _status.status = _status.INPROGRESS2066 _startingpos = self._pos2067 try:2068 _result = None2069 _error = None2070 while 1:2071 _choice0 = self._pos2072 try:2073 _result = self.__chars__('<')2074 _all1 = []2075 while 1:2076 _choice2 = self._pos2077 try:2078 _call_status = self._IGNORE()2079 _result = _call_status.result2080 _error = _call_status.error2081 _all1.append(_result)2082 except BacktrackException, _exc:2083 _error = self._combine_errors(_error, _exc.error)2084 self._pos = _choice22085 break2086 _result = _all12087 _call_status = self._primary()2088 _result = _call_status.result2089 _error = self._combine_errors(_error, _call_status.error)2090 what = _result2091 _all3 = []2092 while 1:2093 _choice4 = self._pos2094 try:2095 _call_status = self._IGNORE()2096 _result = _call_status.result2097 _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 = _choice42102 break2103 _result = _all32104 _result = self.__chars__('>')2105 _all5 = []2106 while 1:2107 _choice6 = self._pos2108 try:2109 _call_status = self._IGNORE()2110 _result = _call_status.result2111 _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 = _choice62116 break2117 _result = _all52118 _result = (Nonterminal('exclusive', [what]))2119 break2120 except BacktrackException, _exc:2121 _error = self._combine_errors(_error, _exc.error)2122 self._pos = _choice02123 _choice7 = self._pos2124 try:2125 _result = self.__chars__('[')2126 _all8 = []2127 while 1:2128 _choice9 = self._pos2129 try:2130 _call_status = self._IGNORE()2131 _result = _call_status.result2132 _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 = _choice92137 break2138 _result = _all82139 _call_status = self._or_()2140 _result = _call_status.result2141 _error = self._combine_errors(_error, _call_status.error)2142 what = _result2143 _all10 = []2144 while 1:2145 _choice11 = self._pos2146 try:2147 _call_status = self._IGNORE()2148 _result = _call_status.result2149 _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 = _choice112154 break2155 _result = _all102156 _result = self.__chars__(']')2157 _all12 = []2158 while 1:2159 _choice13 = self._pos2160 try:2161 _call_status = self._IGNORE()2162 _result = _call_status.result2163 _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 = _choice132168 break2169 _result = _all122170 _result = (Nonterminal('ignore', [what]))2171 break2172 except BacktrackException, _exc:2173 _error = self._combine_errors(_error, _exc.error)2174 self._pos = _choice72175 _choice14 = self._pos2176 try:2177 _before_discard15 = _result2178 _result = self.__chars__('(')2179 _all16 = []2180 while 1:2181 _choice17 = self._pos2182 try:2183 _call_status = self._IGNORE()2184 _result = _call_status.result2185 _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 = _choice172190 break2191 _result = _all162192 _result = _before_discard152193 _call_status = self._or_()2194 _result = _call_status.result2195 _error = self._combine_errors(_error, _call_status.error)2196 _before_discard18 = _result2197 _result = self.__chars__(')')2198 _all19 = []2199 while 1:2200 _choice20 = self._pos2201 try:2202 _call_status = self._IGNORE()2203 _result = _call_status.result2204 _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 = _choice202209 break2210 _result = _all192211 _result = _before_discard182212 break2213 except BacktrackException, _exc:2214 _error = self._combine_errors(_error, _exc.error)2215 self._pos = _choice142216 _choice21 = self._pos2217 try:2218 _call_status = self._primary()2219 _result = _call_status.result2220 _error = self._combine_errors(_error, _call_status.error)2221 break2222 except BacktrackException, _exc:2223 _error = self._combine_errors(_error, _exc.error)2224 self._pos = _choice212225 raise BacktrackException(_error)2226 _call_status = self._primary()2227 _result = _call_status.result2228 _error = self._combine_errors(_error, _call_status.error)2229 break2230 if _status.status == _status.LEFTRECURSION:2231 if _status.result is not None:2232 if _status.pos >= self._pos:2233 _status.status = _status.NORMAL2234 self._pos = _status.pos2235 return _status2236 _status.pos = self._pos2237 _status.status = _status.SOMESOLUTIONS2238 _status.result = _result2239 _status.error = _error2240 self._pos = _startingpos2241 return self._enclosed()2242 _status.status = _status.NORMAL2243 _status.pos = self._pos2244 _status.result = _result2245 _status.error = _error2246 return _status2247 except BacktrackException, _exc:2248 _status.pos = -12249 _status.result = None2250 _error = self._combine_errors(_error, _exc.error)2251 _status.error = _error2252 _status.status = _status.ERROR2253 raise BacktrackException(_error)2254 def primary(self):2255 return self._primary().result2256 def _primary(self):2257 _key = self._pos2258 _status = self._dict_primary.get(_key, None)2259 if _status is None:2260 _status = self._dict_primary[_key] = Status()2261 else:2262 _statusstatus = _status.status2263 if _statusstatus == _status.NORMAL:2264 self._pos = _status.pos2265 return _status2266 elif _statusstatus == _status.ERROR:2267 raise BacktrackException(_status.error)2268 elif (_statusstatus == _status.INPROGRESS or2269 _statusstatus == _status.LEFTRECURSION):2270 _status.status = _status.LEFTRECURSION2271 if _status.result is not None:2272 self._pos = _status.pos2273 return _status2274 else:2275 raise BacktrackException(None)2276 elif _statusstatus == _status.SOMESOLUTIONS:2277 _status.status = _status.INPROGRESS2278 _startingpos = self._pos2279 try:2280 _result = None2281 _error = None2282 while 1:2283 _choice0 = self._pos2284 try:2285 _call_status = self._call()2286 _result = _call_status.result2287 _error = _call_status.error2288 break2289 except BacktrackException, _exc:2290 _error = self._combine_errors(_error, _exc.error)2291 self._pos = _choice02292 _choice1 = self._pos2293 try:2294 _call_status = self._REGEX()2295 _result = _call_status.result2296 _error = self._combine_errors(_error, _call_status.error)2297 _before_discard2 = _result2298 _all3 = []2299 while 1:2300 _choice4 = self._pos2301 try:2302 _call_status = self._IGNORE()2303 _result = _call_status.result2304 _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 = _choice42309 break2310 _result = _all32311 _result = _before_discard22312 break2313 except BacktrackException, _exc:2314 _error = self._combine_errors(_error, _exc.error)2315 self._pos = _choice12316 _choice5 = self._pos2317 try:2318 _call_status = self._QUOTE()2319 _result = _call_status.result2320 _error = self._combine_errors(_error, _call_status.error)2321 _before_discard6 = _result2322 _all7 = []2323 while 1:2324 _choice8 = self._pos2325 try:2326 _call_status = self._IGNORE()2327 _result = _call_status.result2328 _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 = _choice82333 break2334 _result = _all72335 _result = _before_discard62336 break2337 except BacktrackException, _exc:2338 _error = self._combine_errors(_error, _exc.error)2339 self._pos = _choice52340 raise BacktrackException(_error)2341 _call_status = self._QUOTE()2342 _result = _call_status.result2343 _error = self._combine_errors(_error, _call_status.error)2344 _before_discard9 = _result2345 _all10 = []2346 while 1:2347 _choice11 = self._pos2348 try:2349 _call_status = self._IGNORE()2350 _result = _call_status.result2351 _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 = _choice112356 break2357 _result = _all102358 _result = _before_discard92359 break2360 if _status.status == _status.LEFTRECURSION:2361 if _status.result is not None:2362 if _status.pos >= self._pos:2363 _status.status = _status.NORMAL2364 self._pos = _status.pos2365 return _status2366 _status.pos = self._pos2367 _status.status = _status.SOMESOLUTIONS2368 _status.result = _result2369 _status.error = _error2370 self._pos = _startingpos2371 return self._primary()2372 _status.status = _status.NORMAL2373 _status.pos = self._pos2374 _status.result = _result2375 _status.error = _error2376 return _status2377 except BacktrackException, _exc:2378 _status.pos = -12379 _status.result = None2380 _error = self._combine_errors(_error, _exc.error)2381 _status.error = _error2382 _status.status = _status.ERROR2383 raise BacktrackException(_error)2384 def call(self):2385 return self._call().result2386 def _call(self):2387 _key = self._pos2388 _status = self._dict_call.get(_key, None)2389 if _status is None:2390 _status = self._dict_call[_key] = Status()2391 else:2392 _statusstatus = _status.status2393 if _statusstatus == _status.NORMAL:2394 self._pos = _status.pos2395 return _status2396 elif _statusstatus == _status.ERROR:2397 raise BacktrackException(_status.error)2398 elif (_statusstatus == _status.INPROGRESS or2399 _statusstatus == _status.LEFTRECURSION):2400 _status.status = _status.LEFTRECURSION2401 if _status.result is not None:2402 self._pos = _status.pos2403 return _status2404 else:2405 raise BacktrackException(None)2406 elif _statusstatus == _status.SOMESOLUTIONS:2407 _status.status = _status.INPROGRESS2408 _startingpos = self._pos2409 try:2410 _result = None2411 _error = None2412 _call_status = self._NAME()2413 _result = _call_status.result2414 _error = _call_status.error2415 x = _result2416 _call_status = self._arguments()2417 _result = _call_status.result2418 _error = self._combine_errors(_error, _call_status.error)2419 args = _result2420 _all0 = []2421 while 1:2422 _choice1 = self._pos2423 try:2424 _call_status = self._IGNORE()2425 _result = _call_status.result2426 _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 = _choice12431 break2432 _result = _all02433 _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.NORMAL2438 self._pos = _status.pos2439 return _status2440 _status.pos = self._pos2441 _status.status = _status.SOMESOLUTIONS2442 _status.result = _result2443 _status.error = _error2444 self._pos = _startingpos2445 return self._call()2446 _status.status = _status.NORMAL2447 _status.pos = self._pos2448 _status.result = _result2449 _status.error = _error2450 return _status2451 except BacktrackException, _exc:2452 _status.pos = -12453 _status.result = None2454 _error = self._combine_errors(_error, _exc.error)2455 _status.error = _error2456 _status.status = _status.ERROR2457 raise BacktrackException(_error)2458 def arguments(self):2459 return self._arguments().result2460 def _arguments(self):2461 _key = self._pos2462 _status = self._dict_arguments.get(_key, None)2463 if _status is None:2464 _status = self._dict_arguments[_key] = Status()2465 else:2466 _statusstatus = _status.status2467 if _statusstatus == _status.NORMAL:2468 self._pos = _status.pos2469 return _status2470 elif _statusstatus == _status.ERROR:2471 raise BacktrackException(_status.error)2472 elif (_statusstatus == _status.INPROGRESS or2473 _statusstatus == _status.LEFTRECURSION):2474 _status.status = _status.LEFTRECURSION2475 if _status.result is not None:2476 self._pos = _status.pos2477 return _status2478 else:2479 raise BacktrackException(None)2480 elif _statusstatus == _status.SOMESOLUTIONS:2481 _status.status = _status.INPROGRESS2482 _startingpos = self._pos2483 try:2484 _result = None2485 _error = None2486 while 1:2487 _choice0 = self._pos2488 try:2489 _result = self.__chars__('(')2490 _all1 = []2491 while 1:2492 _choice2 = self._pos2493 try:2494 _call_status = self._IGNORE()2495 _result = _call_status.result2496 _error = _call_status.error2497 _all1.append(_result)2498 except BacktrackException, _exc:2499 _error = self._combine_errors(_error, _exc.error)2500 self._pos = _choice22501 break2502 _result = _all12503 _all3 = []2504 while 1:2505 _choice4 = self._pos2506 try:2507 _call_status = self._PYTHONCODE()2508 _result = _call_status.result2509 _error = self._combine_errors(_error, _call_status.error)2510 _before_discard5 = _result2511 _all6 = []2512 while 1:2513 _choice7 = self._pos2514 try:2515 _call_status = self._IGNORE()2516 _result = _call_status.result2517 _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 = _choice72522 break2523 _result = _all62524 _result = self.__chars__(',')2525 _all8 = []2526 while 1:2527 _choice9 = self._pos2528 try:2529 _call_status = self._IGNORE()2530 _result = _call_status.result2531 _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 = _choice92536 break2537 _result = _all82538 _result = _before_discard52539 _all3.append(_result)2540 except BacktrackException, _exc:2541 _error = self._combine_errors(_error, _exc.error)2542 self._pos = _choice42543 break2544 _result = _all32545 args = _result2546 _call_status = self._PYTHONCODE()2547 _result = _call_status.result2548 _error = self._combine_errors(_error, _call_status.error)2549 last = _result2550 _result = self.__chars__(')')2551 _all10 = []2552 while 1:2553 _choice11 = self._pos2554 try:2555 _call_status = self._IGNORE()2556 _result = _call_status.result2557 _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 = _choice112562 break2563 _result = _all102564 _result = (Nonterminal("args", args + [last]))2565 break2566 except BacktrackException, _exc:2567 _error = self._combine_errors(_error, _exc.error)2568 self._pos = _choice02569 _choice12 = self._pos2570 try:2571 _result = (Nonterminal("args", []))2572 break2573 except BacktrackException, _exc:2574 _error = self._combine_errors(_error, _exc.error)2575 self._pos = _choice122576 raise BacktrackException(_error)2577 _result = (Nonterminal("args", []))2578 break2579 if _status.status == _status.LEFTRECURSION:2580 if _status.result is not None:2581 if _status.pos >= self._pos:2582 _status.status = _status.NORMAL2583 self._pos = _status.pos2584 return _status2585 _status.pos = self._pos2586 _status.status = _status.SOMESOLUTIONS2587 _status.result = _result2588 _status.error = _error2589 self._pos = _startingpos2590 return self._arguments()2591 _status.status = _status.NORMAL2592 _status.pos = self._pos2593 _status.result = _result2594 _status.error = _error2595 return _status2596 except BacktrackException, _exc:2597 _status.pos = -12598 _status.result = None2599 _error = self._combine_errors(_error, _exc.error)2600 _status.error = _error2601 _status.status = _status.ERROR2602 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 = 02633 self._inputstream = inputstream2634 def _regex299149370(self):2635 _choice13 = self._pos2636 _runner = self._Runner(self._inputstream, self._pos)2637 _i = _runner.recognize_299149370(self._pos)2638 if _runner.last_matched_state == -1:2639 self._pos = _choice132640 raise BacktrackException2641 _upto = _runner.last_matched_index + 12642 _pos = self._pos2643 assert _pos >= 02644 assert _upto >= 02645 _result = self._inputstream[_pos: _upto]2646 self._pos = _upto2647 return _result2648 def _regex1006631623(self):2649 _choice14 = self._pos2650 _runner = self._Runner(self._inputstream, self._pos)2651 _i = _runner.recognize_1006631623(self._pos)2652 if _runner.last_matched_state == -1:2653 self._pos = _choice142654 raise BacktrackException2655 _upto = _runner.last_matched_index + 12656 _pos = self._pos2657 assert _pos >= 02658 assert _upto >= 02659 _result = self._inputstream[_pos: _upto]2660 self._pos = _upto2661 return _result2662 def _regex528667127(self):2663 _choice15 = self._pos2664 _runner = self._Runner(self._inputstream, self._pos)2665 _i = _runner.recognize_528667127(self._pos)2666 if _runner.last_matched_state == -1:2667 self._pos = _choice152668 raise BacktrackException2669 _upto = _runner.last_matched_index + 12670 _pos = self._pos2671 assert _pos >= 02672 assert _upto >= 02673 _result = self._inputstream[_pos: _upto]2674 self._pos = _upto2675 return _result2676 def _regex291086639(self):2677 _choice16 = self._pos2678 _runner = self._Runner(self._inputstream, self._pos)2679 _i = _runner.recognize_291086639(self._pos)2680 if _runner.last_matched_state == -1:2681 self._pos = _choice162682 raise BacktrackException2683 _upto = _runner.last_matched_index + 12684 _pos = self._pos2685 assert _pos >= 02686 assert _upto >= 02687 _result = self._inputstream[_pos: _upto]2688 self._pos = _upto2689 return _result2690 def _regex1074651696(self):2691 _choice17 = self._pos2692 _runner = self._Runner(self._inputstream, self._pos)2693 _i = _runner.recognize_1074651696(self._pos)2694 if _runner.last_matched_state == -1:2695 self._pos = _choice172696 raise BacktrackException2697 _upto = _runner.last_matched_index + 12698 _pos = self._pos2699 assert _pos >= 02700 assert _upto >= 02701 _result = self._inputstream[_pos: _upto]2702 self._pos = _upto2703 return _result2704 def _regex1124192327(self):2705 _choice18 = self._pos2706 _runner = self._Runner(self._inputstream, self._pos)2707 _i = _runner.recognize_1124192327(self._pos)2708 if _runner.last_matched_state == -1:2709 self._pos = _choice182710 raise BacktrackException2711 _upto = _runner.last_matched_index + 12712 _pos = self._pos2713 assert _pos >= 02714 assert _upto >= 02715 _result = self._inputstream[_pos: _upto]2716 self._pos = _upto2717 return _result2718 def _regex1979538501(self):2719 _choice19 = self._pos2720 _runner = self._Runner(self._inputstream, self._pos)2721 _i = _runner.recognize_1979538501(self._pos)2722 if _runner.last_matched_state == -1:2723 self._pos = _choice192724 raise BacktrackException2725 _upto = _runner.last_matched_index + 12726 _pos = self._pos2727 assert _pos >= 02728 assert _upto >= 02729 _result = self._inputstream[_pos: _upto]2730 self._pos = _upto2731 return _result2732 class _Runner(object):2733 def __init__(self, text, pos):2734 self.text = text2735 self.pos = pos2736 self.last_matched_state = -12737 self.last_matched_index = -12738 self.state = -12739 def recognize_299149370(runner, i):2740 #auto-generated code, don't edit2741 assert i >= 02742 input = runner.text2743 state = 02744 while 1:2745 if state == 0:2746 runner.last_matched_index = i - 12747 runner.last_matched_state = state2748 try:2749 char = input[i]2750 i += 12751 except IndexError:2752 runner.state = 02753 return i2754 if char == '\n':2755 state = 12756 elif char == ' ':2757 state = 22758 else:2759 break2760 if state == 1:2761 runner.last_matched_index = i - 12762 runner.last_matched_state = state2763 try:2764 char = input[i]2765 i += 12766 except IndexError:2767 runner.state = 12768 return i2769 if char == '\n':2770 state = 12771 continue2772 elif char == ' ':2773 state = 12774 continue2775 else:2776 break2777 if state == 2:2778 try:2779 char = input[i]2780 i += 12781 except IndexError:2782 runner.state = 22783 return ~i2784 if char == '\n':2785 state = 12786 continue2787 elif char == ' ':2788 state = 22789 continue2790 else:2791 break2792 runner.last_matched_state = state2793 runner.last_matched_index = i - 12794 runner.state = state2795 if i == len(input):2796 return i2797 else:2798 return ~i2799 break2800 runner.state = state2801 return ~i2802 def recognize_1006631623(runner, i):2803 #auto-generated code, don't edit2804 assert i >= 02805 input = runner.text2806 state = 02807 while 1:2808 if state == 0:2809 try:2810 char = input[i]2811 i += 12812 except IndexError:2813 runner.state = 02814 return ~i2815 if char == '`':2816 state = 32817 else:2818 break2819 if state == 2:2820 try:2821 char = input[i]2822 i += 12823 except IndexError:2824 runner.state = 22825 return ~i2826 if '\x00' <= char <= '\xff':2827 state = 32828 else:2829 break2830 if state == 3:2831 try:2832 char = input[i]2833 i += 12834 except IndexError:2835 runner.state = 32836 return ~i2837 if char == '`':2838 state = 12839 elif char == '\\':2840 state = 22841 continue2842 elif ']' <= char <= '_':2843 state = 32844 continue2845 elif '\x00' <= char <= '[':2846 state = 32847 continue2848 elif 'a' <= char <= '\xff':2849 state = 32850 continue2851 else:2852 break2853 runner.last_matched_state = state2854 runner.last_matched_index = i - 12855 runner.state = state2856 if i == len(input):2857 return i2858 else:2859 return ~i2860 break2861 runner.state = state2862 return ~i2863 def recognize_528667127(runner, i):2864 #auto-generated code, don't edit2865 assert i >= 02866 input = runner.text2867 state = 02868 while 1:2869 if state == 0:2870 try:2871 char = input[i]2872 i += 12873 except IndexError:2874 runner.state = 02875 return ~i2876 if char == ' ':2877 state = 02878 continue2879 elif char == '#':2880 state = 22881 else:2882 break2883 if state == 1:2884 runner.last_matched_index = i - 12885 runner.last_matched_state = state2886 try:2887 char = input[i]2888 i += 12889 except IndexError:2890 runner.state = 12891 return i2892 if char == ' ':2893 state = 02894 continue2895 elif char == '#':2896 state = 22897 else:2898 break2899 if state == 2:2900 try:2901 char = input[i]2902 i += 12903 except IndexError:2904 runner.state = 22905 return ~i2906 if char == '\n':2907 state = 12908 continue2909 elif '\x00' <= char <= '\t':2910 state = 22911 continue2912 elif '\x0b' <= char <= '\xff':2913 state = 22914 continue2915 else:2916 break2917 runner.last_matched_state = state2918 runner.last_matched_index = i - 12919 runner.state = state2920 if i == len(input):2921 return i2922 else:2923 return ~i2924 break2925 runner.state = state2926 return ~i2927 def recognize_291086639(runner, i):2928 #auto-generated code, don't edit2929 assert i >= 02930 input = runner.text2931 state = 02932 while 1:2933 if state == 0:2934 try:2935 char = input[i]2936 i += 12937 except IndexError:2938 runner.state = 02939 return ~i2940 if char == '{':2941 state = 22942 else:2943 break2944 if state == 2:2945 try:2946 char = input[i]2947 i += 12948 except IndexError:2949 runner.state = 22950 return ~i2951 if char == '}':2952 state = 12953 elif '\x00' <= char <= '\t':2954 state = 22955 continue2956 elif '\x0b' <= char <= '|':2957 state = 22958 continue2959 elif '~' <= char <= '\xff':2960 state = 22961 continue2962 else:2963 break2964 runner.last_matched_state = state2965 runner.last_matched_index = i - 12966 runner.state = state2967 if i == len(input):2968 return i2969 else:2970 return ~i2971 break2972 runner.state = state2973 return ~i2974 def recognize_1074651696(runner, i):2975 #auto-generated code, don't edit2976 assert i >= 02977 input = runner.text2978 state = 02979 while 1:2980 if state == 0:2981 try:2982 char = input[i]2983 i += 12984 except IndexError:2985 runner.state = 02986 return ~i2987 if char == '_':2988 state = 12989 elif 'A' <= char <= 'Z':2990 state = 12991 elif 'a' <= char <= 'z':2992 state = 12993 else:2994 break2995 if state == 1:2996 runner.last_matched_index = i - 12997 runner.last_matched_state = state2998 try:2999 char = input[i]3000 i += 13001 except IndexError:3002 runner.state = 13003 return i3004 if char == '_':3005 state = 13006 continue3007 elif '0' <= char <= '9':3008 state = 13009 continue3010 elif 'A' <= char <= 'Z':3011 state = 13012 continue3013 elif 'a' <= char <= 'z':3014 state = 13015 continue3016 else:3017 break3018 runner.last_matched_state = state3019 runner.last_matched_index = i - 13020 runner.state = state3021 if i == len(input):3022 return i3023 else:3024 return ~i3025 break3026 runner.state = state3027 return ~i3028 def recognize_1124192327(runner, i):3029 #auto-generated code, don't edit3030 assert i >= 03031 input = runner.text3032 state = 03033 while 1:3034 if state == 0:3035 try:3036 char = input[i]3037 i += 13038 except IndexError:3039 runner.state = 03040 return ~i3041 if char == "'":3042 state = 13043 else:3044 break3045 if state == 1:3046 try:3047 char = input[i]3048 i += 13049 except IndexError:3050 runner.state = 13051 return ~i3052 if '\x00' <= char <= '&':3053 state = 13054 continue3055 elif '(' <= char <= '\xff':3056 state = 13057 continue3058 elif char == "'":3059 state = 23060 else:3061 break3062 runner.last_matched_state = state3063 runner.last_matched_index = i - 13064 runner.state = state3065 if i == len(input):3066 return i3067 else:3068 return ~i3069 break3070 runner.state = state3071 return ~i3072 def recognize_1979538501(runner, i):3073 #auto-generated code, don't edit3074 assert i >= 03075 input = runner.text3076 state = 03077 while 1:3078 if state == 0:3079 try:3080 char = input[i]3081 i += 13082 except IndexError:3083 runner.state = 03084 return ~i3085 if char == '#':3086 state = 13087 elif char == ' ':3088 state = 23089 elif char == '\t':3090 state = 23091 elif char == '\n':3092 state = 23093 else:3094 break3095 if state == 1:3096 try:3097 char = input[i]3098 i += 13099 except IndexError:3100 runner.state = 13101 return ~i3102 if '\x00' <= char <= '\t':3103 state = 13104 continue3105 elif '\x0b' <= char <= '\xff':3106 state = 13107 continue3108 elif char == '\n':3109 state = 23110 else:3111 break3112 runner.last_matched_state = state3113 runner.last_matched_index = i - 13114 runner.state = state3115 if i == len(input):3116 return i3117 else:3118 return ~i3119 break3120 runner.state = state3121 return ~i3122class PyPackratSyntaxParser(PackratParser):3123 def __init__(self, stream):3124 self.init_parser(stream)3125forbidden = dict.fromkeys(("__weakref__ __doc__ "3126 "__dict__ __module__").split())3127initthere = "__init__" in PyPackratSyntaxParser.__dict__3128for key, value in Parser.__dict__.iteritems():3129 if key not in PyPackratSyntaxParser.__dict__ and key not in forbidden:3130 setattr(PyPackratSyntaxParser, key, value)...
regexparse.py
Source:regexparse.py
1import py2from rpython.rlib.parsing.parsing import PackratParser, Rule3from rpython.rlib.parsing.tree import Nonterminal4from rpython.rlib.parsing.regex import StringExpression, RangeExpression5from rpython.rlib.parsing.lexer import Lexer, DummyLexer6from rpython.rlib.parsing.deterministic import compress_char_set, DFA7import string8set = py.builtin.set9ESCAPES = {10 "a": "\a",11 "b": "\b",12 "e": "\x1b",13 "f": "\f",14 "n": "\n",15 "r": "\r",16 "t": "\t",17 "v": "\v",18}19for i in range(256):20 # Add the ctrl-x types:21 # Rule, according to PCRE:22 # if x is a lower case letter, it is converted to upper case. 23 # Then bit 6 of the character (hex 40) is inverted. 24 # Thus, \cz => 0x1A, \c{ => 0x3B, \c; => 0x7B.25 escaped = "c%s" % chr(i)26 ESCAPES[escaped] = chr(ord(chr(i).upper()) ^ 0x40)27def unescape_muncher(string):28 """Return a tuple, representing the first character of the string29 (appropriately unescaped) and the rest of the string that wasn't30 handled."""31 if string[0] != '\\':32 # Not an escape character33 return string[0], string[1:]34 if string[1] == 'x':35 # Hex char, must have two hex digits36 char = chr(int(string[2:4], 16))37 return char, string[4:]38 if string[1] in '01234567':39 # Octal number, up to three digits long40 span = 241 span += (span < len(string)) and (string[span] in '01234567')42 span += (span < len(string)) and (string[span] in '01234567')43 char = chr(int(string[1:span], 8))44 return char, string[span:]45 if string[1] == 'c':46 # Special \cx types47 return ESCAPES['c'+string[2]], string[3:]48 if string[1] in ESCAPES:49 # Special escapes are in ESCAPE50 return ESCAPES[string[1]], string[2:]51 # Otherwise, it's just the character it's meant to be (e.g., '\.')52 return string[1], string[2:]53 54 55def unescape(s):56 """Unescape a whole string."""57 result = []58 while s:59 char, s = unescape_muncher(s)60 result.append(char)61 return "".join(result)62syntax = r"""63EOF:64 !__any__;65parse:66 regex67 [EOF];68regex:69 r1 = concatenation70 '|'71 r2 = regex72 return {r1 | r2}73 | concatenation;74concatenation:75 l = repetition*76 return {reduce(operator.add, l, regex.StringExpression(""))};77repetition:78 r1 = primary79 '*'80 return {r1.kleene()}81 | r1 = primary82 '+'83 return {r1 + r1.kleene()}84 | r1 = primary85 '?'86 return {regex.StringExpression("") | r1}87 | r1 = primary88 '{'89 n = clippednumrange90 '}'91 return {r1 * n + r1.kleene()}92 | r1 = primary93 '{'94 n = numrange95 '}'96 return {r1 * n[0] + reduce(operator.or_, [r1 * i for i in range(n[1] - n[0] + 1)], regex.StringExpression(""))}97 | '{'98 return {regex.StringExpression("{")}99 | primary;100primary:101 ['('] regex [')']102 | range103 | cc = charclass104 return {reduce(operator.or_, [regex.RangeExpression(a, chr(ord(a) + b - 1)) for a, b in compress_char_set(cc)])}105 | c = char106 return {regex.StringExpression(c)}107 | '.'108 return {regex.RangeExpression(chr(0), chr(255))}109 | '-'110 return {regex.StringExpression('-')}111 | '\'112 return {regex.StringExpression('\\')}113 | ']'114 return {regex.StringExpression(']')};115char:116 c = QUOTEDCHAR117 return {unescape(c)}118 | c = CHAR119 return {c};120QUOTEDCHAR:121 `(\\x[0-9a-fA-F]{2})|(\\[0-3]?[0-7][0-7])|(\\c.)|(\\[^dswDSW])`;122 123CHAR:124 `[^\*\+\(\)\[\]\{\|\.\-\?\^\\]`;125range:126 '['127 s = rangeinner128 ']'129 return {reduce(operator.or_, [regex.RangeExpression(a, chr(ord(a) + b - 1)) for a, b in compress_char_set(s)])};130rangeinner:131 '^'132 s = subrange133 return {set([chr(c) for c in range(256)]) - s}134 | subrange;135subrange:136 ']'137 l = rangeelement*138 return {reduce(operator.or_, [set(["]"])] + l)}139 | l = rangeelement+140 return {reduce(operator.or_, l)};141rangeelement:142 charclass143 | c1 = char144 '-'145 c2 = char146 return {set([chr(i) for i in range(ord(c1), ord(c2) + 1)])}147 | '.'148 return { set(['.']) }149 | '*'150 return { set(['*']) }151 | '+'152 return { set(['+']) }153 | '?'154 return { set(['?']) }155 | '-'156 return { set(['-']) }157 | '['158 return { set(['[']) }159 | c = char160 return { set([c]) };161numrange:162 n1 = NUM163 ','164 n2 = NUM165 return {n1, n2}166 | n1 = NUM167 return {n1, n1};168clippednumrange:169 n1 = NUM170 ','171 return {n1};172charclass:173 '\' 'd'174 return { set([chr(c) for c in range(ord('0'), ord('9')+1)]) }175 | '\' 's'176 return { set(['\t', '\n', '\f', '\r', ' ']) }177 | '\' 'w'178 return { set([chr(c) for c in range(ord('a'), ord('z')+1)] + [chr(c) for c in range(ord('A'), ord('Z')+1)] + [chr(c) for c in range(ord('0'), ord('9')+1)] + ['_']) }179 | '\' 'D'180 return { set([chr(c) for c in range(256)]) - set([chr(c) for c in range(ord('0'), ord('9')+1)]) }181 | '\' 'S'182 return { set([chr(c) for c in range(256)]) - set(['\t', '\n', '\f', '\r', ' ']) }183 | '\' 'W'184 return { set([chr(c) for c in range(256)]) - set([chr(c) for c in range(ord('a'), ord('z')+1)] + [chr(c) for c in range(ord('A'), ord('Z')+1)] + [chr(c) for c in range(ord('0'), ord('9')+1)] + ['_'])};185NUM:186 c = `0|([1-9][0-9]*)`187 return {int(c)};188"""189def parse_regex(s):190 p = RegexParser(s)191 r = p.parse()192 return r193def make_runner(regex, view=False):194 r = parse_regex(regex)195 nfa = r.make_automaton()196 dfa = nfa.make_deterministic()197 if view:198 dfa.view()199 dfa.optimize()200 if view:201 dfa.view()202 r = dfa.get_runner()203 return r204# generated code between this line and its other occurence205from rpython.rlib.parsing.pypackrat import PackratParser, Status206from rpython.rlib.parsing.pypackrat import BacktrackException207from rpython.rlib.parsing import regex208import operator209class Parser(object):210 def EOF(self):211 return self._EOF().result212 def _EOF(self):213 _key = self._pos214 _status = self._dict_EOF.get(_key, None)215 if _status is None:216 _status = self._dict_EOF[_key] = Status()217 else:218 _statusstatus = _status.status219 if _statusstatus == _status.NORMAL:220 self._pos = _status.pos221 return _status222 elif _statusstatus == _status.ERROR:223 raise BacktrackException(_status.error)224 elif (_statusstatus == _status.INPROGRESS or225 _statusstatus == _status.LEFTRECURSION):226 _status.status = _status.LEFTRECURSION227 if _status.result is not None:228 self._pos = _status.pos229 return _status230 else:231 raise BacktrackException(None)232 elif _statusstatus == _status.SOMESOLUTIONS:233 _status.status = _status.INPROGRESS234 _startingpos = self._pos235 try:236 _result = None237 _error = None238 _choice0 = self._pos239 _stored_result1 = _result240 try:241 _result = self.__any__()242 except BacktrackException:243 self._pos = _choice0244 _result = _stored_result1245 else:246 raise BacktrackException(None)247 if _status.status == _status.LEFTRECURSION:248 if _status.result is not None:249 if _status.pos >= self._pos:250 _status.status = _status.NORMAL251 self._pos = _status.pos252 return _status253 _status.pos = self._pos254 _status.status = _status.SOMESOLUTIONS255 _status.result = _result256 _status.error = _error257 self._pos = _startingpos258 return self._EOF()259 _status.status = _status.NORMAL260 _status.pos = self._pos261 _status.result = _result262 _status.error = _error263 return _status264 except BacktrackException, _exc:265 _status.pos = -1266 _status.result = None267 _error = _exc.error268 _status.error = _error269 _status.status = _status.ERROR270 raise BacktrackException(_error)271 def parse(self):272 return self._parse().result273 def _parse(self):274 _key = self._pos275 _status = self._dict_parse.get(_key, None)276 if _status is None:277 _status = self._dict_parse[_key] = Status()278 else:279 _statusstatus = _status.status280 if _statusstatus == _status.NORMAL:281 self._pos = _status.pos282 return _status283 elif _statusstatus == _status.ERROR:284 raise BacktrackException(_status.error)285 elif (_statusstatus == _status.INPROGRESS or286 _statusstatus == _status.LEFTRECURSION):287 _status.status = _status.LEFTRECURSION288 if _status.result is not None:289 self._pos = _status.pos290 return _status291 else:292 raise BacktrackException(None)293 elif _statusstatus == _status.SOMESOLUTIONS:294 _status.status = _status.INPROGRESS295 _startingpos = self._pos296 try:297 _result = None298 _error = None299 _call_status = self._regex()300 _result = _call_status.result301 _error = _call_status.error302 _before_discard0 = _result303 _call_status = self._EOF()304 _result = _call_status.result305 _error = self._combine_errors(_error, _call_status.error)306 _result = _before_discard0307 if _status.status == _status.LEFTRECURSION:308 if _status.result is not None:309 if _status.pos >= self._pos:310 _status.status = _status.NORMAL311 self._pos = _status.pos312 return _status313 _status.pos = self._pos314 _status.status = _status.SOMESOLUTIONS315 _status.result = _result316 _status.error = _error317 self._pos = _startingpos318 return self._parse()319 _status.status = _status.NORMAL320 _status.pos = self._pos321 _status.result = _result322 _status.error = _error323 return _status324 except BacktrackException, _exc:325 _status.pos = -1326 _status.result = None327 _error = self._combine_errors(_error, _exc.error)328 _status.error = _error329 _status.status = _status.ERROR330 raise BacktrackException(_error)331 def regex(self):332 return self._regex().result333 def _regex(self):334 _key = self._pos335 _status = self._dict_regex.get(_key, None)336 if _status is None:337 _status = self._dict_regex[_key] = Status()338 else:339 _statusstatus = _status.status340 if _statusstatus == _status.NORMAL:341 self._pos = _status.pos342 return _status343 elif _statusstatus == _status.ERROR:344 raise BacktrackException(_status.error)345 elif (_statusstatus == _status.INPROGRESS or346 _statusstatus == _status.LEFTRECURSION):347 _status.status = _status.LEFTRECURSION348 if _status.result is not None:349 self._pos = _status.pos350 return _status351 else:352 raise BacktrackException(None)353 elif _statusstatus == _status.SOMESOLUTIONS:354 _status.status = _status.INPROGRESS355 _startingpos = self._pos356 try:357 _result = None358 _error = None359 while 1:360 _choice0 = self._pos361 try:362 _call_status = self._concatenation()363 _result = _call_status.result364 _error = _call_status.error365 r1 = _result366 _result = self.__chars__('|')367 _call_status = self._regex()368 _result = _call_status.result369 _error = self._combine_errors(_error, _call_status.error)370 r2 = _result371 _result = (r1 | r2)372 break373 except BacktrackException, _exc:374 _error = self._combine_errors(_error, _exc.error)375 self._pos = _choice0376 _choice1 = self._pos377 try:378 _call_status = self._concatenation()379 _result = _call_status.result380 _error = self._combine_errors(_error, _call_status.error)381 break382 except BacktrackException, _exc:383 _error = self._combine_errors(_error, _exc.error)384 self._pos = _choice1385 raise BacktrackException(_error)386 _call_status = self._concatenation()387 _result = _call_status.result388 _error = self._combine_errors(_error, _call_status.error)389 break390 if _status.status == _status.LEFTRECURSION:391 if _status.result is not None:392 if _status.pos >= self._pos:393 _status.status = _status.NORMAL394 self._pos = _status.pos395 return _status396 _status.pos = self._pos397 _status.status = _status.SOMESOLUTIONS398 _status.result = _result399 _status.error = _error400 self._pos = _startingpos401 return self._regex()402 _status.status = _status.NORMAL403 _status.pos = self._pos404 _status.result = _result405 _status.error = _error406 return _status407 except BacktrackException, _exc:408 _status.pos = -1409 _status.result = None410 _error = self._combine_errors(_error, _exc.error)411 _status.error = _error412 _status.status = _status.ERROR413 raise BacktrackException(_error)414 def concatenation(self):415 return self._concatenation().result416 def _concatenation(self):417 _key = self._pos418 _status = self._dict_concatenation.get(_key, None)419 if _status is None:420 _status = self._dict_concatenation[_key] = Status()421 else:422 _statusstatus = _status.status423 if _statusstatus == _status.NORMAL:424 self._pos = _status.pos425 return _status426 elif _statusstatus == _status.ERROR:427 raise BacktrackException(_status.error)428 elif (_statusstatus == _status.INPROGRESS or429 _statusstatus == _status.LEFTRECURSION):430 _status.status = _status.LEFTRECURSION431 if _status.result is not None:432 self._pos = _status.pos433 return _status434 else:435 raise BacktrackException(None)436 elif _statusstatus == _status.SOMESOLUTIONS:437 _status.status = _status.INPROGRESS438 _startingpos = self._pos439 try:440 _result = None441 _error = None442 _all0 = []443 while 1:444 _choice1 = self._pos445 try:446 _call_status = self._repetition()447 _result = _call_status.result448 _error = _call_status.error449 _all0.append(_result)450 except BacktrackException, _exc:451 _error = self._combine_errors(_error, _exc.error)452 self._pos = _choice1453 break454 _result = _all0455 l = _result456 _result = (reduce(operator.add, l, regex.StringExpression("")))457 if _status.status == _status.LEFTRECURSION:458 if _status.result is not None:459 if _status.pos >= self._pos:460 _status.status = _status.NORMAL461 self._pos = _status.pos462 return _status463 _status.pos = self._pos464 _status.status = _status.SOMESOLUTIONS465 _status.result = _result466 _status.error = _error467 self._pos = _startingpos468 return self._concatenation()469 _status.status = _status.NORMAL470 _status.pos = self._pos471 _status.result = _result472 _status.error = _error473 return _status474 except BacktrackException, _exc:475 _status.pos = -1476 _status.result = None477 _error = self._combine_errors(_error, _exc.error)478 _status.error = _error479 _status.status = _status.ERROR480 raise BacktrackException(_error)481 def repetition(self):482 return self._repetition().result483 def _repetition(self):484 _key = self._pos485 _status = self._dict_repetition.get(_key, None)486 if _status is None:487 _status = self._dict_repetition[_key] = Status()488 else:489 _statusstatus = _status.status490 if _statusstatus == _status.NORMAL:491 self._pos = _status.pos492 return _status493 elif _statusstatus == _status.ERROR:494 raise BacktrackException(_status.error)495 elif (_statusstatus == _status.INPROGRESS or496 _statusstatus == _status.LEFTRECURSION):497 _status.status = _status.LEFTRECURSION498 if _status.result is not None:499 self._pos = _status.pos500 return _status501 else:502 raise BacktrackException(None)503 elif _statusstatus == _status.SOMESOLUTIONS:504 _status.status = _status.INPROGRESS505 _startingpos = self._pos506 try:507 _result = None508 _error = None509 while 1:510 _choice0 = self._pos511 try:512 _call_status = self._primary()513 _result = _call_status.result514 _error = _call_status.error515 r1 = _result516 _result = self.__chars__('*')517 _result = (r1.kleene())518 break519 except BacktrackException, _exc:520 _error = self._combine_errors(_error, _exc.error)521 self._pos = _choice0522 _choice1 = self._pos523 try:524 _call_status = self._primary()525 _result = _call_status.result526 _error = self._combine_errors(_error, _call_status.error)527 r1 = _result528 _result = self.__chars__('+')529 _result = (r1 + r1.kleene())530 break531 except BacktrackException, _exc:532 _error = self._combine_errors(_error, _exc.error)533 self._pos = _choice1534 _choice2 = self._pos535 try:536 _call_status = self._primary()537 _result = _call_status.result538 _error = self._combine_errors(_error, _call_status.error)539 r1 = _result540 _result = self.__chars__('?')541 _result = (regex.StringExpression("") | r1)542 break543 except BacktrackException, _exc:544 _error = self._combine_errors(_error, _exc.error)545 self._pos = _choice2546 _choice3 = self._pos547 try:548 _call_status = self._primary()549 _result = _call_status.result550 _error = self._combine_errors(_error, _call_status.error)551 r1 = _result552 _result = self.__chars__('{')553 _call_status = self._clippednumrange()554 _result = _call_status.result555 _error = self._combine_errors(_error, _call_status.error)556 n = _result557 _result = self.__chars__('}')558 _result = (r1 * n + r1.kleene())559 break560 except BacktrackException, _exc:561 _error = self._combine_errors(_error, _exc.error)562 self._pos = _choice3563 _choice4 = self._pos564 try:565 _call_status = self._primary()566 _result = _call_status.result567 _error = self._combine_errors(_error, _call_status.error)568 r1 = _result569 _result = self.__chars__('{')570 _call_status = self._numrange()571 _result = _call_status.result572 _error = self._combine_errors(_error, _call_status.error)573 n = _result574 _result = self.__chars__('}')575 _result = (r1 * n[0] + reduce(operator.or_, [r1 * i for i in range(n[1] - n[0] + 1)], regex.StringExpression("")))576 break577 except BacktrackException, _exc:578 _error = self._combine_errors(_error, _exc.error)579 self._pos = _choice4580 _choice5 = self._pos581 try:582 _result = self.__chars__('{')583 _result = (regex.StringExpression("{"))584 break585 except BacktrackException, _exc:586 _error = self._combine_errors(_error, _exc.error)587 self._pos = _choice5588 _choice6 = self._pos589 try:590 _call_status = self._primary()591 _result = _call_status.result592 _error = self._combine_errors(_error, _call_status.error)593 break594 except BacktrackException, _exc:595 _error = self._combine_errors(_error, _exc.error)596 self._pos = _choice6597 raise BacktrackException(_error)598 _call_status = self._primary()599 _result = _call_status.result600 _error = self._combine_errors(_error, _call_status.error)601 break602 if _status.status == _status.LEFTRECURSION:603 if _status.result is not None:604 if _status.pos >= self._pos:605 _status.status = _status.NORMAL606 self._pos = _status.pos607 return _status608 _status.pos = self._pos609 _status.status = _status.SOMESOLUTIONS610 _status.result = _result611 _status.error = _error612 self._pos = _startingpos613 return self._repetition()614 _status.status = _status.NORMAL615 _status.pos = self._pos616 _status.result = _result617 _status.error = _error618 return _status619 except BacktrackException, _exc:620 _status.pos = -1621 _status.result = None622 _error = self._combine_errors(_error, _exc.error)623 _status.error = _error624 _status.status = _status.ERROR625 raise BacktrackException(_error)626 def primary(self):627 return self._primary().result628 def _primary(self):629 _key = self._pos630 _status = self._dict_primary.get(_key, None)631 if _status is None:632 _status = self._dict_primary[_key] = Status()633 else:634 _statusstatus = _status.status635 if _statusstatus == _status.NORMAL:636 self._pos = _status.pos637 return _status638 elif _statusstatus == _status.ERROR:639 raise BacktrackException(_status.error)640 elif (_statusstatus == _status.INPROGRESS or641 _statusstatus == _status.LEFTRECURSION):642 _status.status = _status.LEFTRECURSION643 if _status.result is not None:644 self._pos = _status.pos645 return _status646 else:647 raise BacktrackException(None)648 elif _statusstatus == _status.SOMESOLUTIONS:649 _status.status = _status.INPROGRESS650 _startingpos = self._pos651 try:652 _result = None653 _error = None654 while 1:655 _choice0 = self._pos656 try:657 _before_discard1 = _result658 _result = self.__chars__('(')659 _result = _before_discard1660 _call_status = self._regex()661 _result = _call_status.result662 _error = _call_status.error663 _before_discard2 = _result664 _result = self.__chars__(')')665 _result = _before_discard2666 break667 except BacktrackException, _exc:668 _error = self._combine_errors(_error, _exc.error)669 self._pos = _choice0670 _choice3 = self._pos671 try:672 _call_status = self._range()673 _result = _call_status.result674 _error = self._combine_errors(_error, _call_status.error)675 break676 except BacktrackException, _exc:677 _error = self._combine_errors(_error, _exc.error)678 self._pos = _choice3679 _choice4 = self._pos680 try:681 _call_status = self._charclass()682 _result = _call_status.result683 _error = self._combine_errors(_error, _call_status.error)684 cc = _result685 _result = (reduce(operator.or_, [regex.RangeExpression(a, chr(ord(a) + b - 1)) for a, b in compress_char_set(cc)]))686 break687 except BacktrackException, _exc:688 _error = self._combine_errors(_error, _exc.error)689 self._pos = _choice4690 _choice5 = self._pos691 try:692 _call_status = self._char()693 _result = _call_status.result694 _error = self._combine_errors(_error, _call_status.error)695 c = _result696 _result = (regex.StringExpression(c))697 break698 except BacktrackException, _exc:699 _error = self._combine_errors(_error, _exc.error)700 self._pos = _choice5701 _choice6 = self._pos702 try:703 _result = self.__chars__('.')704 _result = (regex.RangeExpression(chr(0), chr(255)))705 break706 except BacktrackException, _exc:707 _error = self._combine_errors(_error, _exc.error)708 self._pos = _choice6709 _choice7 = self._pos710 try:711 _result = self.__chars__('-')712 _result = (regex.StringExpression('-'))713 break714 except BacktrackException, _exc:715 _error = self._combine_errors(_error, _exc.error)716 self._pos = _choice7717 _choice8 = self._pos718 try:719 _result = self.__chars__('\\')720 _result = (regex.StringExpression('\\'))721 break722 except BacktrackException, _exc:723 _error = self._combine_errors(_error, _exc.error)724 self._pos = _choice8725 _choice9 = self._pos726 try:727 _result = self.__chars__(']')728 _result = (regex.StringExpression(']'))729 break730 except BacktrackException, _exc:731 _error = self._combine_errors(_error, _exc.error)732 self._pos = _choice9733 raise BacktrackException(_error)734 _result = self.__chars__(']')735 _result = (regex.StringExpression(']'))736 break737 if _status.status == _status.LEFTRECURSION:738 if _status.result is not None:739 if _status.pos >= self._pos:740 _status.status = _status.NORMAL741 self._pos = _status.pos742 return _status743 _status.pos = self._pos744 _status.status = _status.SOMESOLUTIONS745 _status.result = _result746 _status.error = _error747 self._pos = _startingpos748 return self._primary()749 _status.status = _status.NORMAL750 _status.pos = self._pos751 _status.result = _result752 _status.error = _error753 return _status754 except BacktrackException, _exc:755 _status.pos = -1756 _status.result = None757 _error = self._combine_errors(_error, _exc.error)758 _status.error = _error759 _status.status = _status.ERROR760 raise BacktrackException(_error)761 def char(self):762 return self._char().result763 def _char(self):764 _key = self._pos765 _status = self._dict_char.get(_key, None)766 if _status is None:767 _status = self._dict_char[_key] = Status()768 else:769 _statusstatus = _status.status770 if _statusstatus == _status.NORMAL:771 self._pos = _status.pos772 return _status773 elif _statusstatus == _status.ERROR:774 raise BacktrackException(_status.error)775 elif (_statusstatus == _status.INPROGRESS or776 _statusstatus == _status.LEFTRECURSION):777 _status.status = _status.LEFTRECURSION778 if _status.result is not None:779 self._pos = _status.pos780 return _status781 else:782 raise BacktrackException(None)783 elif _statusstatus == _status.SOMESOLUTIONS:784 _status.status = _status.INPROGRESS785 _startingpos = self._pos786 try:787 _result = None788 _error = None789 while 1:790 _choice0 = self._pos791 try:792 _call_status = self._QUOTEDCHAR()793 _result = _call_status.result794 _error = _call_status.error795 c = _result796 _result = (unescape(c))797 break798 except BacktrackException, _exc:799 _error = self._combine_errors(_error, _exc.error)800 self._pos = _choice0801 _choice1 = self._pos802 try:803 _call_status = self._CHAR()804 _result = _call_status.result805 _error = self._combine_errors(_error, _call_status.error)806 c = _result807 _result = (c)808 break809 except BacktrackException, _exc:810 _error = self._combine_errors(_error, _exc.error)811 self._pos = _choice1812 raise BacktrackException(_error)813 _call_status = self._CHAR()814 _result = _call_status.result815 _error = self._combine_errors(_error, _call_status.error)816 c = _result817 _result = (c)818 break819 if _status.status == _status.LEFTRECURSION:820 if _status.result is not None:821 if _status.pos >= self._pos:822 _status.status = _status.NORMAL823 self._pos = _status.pos824 return _status825 _status.pos = self._pos826 _status.status = _status.SOMESOLUTIONS827 _status.result = _result828 _status.error = _error829 self._pos = _startingpos830 return self._char()831 _status.status = _status.NORMAL832 _status.pos = self._pos833 _status.result = _result834 _status.error = _error835 return _status836 except BacktrackException, _exc:837 _status.pos = -1838 _status.result = None839 _error = self._combine_errors(_error, _exc.error)840 _status.error = _error841 _status.status = _status.ERROR842 raise BacktrackException(_error)843 def QUOTEDCHAR(self):844 return self._QUOTEDCHAR().result845 def _QUOTEDCHAR(self):846 _key = self._pos847 _status = self._dict_QUOTEDCHAR.get(_key, None)848 if _status is None:849 _status = self._dict_QUOTEDCHAR[_key] = Status()850 else:851 _statusstatus = _status.status852 if _statusstatus == _status.NORMAL:853 self._pos = _status.pos854 return _status855 elif _statusstatus == _status.ERROR:856 raise BacktrackException(_status.error)857 _startingpos = self._pos858 try:859 _result = None860 _error = None861 _result = self._regex1423754537()862 assert _status.status != _status.LEFTRECURSION863 _status.status = _status.NORMAL864 _status.pos = self._pos865 _status.result = _result866 _status.error = _error867 return _status868 except BacktrackException, _exc:869 _status.pos = -1870 _status.result = None871 _error = _exc.error872 _status.error = _error873 _status.status = _status.ERROR874 raise BacktrackException(_error)875 def CHAR(self):876 return self._CHAR().result877 def _CHAR(self):878 _key = self._pos879 _status = self._dict_CHAR.get(_key, None)880 if _status is None:881 _status = self._dict_CHAR[_key] = Status()882 else:883 _statusstatus = _status.status884 if _statusstatus == _status.NORMAL:885 self._pos = _status.pos886 return _status887 elif _statusstatus == _status.ERROR:888 raise BacktrackException(_status.error)889 _startingpos = self._pos890 try:891 _result = None892 _error = None893 _result = self._regex2132196932()894 assert _status.status != _status.LEFTRECURSION895 _status.status = _status.NORMAL896 _status.pos = self._pos897 _status.result = _result898 _status.error = _error899 return _status900 except BacktrackException, _exc:901 _status.pos = -1902 _status.result = None903 _error = _exc.error904 _status.error = _error905 _status.status = _status.ERROR906 raise BacktrackException(_error)907 def range(self):908 return self._range().result909 def _range(self):910 _key = self._pos911 _status = self._dict_range.get(_key, None)912 if _status is None:913 _status = self._dict_range[_key] = Status()914 else:915 _statusstatus = _status.status916 if _statusstatus == _status.NORMAL:917 self._pos = _status.pos918 return _status919 elif _statusstatus == _status.ERROR:920 raise BacktrackException(_status.error)921 elif (_statusstatus == _status.INPROGRESS or922 _statusstatus == _status.LEFTRECURSION):923 _status.status = _status.LEFTRECURSION924 if _status.result is not None:925 self._pos = _status.pos926 return _status927 else:928 raise BacktrackException(None)929 elif _statusstatus == _status.SOMESOLUTIONS:930 _status.status = _status.INPROGRESS931 _startingpos = self._pos932 try:933 _result = None934 _error = None935 _result = self.__chars__('[')936 _call_status = self._rangeinner()937 _result = _call_status.result938 _error = _call_status.error939 s = _result940 _result = self.__chars__(']')941 _result = (reduce(operator.or_, [regex.RangeExpression(a, chr(ord(a) + b - 1)) for a, b in compress_char_set(s)]))942 if _status.status == _status.LEFTRECURSION:943 if _status.result is not None:944 if _status.pos >= self._pos:945 _status.status = _status.NORMAL946 self._pos = _status.pos947 return _status948 _status.pos = self._pos949 _status.status = _status.SOMESOLUTIONS950 _status.result = _result951 _status.error = _error952 self._pos = _startingpos953 return self._range()954 _status.status = _status.NORMAL955 _status.pos = self._pos956 _status.result = _result957 _status.error = _error958 return _status959 except BacktrackException, _exc:960 _status.pos = -1961 _status.result = None962 _error = self._combine_errors(_error, _exc.error)963 _status.error = _error964 _status.status = _status.ERROR965 raise BacktrackException(_error)966 def rangeinner(self):967 return self._rangeinner().result968 def _rangeinner(self):969 _key = self._pos970 _status = self._dict_rangeinner.get(_key, None)971 if _status is None:972 _status = self._dict_rangeinner[_key] = Status()973 else:974 _statusstatus = _status.status975 if _statusstatus == _status.NORMAL:976 self._pos = _status.pos977 return _status978 elif _statusstatus == _status.ERROR:979 raise BacktrackException(_status.error)980 elif (_statusstatus == _status.INPROGRESS or981 _statusstatus == _status.LEFTRECURSION):982 _status.status = _status.LEFTRECURSION983 if _status.result is not None:984 self._pos = _status.pos985 return _status986 else:987 raise BacktrackException(None)988 elif _statusstatus == _status.SOMESOLUTIONS:989 _status.status = _status.INPROGRESS990 _startingpos = self._pos991 try:992 _result = None993 _error = None994 while 1:995 _choice0 = self._pos996 try:997 _result = self.__chars__('^')998 _call_status = self._subrange()999 _result = _call_status.result1000 _error = _call_status.error1001 s = _result1002 _result = (set([chr(c) for c in range(256)]) - s)1003 break1004 except BacktrackException, _exc:1005 _error = self._combine_errors(_error, _exc.error)1006 self._pos = _choice01007 _choice1 = self._pos1008 try:1009 _call_status = self._subrange()1010 _result = _call_status.result1011 _error = self._combine_errors(_error, _call_status.error)1012 break1013 except BacktrackException, _exc:1014 _error = self._combine_errors(_error, _exc.error)1015 self._pos = _choice11016 raise BacktrackException(_error)1017 _call_status = self._subrange()1018 _result = _call_status.result1019 _error = self._combine_errors(_error, _call_status.error)1020 break1021 if _status.status == _status.LEFTRECURSION:1022 if _status.result is not None:1023 if _status.pos >= self._pos:1024 _status.status = _status.NORMAL1025 self._pos = _status.pos1026 return _status1027 _status.pos = self._pos1028 _status.status = _status.SOMESOLUTIONS1029 _status.result = _result1030 _status.error = _error1031 self._pos = _startingpos1032 return self._rangeinner()1033 _status.status = _status.NORMAL1034 _status.pos = self._pos1035 _status.result = _result1036 _status.error = _error1037 return _status1038 except BacktrackException, _exc:1039 _status.pos = -11040 _status.result = None1041 _error = self._combine_errors(_error, _exc.error)1042 _status.error = _error1043 _status.status = _status.ERROR1044 raise BacktrackException(_error)1045 def subrange(self):1046 return self._subrange().result1047 def _subrange(self):1048 _key = self._pos1049 _status = self._dict_subrange.get(_key, None)1050 if _status is None:1051 _status = self._dict_subrange[_key] = Status()1052 else:1053 _statusstatus = _status.status1054 if _statusstatus == _status.NORMAL:1055 self._pos = _status.pos1056 return _status1057 elif _statusstatus == _status.ERROR:1058 raise BacktrackException(_status.error)1059 elif (_statusstatus == _status.INPROGRESS or1060 _statusstatus == _status.LEFTRECURSION):1061 _status.status = _status.LEFTRECURSION1062 if _status.result is not None:1063 self._pos = _status.pos1064 return _status1065 else:1066 raise BacktrackException(None)1067 elif _statusstatus == _status.SOMESOLUTIONS:1068 _status.status = _status.INPROGRESS1069 _startingpos = self._pos1070 try:1071 _result = None1072 _error = None1073 while 1:1074 _choice0 = self._pos1075 try:1076 _result = self.__chars__(']')1077 _all1 = []1078 while 1:1079 _choice2 = self._pos1080 try:1081 _call_status = self._rangeelement()1082 _result = _call_status.result1083 _error = _call_status.error1084 _all1.append(_result)1085 except BacktrackException, _exc:1086 _error = self._combine_errors(_error, _exc.error)1087 self._pos = _choice21088 break1089 _result = _all11090 l = _result1091 _result = (reduce(operator.or_, [set(["]"])] + l))1092 break1093 except BacktrackException, _exc:1094 _error = self._combine_errors(_error, _exc.error)1095 self._pos = _choice01096 _choice3 = self._pos1097 try:1098 _all4 = []1099 _call_status = self._rangeelement()1100 _result = _call_status.result1101 _error = self._combine_errors(_error, _call_status.error)1102 _all4.append(_result)1103 while 1:1104 _choice5 = self._pos1105 try:1106 _call_status = self._rangeelement()1107 _result = _call_status.result1108 _error = self._combine_errors(_error, _call_status.error)1109 _all4.append(_result)1110 except BacktrackException, _exc:1111 _error = self._combine_errors(_error, _exc.error)1112 self._pos = _choice51113 break1114 _result = _all41115 l = _result1116 _result = (reduce(operator.or_, l))1117 break1118 except BacktrackException, _exc:1119 _error = self._combine_errors(_error, _exc.error)1120 self._pos = _choice31121 raise BacktrackException(_error)1122 _all6 = []1123 _call_status = self._rangeelement()1124 _result = _call_status.result1125 _error = self._combine_errors(_error, _call_status.error)1126 _all6.append(_result)1127 while 1:1128 _choice7 = self._pos1129 try:1130 _call_status = self._rangeelement()1131 _result = _call_status.result1132 _error = self._combine_errors(_error, _call_status.error)1133 _all6.append(_result)1134 except BacktrackException, _exc:1135 _error = self._combine_errors(_error, _exc.error)1136 self._pos = _choice71137 break1138 _result = _all61139 l = _result1140 _result = (reduce(operator.or_, l))1141 break1142 if _status.status == _status.LEFTRECURSION:1143 if _status.result is not None:1144 if _status.pos >= self._pos:1145 _status.status = _status.NORMAL1146 self._pos = _status.pos1147 return _status1148 _status.pos = self._pos1149 _status.status = _status.SOMESOLUTIONS1150 _status.result = _result1151 _status.error = _error1152 self._pos = _startingpos1153 return self._subrange()1154 _status.status = _status.NORMAL1155 _status.pos = self._pos1156 _status.result = _result1157 _status.error = _error1158 return _status1159 except BacktrackException, _exc:1160 _status.pos = -11161 _status.result = None1162 _error = self._combine_errors(_error, _exc.error)1163 _status.error = _error1164 _status.status = _status.ERROR1165 raise BacktrackException(_error)1166 def rangeelement(self):1167 return self._rangeelement().result1168 def _rangeelement(self):1169 _key = self._pos1170 _status = self._dict_rangeelement.get(_key, None)1171 if _status is None:1172 _status = self._dict_rangeelement[_key] = Status()1173 else:1174 _statusstatus = _status.status1175 if _statusstatus == _status.NORMAL:1176 self._pos = _status.pos1177 return _status1178 elif _statusstatus == _status.ERROR:1179 raise BacktrackException(_status.error)1180 elif (_statusstatus == _status.INPROGRESS or1181 _statusstatus == _status.LEFTRECURSION):1182 _status.status = _status.LEFTRECURSION1183 if _status.result is not None:1184 self._pos = _status.pos1185 return _status1186 else:1187 raise BacktrackException(None)1188 elif _statusstatus == _status.SOMESOLUTIONS:1189 _status.status = _status.INPROGRESS1190 _startingpos = self._pos1191 try:1192 _result = None1193 _error = None1194 while 1:1195 _choice0 = self._pos1196 try:1197 _call_status = self._charclass()1198 _result = _call_status.result1199 _error = _call_status.error1200 break1201 except BacktrackException, _exc:1202 _error = self._combine_errors(_error, _exc.error)1203 self._pos = _choice01204 _choice1 = self._pos1205 try:1206 _call_status = self._char()1207 _result = _call_status.result1208 _error = self._combine_errors(_error, _call_status.error)1209 c1 = _result1210 _result = self.__chars__('-')1211 _call_status = self._char()1212 _result = _call_status.result1213 _error = self._combine_errors(_error, _call_status.error)1214 c2 = _result1215 _result = (set([chr(i) for i in range(ord(c1), ord(c2) + 1)]))1216 break1217 except BacktrackException, _exc:1218 _error = self._combine_errors(_error, _exc.error)1219 self._pos = _choice11220 _choice2 = self._pos1221 try:1222 _result = self.__chars__('.')1223 _result = ( set(['.']) )1224 break1225 except BacktrackException, _exc:1226 _error = self._combine_errors(_error, _exc.error)1227 self._pos = _choice21228 _choice3 = self._pos1229 try:1230 _result = self.__chars__('*')1231 _result = ( set(['*']) )1232 break1233 except BacktrackException, _exc:1234 _error = self._combine_errors(_error, _exc.error)1235 self._pos = _choice31236 _choice4 = self._pos1237 try:1238 _result = self.__chars__('+')1239 _result = ( set(['+']) )1240 break1241 except BacktrackException, _exc:1242 _error = self._combine_errors(_error, _exc.error)1243 self._pos = _choice41244 _choice5 = self._pos1245 try:1246 _result = self.__chars__('?')1247 _result = ( set(['?']) )1248 break1249 except BacktrackException, _exc:1250 _error = self._combine_errors(_error, _exc.error)1251 self._pos = _choice51252 _choice6 = self._pos1253 try:1254 _result = self.__chars__('-')1255 _result = ( set(['-']) )1256 break1257 except BacktrackException, _exc:1258 _error = self._combine_errors(_error, _exc.error)1259 self._pos = _choice61260 _choice7 = self._pos1261 try:1262 _result = self.__chars__('[')1263 _result = ( set(['[']) )1264 break1265 except BacktrackException, _exc:1266 _error = self._combine_errors(_error, _exc.error)1267 self._pos = _choice71268 _choice8 = self._pos1269 try:1270 _call_status = self._char()1271 _result = _call_status.result1272 _error = self._combine_errors(_error, _call_status.error)1273 c = _result1274 _result = ( set([c]) )1275 break1276 except BacktrackException, _exc:1277 _error = self._combine_errors(_error, _exc.error)1278 self._pos = _choice81279 raise BacktrackException(_error)1280 _call_status = self._char()1281 _result = _call_status.result1282 _error = self._combine_errors(_error, _call_status.error)1283 c = _result1284 _result = ( set([c]) )1285 break1286 if _status.status == _status.LEFTRECURSION:1287 if _status.result is not None:1288 if _status.pos >= self._pos:1289 _status.status = _status.NORMAL1290 self._pos = _status.pos1291 return _status1292 _status.pos = self._pos1293 _status.status = _status.SOMESOLUTIONS1294 _status.result = _result1295 _status.error = _error1296 self._pos = _startingpos1297 return self._rangeelement()1298 _status.status = _status.NORMAL1299 _status.pos = self._pos1300 _status.result = _result1301 _status.error = _error1302 return _status1303 except BacktrackException, _exc:1304 _status.pos = -11305 _status.result = None1306 _error = self._combine_errors(_error, _exc.error)1307 _status.error = _error1308 _status.status = _status.ERROR1309 raise BacktrackException(_error)1310 def numrange(self):1311 return self._numrange().result1312 def _numrange(self):1313 _key = self._pos1314 _status = self._dict_numrange.get(_key, None)1315 if _status is None:1316 _status = self._dict_numrange[_key] = Status()1317 else:1318 _statusstatus = _status.status1319 if _statusstatus == _status.NORMAL:1320 self._pos = _status.pos1321 return _status1322 elif _statusstatus == _status.ERROR:1323 raise BacktrackException(_status.error)1324 elif (_statusstatus == _status.INPROGRESS or1325 _statusstatus == _status.LEFTRECURSION):1326 _status.status = _status.LEFTRECURSION1327 if _status.result is not None:1328 self._pos = _status.pos1329 return _status1330 else:1331 raise BacktrackException(None)1332 elif _statusstatus == _status.SOMESOLUTIONS:1333 _status.status = _status.INPROGRESS1334 _startingpos = self._pos1335 try:1336 _result = None1337 _error = None1338 while 1:1339 _choice0 = self._pos1340 try:1341 _call_status = self._NUM()1342 _result = _call_status.result1343 _error = _call_status.error1344 n1 = _result1345 _result = self.__chars__(',')1346 _call_status = self._NUM()1347 _result = _call_status.result1348 _error = self._combine_errors(_error, _call_status.error)1349 n2 = _result1350 _result = (n1, n2)1351 break1352 except BacktrackException, _exc:1353 _error = self._combine_errors(_error, _exc.error)1354 self._pos = _choice01355 _choice1 = self._pos1356 try:1357 _call_status = self._NUM()1358 _result = _call_status.result1359 _error = self._combine_errors(_error, _call_status.error)1360 n1 = _result1361 _result = (n1, n1)1362 break1363 except BacktrackException, _exc:1364 _error = self._combine_errors(_error, _exc.error)1365 self._pos = _choice11366 raise BacktrackException(_error)1367 _call_status = self._NUM()1368 _result = _call_status.result1369 _error = self._combine_errors(_error, _call_status.error)1370 n1 = _result1371 _result = (n1, n1)1372 break1373 if _status.status == _status.LEFTRECURSION:1374 if _status.result is not None:1375 if _status.pos >= self._pos:1376 _status.status = _status.NORMAL1377 self._pos = _status.pos1378 return _status1379 _status.pos = self._pos1380 _status.status = _status.SOMESOLUTIONS1381 _status.result = _result1382 _status.error = _error1383 self._pos = _startingpos1384 return self._numrange()1385 _status.status = _status.NORMAL1386 _status.pos = self._pos1387 _status.result = _result1388 _status.error = _error1389 return _status1390 except BacktrackException, _exc:1391 _status.pos = -11392 _status.result = None1393 _error = self._combine_errors(_error, _exc.error)1394 _status.error = _error1395 _status.status = _status.ERROR1396 raise BacktrackException(_error)1397 def clippednumrange(self):1398 return self._clippednumrange().result1399 def _clippednumrange(self):1400 _key = self._pos1401 _status = self._dict_clippednumrange.get(_key, None)1402 if _status is None:1403 _status = self._dict_clippednumrange[_key] = Status()1404 else:1405 _statusstatus = _status.status1406 if _statusstatus == _status.NORMAL:1407 self._pos = _status.pos1408 return _status1409 elif _statusstatus == _status.ERROR:1410 raise BacktrackException(_status.error)1411 elif (_statusstatus == _status.INPROGRESS or1412 _statusstatus == _status.LEFTRECURSION):1413 _status.status = _status.LEFTRECURSION1414 if _status.result is not None:1415 self._pos = _status.pos1416 return _status1417 else:1418 raise BacktrackException(None)1419 elif _statusstatus == _status.SOMESOLUTIONS:1420 _status.status = _status.INPROGRESS1421 _startingpos = self._pos1422 try:1423 _result = None1424 _error = None1425 _call_status = self._NUM()1426 _result = _call_status.result1427 _error = _call_status.error1428 n1 = _result1429 _result = self.__chars__(',')1430 _result = (n1)1431 if _status.status == _status.LEFTRECURSION:1432 if _status.result is not None:1433 if _status.pos >= self._pos:1434 _status.status = _status.NORMAL1435 self._pos = _status.pos1436 return _status1437 _status.pos = self._pos1438 _status.status = _status.SOMESOLUTIONS1439 _status.result = _result1440 _status.error = _error1441 self._pos = _startingpos1442 return self._clippednumrange()1443 _status.status = _status.NORMAL1444 _status.pos = self._pos1445 _status.result = _result1446 _status.error = _error1447 return _status1448 except BacktrackException, _exc:1449 _status.pos = -11450 _status.result = None1451 _error = self._combine_errors(_error, _exc.error)1452 _status.error = _error1453 _status.status = _status.ERROR1454 raise BacktrackException(_error)1455 def charclass(self):1456 return self._charclass().result1457 def _charclass(self):1458 _key = self._pos1459 _status = self._dict_charclass.get(_key, None)1460 if _status is None:1461 _status = self._dict_charclass[_key] = Status()1462 else:1463 _statusstatus = _status.status1464 if _statusstatus == _status.NORMAL:1465 self._pos = _status.pos1466 return _status1467 elif _statusstatus == _status.ERROR:1468 raise BacktrackException(_status.error)1469 _startingpos = self._pos1470 try:1471 _result = None1472 _error = None1473 while 1:1474 _choice0 = self._pos1475 try:1476 _result = self.__chars__('\\')1477 _result = self.__chars__('d')1478 _result = ( set([chr(c) for c in range(ord('0'), ord('9')+1)]) )1479 break1480 except BacktrackException, _exc:1481 _error = _exc.error1482 self._pos = _choice01483 _choice1 = self._pos1484 try:1485 _result = self.__chars__('\\')1486 _result = self.__chars__('s')1487 _result = ( set(['\t', '\n', '\f', '\r', ' ']) )1488 break1489 except BacktrackException, _exc:1490 _error = self._combine_errors(_error, _exc.error)1491 self._pos = _choice11492 _choice2 = self._pos1493 try:1494 _result = self.__chars__('\\')1495 _result = self.__chars__('w')1496 _result = ( set([chr(c) for c in range(ord('a'), ord('z')+1)] + [chr(c) for c in range(ord('A'), ord('Z')+1)] + [chr(c) for c in range(ord('0'), ord('9')+1)] + ['_']) )1497 break1498 except BacktrackException, _exc:1499 _error = self._combine_errors(_error, _exc.error)1500 self._pos = _choice21501 _choice3 = self._pos1502 try:1503 _result = self.__chars__('\\')1504 _result = self.__chars__('D')1505 _result = ( set([chr(c) for c in range(256)]) - set([chr(c) for c in range(ord('0'), ord('9')+1)]) )1506 break1507 except BacktrackException, _exc:1508 _error = self._combine_errors(_error, _exc.error)1509 self._pos = _choice31510 _choice4 = self._pos1511 try:1512 _result = self.__chars__('\\')1513 _result = self.__chars__('S')1514 _result = ( set([chr(c) for c in range(256)]) - set(['\t', '\n', '\f', '\r', ' ']) )1515 break1516 except BacktrackException, _exc:1517 _error = self._combine_errors(_error, _exc.error)1518 self._pos = _choice41519 _choice5 = self._pos1520 try:1521 _result = self.__chars__('\\')1522 _result = self.__chars__('W')1523 _result = ( set([chr(c) for c in range(256)]) - set([chr(c) for c in range(ord('a'), ord('z')+1)] + [chr(c) for c in range(ord('A'), ord('Z')+1)] + [chr(c) for c in range(ord('0'), ord('9')+1)] + ['_']))1524 break1525 except BacktrackException, _exc:1526 _error = self._combine_errors(_error, _exc.error)1527 self._pos = _choice51528 raise BacktrackException(_error)1529 _result = self.__chars__('\\')1530 _result = self.__chars__('W')1531 _result = ( set([chr(c) for c in range(256)]) - set([chr(c) for c in range(ord('a'), ord('z')+1)] + [chr(c) for c in range(ord('A'), ord('Z')+1)] + [chr(c) for c in range(ord('0'), ord('9')+1)] + ['_']))1532 break1533 assert _status.status != _status.LEFTRECURSION1534 _status.status = _status.NORMAL1535 _status.pos = self._pos1536 _status.result = _result1537 _status.error = _error1538 return _status1539 except BacktrackException, _exc:1540 _status.pos = -11541 _status.result = None1542 _error = self._combine_errors(_error, _exc.error)1543 _status.error = _error1544 _status.status = _status.ERROR1545 raise BacktrackException(_error)1546 def NUM(self):1547 return self._NUM().result1548 def _NUM(self):1549 _key = self._pos1550 _status = self._dict_NUM.get(_key, None)1551 if _status is None:1552 _status = self._dict_NUM[_key] = Status()1553 else:1554 _statusstatus = _status.status1555 if _statusstatus == _status.NORMAL:1556 self._pos = _status.pos1557 return _status1558 elif _statusstatus == _status.ERROR:1559 raise BacktrackException(_status.error)1560 _startingpos = self._pos1561 try:1562 _result = None1563 _error = None1564 _result = self._regex1166214427()1565 c = _result1566 _result = (int(c))1567 assert _status.status != _status.LEFTRECURSION1568 _status.status = _status.NORMAL1569 _status.pos = self._pos1570 _status.result = _result1571 _status.error = _error1572 return _status1573 except BacktrackException, _exc:1574 _status.pos = -11575 _status.result = None1576 _error = _exc.error1577 _status.error = _error1578 _status.status = _status.ERROR1579 raise BacktrackException(_error)1580 def __init__(self, inputstream):1581 self._dict_EOF = {}1582 self._dict_parse = {}1583 self._dict_regex = {}1584 self._dict_concatenation = {}1585 self._dict_repetition = {}1586 self._dict_primary = {}1587 self._dict_char = {}1588 self._dict_QUOTEDCHAR = {}1589 self._dict_CHAR = {}1590 self._dict_range = {}1591 self._dict_rangeinner = {}1592 self._dict_subrange = {}1593 self._dict_rangeelement = {}1594 self._dict_numrange = {}1595 self._dict_clippednumrange = {}1596 self._dict_charclass = {}1597 self._dict_NUM = {}1598 self._pos = 01599 self._inputstream = inputstream1600 def _regex2132196932(self):1601 _choice0 = self._pos1602 _runner = self._Runner(self._inputstream, self._pos)1603 _i = _runner.recognize_2132196932(self._pos)1604 if _runner.last_matched_state == -1:1605 self._pos = _choice01606 raise BacktrackException1607 _upto = _runner.last_matched_index + 11608 _pos = self._pos1609 assert _pos >= 01610 assert _upto >= 01611 _result = self._inputstream[_pos: _upto]1612 self._pos = _upto1613 return _result1614 def _regex1166214427(self):1615 _choice1 = self._pos1616 _runner = self._Runner(self._inputstream, self._pos)1617 _i = _runner.recognize_1166214427(self._pos)1618 if _runner.last_matched_state == -1:1619 self._pos = _choice11620 raise BacktrackException1621 _upto = _runner.last_matched_index + 11622 _pos = self._pos1623 assert _pos >= 01624 assert _upto >= 01625 _result = self._inputstream[_pos: _upto]1626 self._pos = _upto1627 return _result1628 def _regex1423754537(self):1629 _choice2 = self._pos1630 _runner = self._Runner(self._inputstream, self._pos)1631 _i = _runner.recognize_1423754537(self._pos)1632 if _runner.last_matched_state == -1:1633 self._pos = _choice21634 raise BacktrackException1635 _upto = _runner.last_matched_index + 11636 _pos = self._pos1637 assert _pos >= 01638 assert _upto >= 01639 _result = self._inputstream[_pos: _upto]1640 self._pos = _upto1641 return _result1642 class _Runner(object):1643 def __init__(self, text, pos):1644 self.text = text1645 self.pos = pos1646 self.last_matched_state = -11647 self.last_matched_index = -11648 self.state = -11649 def recognize_2132196932(runner, i):1650 #auto-generated code, don't edit1651 assert i >= 01652 input = runner.text1653 state = 01654 while 1:1655 if state == 0:1656 try:1657 char = input[i]1658 i += 11659 except IndexError:1660 runner.state = 01661 return ~i1662 if '}' <= char <= '\xff':1663 state = 11664 elif '\x00' <= char <= "'":1665 state = 11666 elif '_' <= char <= 'z':1667 state = 11668 elif '@' <= char <= 'Z':1669 state = 11670 elif '/' <= char <= '>':1671 state = 11672 elif char == ',':1673 state = 11674 else:1675 break1676 runner.last_matched_state = state1677 runner.last_matched_index = i - 11678 runner.state = state1679 if i == len(input):1680 return i1681 else:1682 return ~i1683 break1684 runner.state = state1685 return ~i1686 def recognize_1166214427(runner, i):1687 #auto-generated code, don't edit1688 assert i >= 01689 input = runner.text1690 state = 01691 while 1:1692 if state == 0:1693 try:1694 char = input[i]1695 i += 11696 except IndexError:1697 runner.state = 01698 return ~i1699 if char == '0':1700 state = 11701 elif '1' <= char <= '9':1702 state = 21703 else:1704 break1705 if state == 2:1706 runner.last_matched_index = i - 11707 runner.last_matched_state = state1708 try:1709 char = input[i]1710 i += 11711 except IndexError:1712 runner.state = 21713 return i1714 if '0' <= char <= '9':1715 state = 21716 continue1717 else:1718 break1719 runner.last_matched_state = state1720 runner.last_matched_index = i - 11721 runner.state = state1722 if i == len(input):1723 return i1724 else:1725 return ~i1726 break1727 runner.state = state1728 return ~i1729 def recognize_1423754537(runner, i):1730 #auto-generated code, don't edit1731 assert i >= 01732 input = runner.text1733 state = 01734 while 1:1735 if state == 0:1736 try:1737 char = input[i]1738 i += 11739 except IndexError:1740 runner.state = 01741 return ~i1742 if char == '\\':1743 state = 51744 else:1745 break1746 if state == 1:1747 runner.last_matched_index = i - 11748 runner.last_matched_state = state1749 try:1750 char = input[i]1751 i += 11752 except IndexError:1753 runner.state = 11754 return i1755 if '0' <= char <= '9':1756 state = 61757 elif 'A' <= char <= 'F':1758 state = 61759 elif 'a' <= char <= 'f':1760 state = 61761 else:1762 break1763 if state == 2:1764 runner.last_matched_index = i - 11765 runner.last_matched_state = state1766 try:1767 char = input[i]1768 i += 11769 except IndexError:1770 runner.state = 21771 return i1772 if '0' <= char <= '7':1773 state = 41774 else:1775 break1776 if state == 3:1777 runner.last_matched_index = i - 11778 runner.last_matched_state = state1779 try:1780 char = input[i]1781 i += 11782 except IndexError:1783 runner.state = 31784 return i1785 if '0' <= char <= '7':1786 state = 21787 continue1788 else:1789 break1790 if state == 5:1791 try:1792 char = input[i]1793 i += 11794 except IndexError:1795 runner.state = 51796 return ~i1797 if char == 'x':1798 state = 11799 continue1800 elif '4' <= char <= '7':1801 state = 21802 continue1803 elif '0' <= char <= '3':1804 state = 31805 continue1806 elif 'y' <= char <= '\xff':1807 state = 41808 elif '\x00' <= char <= '/':1809 state = 41810 elif 'E' <= char <= 'R':1811 state = 41812 elif 'e' <= char <= 'r':1813 state = 41814 elif '8' <= char <= 'C':1815 state = 41816 elif 'X' <= char <= 'b':1817 state = 41818 elif 'T' <= char <= 'V':1819 state = 41820 elif 't' <= char <= 'v':1821 state = 41822 elif char == 'c':1823 state = 71824 else:1825 break1826 if state == 6:1827 try:1828 char = input[i]1829 i += 11830 except IndexError:1831 runner.state = 61832 return ~i1833 if '0' <= char <= '9':1834 state = 41835 elif 'A' <= char <= 'F':1836 state = 41837 elif 'a' <= char <= 'f':1838 state = 41839 else:1840 break1841 if state == 7:1842 runner.last_matched_index = i - 11843 runner.last_matched_state = state1844 try:1845 char = input[i]1846 i += 11847 except IndexError:1848 runner.state = 71849 return i1850 if '\x00' <= char <= '\xff':1851 state = 41852 else:1853 break1854 runner.last_matched_state = state1855 runner.last_matched_index = i - 11856 runner.state = state1857 if i == len(input):1858 return i1859 else:1860 return ~i1861 break1862 runner.state = state1863 return ~i1864class RegexParser(PackratParser):1865 def __init__(self, stream):1866 self.init_parser(stream)1867forbidden = dict.fromkeys(("__weakref__ __doc__ "1868 "__dict__ __module__").split())1869initthere = "__init__" in RegexParser.__dict__1870for key, value in Parser.__dict__.iteritems():1871 if key not in RegexParser.__dict__ and key not in forbidden:1872 setattr(RegexParser, key, value)1873RegexParser.init_parser = Parser.__init__.im_func1874# generated code between this line and its other occurence1875def test_generate():1876 f = py.path.local(__file__)1877 oldcontent = f.read()1878 s = "# GENERATED CODE BETWEEN THIS LINE AND ITS OTHER OCCURENCE\n".lower()1879 pre, gen, after = oldcontent.split(s)1880 from pypackrat import PyPackratSyntaxParser1881 from makepackrat import TreeOptimizer, ParserBuilder1882 p = PyPackratSyntaxParser(syntax)1883 t = p.file()1884 t = t.visit(TreeOptimizer())1885 visitor = ParserBuilder()1886 t.visit(visitor)1887 code = visitor.get_code()1888 content = """\1889%s\1890%s1891from rpython.rlib.parsing.pypackrat import PackratParser, Status1892from rpython.rlib.parsing.pypackrat import BacktrackException1893from rpython.rlib.parsing import regex1894import operator1895%s1896class RegexParser(PackratParser):1897 def __init__(self, stream):1898 self.init_parser(stream)1899forbidden = dict.fromkeys(("__weakref__ __doc__ "1900 "__dict__ __module__").split())1901initthere = "__init__" in RegexParser.__dict__1902for key, value in Parser.__dict__.iteritems():1903 if key not in RegexParser.__dict__ and key not in forbidden:1904 setattr(RegexParser, key, value)1905RegexParser.init_parser = Parser.__init__.im_func1906%s1907%s\1908""" % (pre, s, code, s, after)1909 print content...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!