Best Python code snippet using assertpy_python
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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _exc:1393                            _error = self._combine_errors(_error, _exc.error)1394                            self._pos = _choice111395                            break1396                    _result = _all101397                    _result = (Nonterminal('if', [condition]))1398                    break1399                except BacktrackException as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _exc:1796                            _error = self._combine_errors(_error, _exc.error)1797                            self._pos = _choice41798                            break1799                    _result = _all31800                    _result = (Nonterminal('maybe', [what]))1801                    break1802                except BacktrackException as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _exc:1995                            _error = self._combine_errors(_error, _exc.error)1996                            self._pos = _choice41997                            break1998                    _result = _all31999                    _result = (Nonterminal('negation', [what]))2000                    break2001                except BacktrackException as _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 as _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 as _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 as _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 as _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 as _exc:2114                            _error = self._combine_errors(_error, _exc.error)2115                            self._pos = _choice62116                            break2117                    _result = _all52118                    _result = (Nonterminal('exclusive', [what]))2119                    break2120                except BacktrackException as _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 as _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 as _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 as _exc:2166                            _error = self._combine_errors(_error, _exc.error)2167                            self._pos = _choice132168                            break2169                    _result = _all122170                    _result = (Nonterminal('ignore', [what]))2171                    break2172                except BacktrackException as _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 as _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 as _exc:2207                            _error = self._combine_errors(_error, _exc.error)2208                            self._pos = _choice202209                            break2210                    _result = _all192211                    _result = _before_discard182212                    break2213                except BacktrackException as _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 as _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 as _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 as _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 as _exc:2307                            _error = self._combine_errors(_error, _exc.error)2308                            self._pos = _choice42309                            break2310                    _result = _all32311                    _result = _before_discard22312                    break2313                except BacktrackException as _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 as _exc:2331                            _error = self._combine_errors(_error, _exc.error)2332                            self._pos = _choice82333                            break2334                    _result = _all72335                    _result = _before_discard62336                    break2337                except BacktrackException as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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 as _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)...assertions.py
Source:assertions.py  
...1084            if not hasattr(l, '__getitem__'):1085                raise TypeError('%s <%s> does not have [] accessor' % (name, type(l).__name__))1086    def _dict_not_equal(self, val, other, ignore=None, include=None):1087        if ignore or include:1088            ignores = self._dict_ignore(ignore)1089            includes = self._dict_include(include)1090            # guarantee include keys are in val1091            if include:1092                missing = []1093                for i in includes:1094                    if i not in val:1095                        missing.append(i)1096                if missing:1097                    self._err('Expected <%s> to include key%s %s, but did not include key%s %s.' % (1098                        val,1099                        '' if len(includes) == 1 else 's',1100                        self._fmt_items(['.'.join([str(s) for s in i]) if type(i) is tuple else i for i in includes]),1101                        '' if len(missing) == 1 else 's',1102                        self._fmt_items(missing)))1103            if ignore and include:1104                k1 = set([k for k in val if k not in ignores and k in includes])1105            elif ignore:1106                k1 = set([k for k in val if k not in ignores])1107            else:  # include1108                k1 = set([k for k in val if k in includes])1109            if ignore and include:1110                k2 = set([k for k in other if k not in ignores and k in includes])1111            elif ignore:1112                k2 = set([k for k in other if k not in ignores])1113            else:  # include1114                k2 = set([k for k in other if k in includes])1115            if k1 != k2:1116                return True1117            else:1118                for k in k1:1119                    if self._check_dict_like(val[k], check_values=False, return_as_bool=True) and self._check_dict_like(1120                            other[k], check_values=False, return_as_bool=True):1121                        return self._dict_not_equal(val[k], other[k],1122                                                    ignore=[i[1:] for i in ignores if1123                                                            type(i) is tuple and i[0] == k] if ignore else None,1124                                                    include=[i[1:] for i in self._dict_ignore(include) if1125                                                             type(i) is tuple and i[0] == k] if include else None)1126                    elif val[k] != other[k]:1127                        return True1128            return False1129        else:1130            return val != other1131    def _dict_ignore(self, ignore):1132        return [i[0] if type(i) is tuple and len(i) == 1 else i \1133                for i in (ignore if type(ignore) is list else [ignore])]1134    def _dict_include(self, include):1135        return [i[0] if type(i) is tuple else i \1136                for i in (include if type(include) is list else [include])]1137    def _dict_err(self, val, other, ignore=None, include=None):1138        def _dict_repr(d, other):1139            out = ''1140            ellip = False1141            for k, v in d.items():1142                if k not in other:1143                    out += '%s%s: %s' % (', ' if len(out) > 0 else '', repr(k), repr(v))1144                elif v != other[k]:1145                    out += '%s%s: %s' % (', ' if len(out) > 0 else '', repr(k),1146                                         _dict_repr(v, other[k]) if self._check_dict_like(v, check_values=False,1147                                                                                          return_as_bool=True) and self._check_dict_like(1148                                             other[k], check_values=False, return_as_bool=True) else repr(v)1149                                         )1150                else:1151                    ellip = True1152            return '{%s%s}' % ('..' if ellip and len(out) == 0 else '.., ' if ellip else '', out)1153        if ignore:1154            ignores = self._dict_ignore(ignore)1155            ignore_err = ' ignoring keys %s' % self._fmt_items(1156                ['.'.join([str(s) for s in i]) if type(i) is tuple else i for i in ignores])1157        if include:1158            includes = self._dict_ignore(include)1159            include_err = ' including keys %s' % self._fmt_items(1160                ['.'.join([str(s) for s in i]) if type(i) is tuple else i for i in includes])1161        self._err('Expected <%s> to be equal to <%s>%s%s, but was not.' % (1162            _dict_repr(val, other),1163            _dict_repr(other, val),1164            ignore_err if ignore else '',1165            include_err if include else ''1166        ))1167    ### snapshot testing ###1168    def snapshot(self, id=None, path='__snapshots'):1169        if sys.version_info[0] < 3:1170            raise NotImplementedError('snapshot testing requires Python 3')1171        class _Encoder(json.JSONEncoder):1172            def default(self, o):...helpers.py
Source:helpers.py  
...133                raise TypeError('%s <%s> does not have [] accessor' % (name, type(l).__name__))134    def _dict_not_equal(self, val, other, ignore=None, include=None):135        """Helper to compare dicts."""136        if ignore or include:137            ignores = self._dict_ignore(ignore)138            includes = self._dict_include(include)139            # guarantee include keys are in val140            if include:141                missing = []142                for i in includes:143                    if i not in val:144                        missing.append(i)145                if missing:146                    return self.error('Expected <%s> to include key%s %s, but did not include key%s %s.' % (147                        val,148                        '' if len(includes) == 1 else 's',149                        self._fmt_items(['.'.join([str(s) for s in i]) if type(i) is tuple else i for i in includes]),150                        '' if len(missing) == 1 else 's',151                        self._fmt_items(missing)))152            # calc val keys given ignores and includes153            if ignore and include:154                k1 = set([k for k in val if k not in ignores and k in includes])155            elif ignore:156                k1 = set([k for k in val if k not in ignores])157            else:  # include158                k1 = set([k for k in val if k in includes])159            # calc other keys given ignores and includes160            if ignore and include:161                k2 = set([k for k in other if k not in ignores and k in includes])162            elif ignore:163                k2 = set([k for k in other if k not in ignores])164            else:  # include165                k2 = set([k for k in other if k in includes])166            if k1 != k2:167                # different set of keys, so not equal168                return True169            else:170                for k in k1:171                    if self._check_dict_like(val[k], check_values=False, return_as_bool=True) and \172                            self._check_dict_like(other[k], check_values=False, return_as_bool=True):173                        subdicts_not_equal = self._dict_not_equal(174                            val[k],175                            other[k],176                            ignore=[i[1:] for i in ignores if type(i) is tuple and i[0] == k] if ignore else None,177                            include=[i[1:] for i in self._dict_ignore(include) if type(i) is tuple and i[0] == k] if include else None)178                        if subdicts_not_equal:179                            # fast fail inside the loop since sub-dicts are not equal180                            return True181                    elif val[k] != other[k]:182                        # fast fail inside the loop since values are not equal183                        return True184            return False185        else:186            return val != other187    def _dict_ignore(self, ignore):188        """Helper to make list for given ignore kwarg values."""189        return [i[0] if type(i) is tuple and len(i) == 1 else i for i in (ignore if type(ignore) is list else [ignore])]190    def _dict_include(self, include):191        """Helper to make a list from given include kwarg values."""192        return [i[0] if type(i) is tuple else i for i in (include if type(include) is list else [include])]193    def _dict_err(self, val, other, ignore=None, include=None):194        """Helper to construct error message for dict comparison."""195        def _dict_repr(d, other):196            out = ''197            ellip = False198            for k, v in sorted(d.items()):199                if k not in other:200                    out += '%s%s: %s' % (', ' if len(out) > 0 else '', repr(k), repr(v))201                elif v != other[k]:202                    out += '%s%s: %s' % (203                        ', ' if len(out) > 0 else '',204                        repr(k),205                        _dict_repr(v, other[k]) if self._check_dict_like(206                            v, check_values=False, return_as_bool=True) and self._check_dict_like(207                                other[k], check_values=False, return_as_bool=True) else repr(v)208                    )209                else:210                    ellip = True211            return '{%s%s}' % ('..' if ellip and len(out) == 0 else '.., ' if ellip else '', out)212        if ignore:213            ignores = self._dict_ignore(ignore)214            ignore_err = ' ignoring keys %s' % self._fmt_items(['.'.join([str(s) for s in i]) if type(i) is tuple else i for i in ignores])215        if include:216            includes = self._dict_ignore(include)217            include_err = ' including keys %s' % self._fmt_items(['.'.join([str(s) for s in i]) if type(i) is tuple else i for i in includes])218        return self.error('Expected <%s> to be equal to <%s>%s%s, but was not.' % (219            _dict_repr(val, other),220            _dict_repr(other, val),221            ignore_err if ignore else '',222            include_err if include else ''...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!!
