How to use _result method in rester

Best Python code snippet using rester_python

pypackrat.py

Source:pypackrat.py Github

copy

Full Screen

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)...

Full Screen

Full Screen

test_lab_value_matcher.py

Source:test_lab_value_matcher.py Github

copy

Full Screen

1#!/usr/bin/python32"""3 Test program for the 'lab_value_matcher' module.4"""5import re6import os7import sys8import json9import argparse10from collections import namedtuple11if __name__ == '__main__':12 # interactive testing; add nlp dir to path to find logging class13 match = re.search(r'nlp/', sys.path[0])14 if match:15 nlp_dir = sys.path[0][:match.end()]16 sys.path.append(nlp_dir)17 else:18 print('\n*** test_lab_value_matcher.py: nlp dir not found ***\n')19 sys.exit(0)20#from claritynlp_logging import log, ERROR, DEBUG21try:22 import lab_value_matcher as lvm23except:24 from algorithms.finder import lab_value_matcher as lvm25 26_VERSION_MAJOR = 027_VERSION_MINOR = 528_MODULE_NAME = 'test_lab_value_matcher.py'29_RESULT_FIELDS = ['match_text']30_Result = namedtuple('_Result', _RESULT_FIELDS)31_Result.__new__.__defaults__ = (None,) * len(_Result._fields)32###############################################################################33def _compare_results(34 computed_values,35 expected_values,36 sentence,37 field_list):38 # check that len(computed) == len(expected)39 if len(computed_values) != len(expected_values):40 print('\tMismatch in computed vs. expected results: ')41 print('\tSentence: {0}'.format(sentence))42 print('\tComputed: ')43 for v in computed_values:44 print('\t\t{0}'.format(v))45 print('\tExpected: ')46 for v in expected_values:47 print('\t\t{0}'.format(v))48 print('NAMEDTUPLE: ')49 for k,v in v._asdict().items():50 print('\t{0} => {1}'.format(k,v))51 return False52 # check fields for each result53 failures = []54 for i, t in enumerate(computed_values):55 # iterate over fields of current result56 for field, value in t._asdict().items():57 # remove trailing whitespace, if any, from computed value58 if str == type(value):59 value = value.strip()60 expected = expected_values[i]._asdict()61 # compare only those fields in _RESULT_FIELDS62 if field in field_list:63 if value != expected[field]:64 # append as namedtuples65 failures.append( (t, expected_values[i]) )66 if len(failures) > 0:67 print(sentence)68 for f in failures:69 # extract fields with values not equal to None70 c = [ (k,v) for k,v in f[0]._asdict().items()71 if v is not None and k in field_list]72 e = [ (k,v) for k,v in f[1]._asdict().items() if v is not None]73 print('\tComputed: {0}'.format(c))74 print('\tExpected: {0}'.format(e))75 76 return False77 return True78 79###############################################################################80def _run_tests(test_data):81 for sentence, expected_values in test_data.items():82 # computed values are finder_overlap.Candidate namedtuples83 # relevant field is 'match_text'84 computed_values = lvm.run(sentence)85 86 ok = _compare_results(87 computed_values,88 expected_values,89 sentence,90 _RESULT_FIELDS)91 if not ok:92 return False93 94 return True95###############################################################################96def run():97 lvm.init()98 99 test_data = {100 'Vitals were SBP 116, HR 75 R=18 L. 80 in.':[101 _Result(match_text='SBP 116'),102 _Result(match_text='HR 75'),103 _Result(match_text='R=18'),104 _Result(match_text='L. 80 in.')105 ],106 'Vitals were HR=120, BP=109/44, RR=29, POx=93% on 8L FM':[107 _Result(match_text='HR=120'),108 _Result(match_text='BP=109/44'),109 _Result(match_text='RR=29'),110 _Result(match_text='POx=93% on 8L FM')111 ],112 'Vitals: T: 96.0 BP: 90/54 P: 88 R: 16 18 O2:88/NRB':[113 _Result(match_text='T: 96.0'),114 _Result(match_text='BP: 90/54'),115 _Result(match_text='P: 88'),116 _Result(match_text='R: 16 18'),117 _Result(match_text='O2:88/NRB')118 ],119 'Vitals: T 98.9 F BP 138/56 P 89 RR 28 SaO2 100% on NRB':[120 _Result(match_text='T 98.9 F'),121 _Result(match_text='BP 138/56'),122 _Result(match_text='P 89'),123 _Result(match_text='RR 28'),124 _Result(match_text='SaO2 100% on NRB')125 ],126 'Vitals were T 98 BP 163/64 HR 73 O2 95% on 55% venti mask':[127 _Result(match_text='T 98'),128 _Result(match_text='BP 163/64'),129 _Result(match_text='HR 73'),130 _Result(match_text='O2 95% on 55% venti mask')131 ],132 'VS: T 95.6 HR 45 BP 75/30 RR 17 98% RA.':[133 _Result(match_text='T 95.6'),134 _Result(match_text='HR 45'),135 _Result(match_text='BP 75/30'),136 _Result(match_text='RR 17'),137 _Result(match_text='98% RA')138 ],139 'VS T97.3 P84 BP120/56 RR16 O2Sat98 2LNC':[140 _Result(match_text='T97.3'),141 _Result(match_text='P84'),142 _Result(match_text='BP120/56'),143 _Result(match_text='RR16'),144 _Result(match_text='O2Sat98 2LNC')145 ],146 'Ht: (in) 74 Wt. (lb): 199 BSA (m2): 2.17 m2 ' +\147 'BP (mm Hg): 140/91 HR (bpm): 53':[148 _Result(match_text='Ht: (in) 74'),149 _Result(match_text='Wt. (lb): 199'),150 _Result(match_text='BSA (m2): 2.17 m2'),151 _Result(match_text='BP (mm Hg): 140/91'),152 _Result(match_text='HR (bpm): 53')153 ],154 'Vitals: T: 99 BP: 115/68 P: 79 R:21 O2: 97':[155 _Result(match_text='T: 99'),156 _Result(match_text='BP: 115/68'),157 _Result(match_text='P: 79'),158 _Result(match_text='R:21'),159 _Result(match_text='O2: 97')160 ],161 'Vitals - T 95.5 BP 132/65 HR 78 RR 20 SpO2 98%/3L':[162 _Result(match_text='T 95.5'),163 _Result(match_text='BP 132/65'),164 _Result(match_text='HR 78'),165 _Result(match_text='RR 20'),166 _Result(match_text='SpO2 98%/3L')167 ],168 'VS: T=98 BP= 122/58 HR= 7 RR= 20 O2 sat= 100% 2L NC':[169 _Result(match_text='T=98'),170 _Result(match_text='BP= 122/58'),171 _Result(match_text='HR= 7'),172 _Result(match_text='RR= 20'),173 _Result(match_text='O2 sat= 100% 2L NC')174 ],175 'Vitals: T: 97.7 P:100 R:16 BP:126/95 SaO2:100 Ra':[176 _Result(match_text='T: 97.7'),177 _Result(match_text='P:100'),178 _Result(match_text='R:16'),179 _Result(match_text='BP:126/95'),180 _Result(match_text='SaO2:100 Ra')181 ],182 'VS: T-100.6, HR-105, BP-93/46, RR-16, Sats-98% 3L/NC':[183 _Result(match_text='T-100.6'),184 _Result(match_text='HR-105'),185 _Result(match_text='BP-93/46'),186 _Result(match_text='RR-16'),187 _Result(match_text='Sats-98% 3L/NC')188 ],189 'VS - Temp. 98.5F, BP115/65 , HR103 , R16 , 96O2-sat % RA':[190 _Result(match_text='Temp. 98.5F'),191 _Result(match_text='BP115/65'),192 _Result(match_text='HR103'),193 _Result(match_text='R16'),194 _Result(match_text='96O2-sat % RA')195 ],196 'Vitals: Temp 100.2 HR 72 BP 184/56 RR 16 sats 96% on RA':[197 _Result(match_text='Temp 100.2'),198 _Result(match_text='HR 72'),199 _Result(match_text='BP 184/56'),200 _Result(match_text='RR 16'),201 _Result(match_text='sats 96% on RA')202 ],203 'PHYSICAL EXAM: O: T: 98.8 BP: 123/60 HR:97 R 16 O2Sats100%':[204 _Result(match_text='T: 98.8'),205 _Result(match_text='BP: 123/60'),206 _Result(match_text='HR:97'),207 _Result(match_text='R 16'),208 _Result(match_text='O2Sats100%')209 ],210 'VS before transfer were 85 BP 99/34 RR 20 SpO2% 99/bipap 10/5 50%.':[211 _Result(match_text='BP 99/34'),212 _Result(match_text='RR 20'),213 _Result(match_text='SpO2% 99/bipap')214 ],215 'Initial vs were: T 98 P 91 BP 122/63 R 20 O2 sat 95%RA.':[216 _Result(match_text='T 98'),217 _Result(match_text='P 91'),218 _Result(match_text='BP 122/63'),219 _Result(match_text='R 20'),220 _Result(match_text='O2 sat 95%RA')221 ],222 'Initial vitals were HR 106 BP 88/56 RR 20 O2 Sat 85% 3L.':[223 _Result(match_text='HR 106'),224 _Result(match_text='BP 88/56'),225 _Result(match_text='RR 20'),226 _Result(match_text='O2 Sat 85% 3L')227 ],228 'Initial vs were: T=99.3 P=120 BP=111/57 RR=24 POx=100%.':[229 _Result(match_text='T=99.3'),230 _Result(match_text='P=120'),231 _Result(match_text='BP=111/57'),232 _Result(match_text='RR=24'),233 _Result(match_text='POx=100%')234 ],235 'At transfer vitals were HR=120 BP=109/44 RR=29 POx=93% on 8L FM.':[236 _Result(match_text='HR=120'),237 _Result(match_text='BP=109/44'),238 _Result(match_text='RR=29'),239 _Result(match_text='POx=93% on 8L FM')240 ],241 "Vitals as follows: BP 120/80 HR 60-80's RR SaO2 96% 6L NC.":[242 _Result(match_text='BP 120/80'),243 _Result(match_text="HR 60-80's"),244 _Result(match_text='SaO2 96% 6L NC')245 ],246 'Vital signs were T 97.5 HR 62 BP 168/60 RR 18 95% RA.':[247 _Result(match_text='T 97.5'),248 _Result(match_text='HR 62'),249 _Result(match_text='BP 168/60'),250 _Result(match_text='RR 18'),251 _Result(match_text='95% RA')252 ],253 'T 99.4 P 160 R 56 BP 60/36 mean 44 O2 sat 97% Wt 3025 grams ' +\254 'Lt 18.5 inches HC 35 cm':[255 _Result(match_text='T 99.4'),256 _Result(match_text='P 160'),257 _Result(match_text='R 56'),258 _Result(match_text='BP 60/36'),259 _Result(match_text='O2 sat 97%'),260 _Result(match_text='Wt 3025 grams'),261 _Result(match_text='Lt 18.5 inches'),262 _Result(match_text='HC 35 cm')263 ],264 'Vital signs were T 97.0 BP 85/44 HR 107 RR 28 and SpO2 91% on NRB.':[265 _Result(match_text='T 97.0'),266 _Result(match_text='BP 85/44'),267 _Result(match_text='HR 107'),268 _Result(match_text='RR 28'),269 _Result(match_text='SpO2 91% on NRB'),270 ],271 'Vitals were T 95.6 HR 67 BP 143/79 RR 16 and ' +\272 'O2 sat 92% on room air and 100% on 3 L/min nc':[273 _Result(match_text='T 95.6'),274 _Result(match_text='HR 67'),275 _Result(match_text='BP 143/79'),276 _Result(match_text='RR 16'),277 _Result(match_text='O2 sat 92% on room air')278 ],279 'Vitals were BP 119/53 (105/43 sleeping) HR 103 RR 15 and ' +\280 'SpO2 97% on NRB.':[281 _Result(match_text='BP 119/53 (105/43'),282 _Result(match_text='HR 103'),283 _Result(match_text='RR 15'),284 _Result(match_text='SpO2 97% on NRB'),285 ],286 'Vitals were Temp. 100.8 Pulse: 103 RR: 28 BP: 84/43 ' +\287 'O2Sat: 88 O2 Flow: 100 (Non-Rebreather).':[288 _Result(match_text='Temp. 100.8'),289 _Result(match_text='Pulse: 103'),290 _Result(match_text='RR: 28'),291 _Result(match_text='BP: 84/43'),292 _Result(match_text='O2Sat: 88'),293 _Result(match_text='O2 Flow: 100 (Non-Rebreather)')294 ],295 'Vitals were T 97.1 HR 76 BP 148/80 RR 25 SpO2 92%/RA.':[296 _Result(match_text='T 97.1'),297 _Result(match_text='HR 76'),298 _Result(match_text='BP 148/80'),299 _Result(match_text='RR 25'),300 _Result(match_text='SpO2 92%/RA'),301 ],302 'Tm 96.4, BP= 90-109/49-82, HR= paced at 70, RR= 24, ' +\303 'O2 sat= 96% on 4L':[304 _Result(match_text='Tm 96.4'),305 _Result(match_text='BP= 90-109/49-82'),306 _Result(match_text='HR= paced at 70'),307 _Result(match_text='RR= 24'),308 _Result(match_text='O2 sat= 96% on 4L'),309 ],310 'Vitals were T 97.1 BP 80/70 AR 80 RR 24 O2 sat 70% on 50% flowmask':[311 _Result(match_text='T 97.1'),312 _Result(match_text='BP 80/70'),313 _Result(match_text='RR 24'),314 _Result(match_text='O2 sat 70% on 50% flowmask'),315 ],316 'Vitals: T: 98.9 degrees Farenheit BP: 120/49 mmHg supine ' +\317 'HR 84 bpm RR 13 bpm O2: 100% PS 18/10 FiO2 40%':[318 _Result(match_text='T: 98.9 degrees Farenheit'),319 _Result(match_text='BP: 120/49 mmHg'),320 _Result(match_text='HR 84 bpm'),321 _Result(match_text='RR 13 bpm'),322 _Result(match_text='O2: 100%'),323 _Result(match_text='PS 18/10'),324 _Result(match_text='FiO2 40%')325 ],326 'Vitals T 99.2 (baseline ~96-97), BP 91/50, HR 63, RR 12, ' +\327 'satting 95% on trach mask':[328 _Result(match_text='T 99.2'),329 _Result(match_text='BP 91/50'),330 _Result(match_text='HR 63'),331 _Result(match_text='RR 12'),332 _Result(match_text='satting 95% on trach mask')333 ],334 'Vitals: T 99.2F BP 220/109 HR 69 SR sO2 100% on 100% O2 on vent':[335 _Result(match_text='T 99.2F'),336 _Result(match_text='BP 220/109'),337 _Result(match_text='HR 69'),338 _Result(match_text='sO2 100% on 100% O2 on vent')339 ],340 'Vital signs: Tmax: 38 C (100.4 Tcurrent: 37 C (98.6 ' +\341 'HR: 82 (78 - 103) bpm ' +\342 'BP: 121/68(76) {113/57(72) - 137/88(94)} mmHg RR: 24 ' +\343 '(19 - 29) insp/min SpO2: 92% Heart rhythm: SR ' +\344 '(Sinus Rhythm) Wgt (current): 107 kg (admission): 98 kg ' +\345 'Height: 68 Inch CVP: 16 (6 - 17)mmHg':[346 _Result(match_text='Tmax: 38 C'),347 _Result(match_text='Tcurrent: 37 C'),348 _Result(match_text='HR: 82 (78 - 103) bpm'),349 _Result(match_text='BP: 121/68(76) {113/57(72) - 137/88(94)} mmHg'),350 _Result(match_text='RR: 24 (19 - 29) insp/min'),351 _Result(match_text='SpO2: 92%'),352 _Result(match_text='Wgt (current): 107 kg (admission): 98 kg'),353 _Result(match_text='Height: 68 Inch'),354 _Result(match_text='CVP: 16 (6 - 17)mmHg')355 ],356 'Vital signs: Tcurrent: 36.8 C (98.2 HR: 75 (75 - 107) bpm ' +\357 'BP: 122/78(89) {122/78(29) - 149/86(100)} mmHg ' +\358 'RR: 21 (20 - 38) insp/min SpO2: 96% ' +\359 'Heart rhythm: ST (Sinus Tachycardia) Height: 72 Inch':[360 _Result(match_text='Tcurrent: 36.8 C'),361 _Result(match_text='HR: 75 (75 - 107) bpm'),362 _Result(match_text='BP: 122/78(89) {122/78(29) - 149/86(100)} mmHg'),363 _Result(match_text='RR: 21 (20 - 38) insp/min'),364 _Result(match_text='SpO2: 96%'),365 _Result(match_text='Height: 72 Inch'),366 ],367 'Ventilator mode: CMV/ASSIST/AutoFlow Vt (Set): 550 (550 - 550) mL ' +\368 'Vt (Spontaneous): 234 (234 - 234) mL RR (Set): 16 ' +\369 'RR (Spontaneous): 0 PEEP: 5 cmH2O FiO2: 70% RSBI: 140 ' +\370 'PIP: 25 cmH2O SpO2: 98% Ve: 14.6 L/min':[371 _Result(match_text='Vt (Set): 550 (550 - 550) mL'),372 _Result(match_text='Vt (Spontaneous): 234 (234 - 234) mL'),373 _Result(match_text='RR (Set): 16'),374 _Result(match_text='RR (Spontaneous): 0'),375 _Result(match_text='PEEP: 5 cmH2O'),376 _Result(match_text='FiO2: 70%'),377 _Result(match_text='RSBI: 140'),378 _Result(match_text='PIP: 25 cmH2O'),379 _Result(match_text='SpO2: 98%'),380 _Result(match_text='Ve: 14.6 L/min')381 ],382 'Vt (Spontaneous): 608 (565 - 793) mL PS : 15 cmH2O ' +\383 'RR (Spontaneous): 27 PEEP: 10 cmH2O FiO2: 50% ' +\384 'RSBI Deferred: PEEP > 10 PIP: 26 cmH2O SpO2: 99% ' +\385 'ABG: 7.41/39/81/21/0 Ve: 17.4 L/min PaO2 / FiO2: 164':[386 _Result(match_text='Vt (Spontaneous): 608 (565 - 793) mL'),387 _Result(match_text='PS : 15 cmH2O'),388 _Result(match_text='RR (Spontaneous): 27'),389 _Result(match_text='PEEP: 10 cmH2O'),390 _Result(match_text='FiO2: 50%'),391 _Result(match_text='PIP: 26 cmH2O'),392 _Result(match_text='SpO2: 99%'),393 _Result(match_text='ABG: 7.41/39/81/21/0'),394 _Result(match_text='Ve: 17.4 L/min'),395 _Result(match_text='PaO2 / FiO2: 164')396 ],397 'Respiratory: Vt (Set): 600 (600 - 600) mL Vt (Spontaneous): 743 ' +\398 '(464 - 816) mL PS : 5 cmH2O RR (Set): 14 RR (Spontaneous): 19' +\399 ' PEEP: 5 cmH2O FiO2: 50% RSBI: 49 PIP: 11 cmH2O ' +\400 'Plateau: 20 cmH2O SPO2: 99% ABG: 7.34/51/109/25/0 ' +\401 'Ve: 10.3 L/min PaO2 / FiO2: 218':[402 _Result(match_text='Vt (Set): 600 (600 - 600) mL'),403 _Result(match_text='Vt (Spontaneous): 743 (464 - 816) mL'),404 _Result(match_text='PS : 5 cmH2O'),405 _Result(match_text='RR (Set): 14'),406 _Result(match_text='RR (Spontaneous): 19'),407 _Result(match_text='PEEP: 5 cmH2O'),408 _Result(match_text='FiO2: 50%'),409 _Result(match_text='RSBI: 49'),410 _Result(match_text='PIP: 11 cmH2O'),411 _Result(match_text='Plateau: 20 cmH2O'),412 _Result(match_text='SPO2: 99%'),413 _Result(match_text='ABG: 7.34/51/109/25/0'),414 _Result(match_text='Ve: 10.3 L/min'),415 _Result(match_text='PaO2 / FiO2: 218') 416 ],417 # all-text regexes were removed, not a problem for Spacy sentence seg.418 419 # 'Vital signs were a temperature of 97.5, a heart rate of 70, ' +\420 # 'a blood pressure of 193/100, a respiratory rate of 20, and ' +\421 # 'an oxygen saturation of 96% on 2 liters':[422 # _Result(match_text='temperature of 97.5'),423 # _Result(match_text='heart rate of 70'),424 # _Result(match_text='blood pressure of 193/100'),425 # _Result(match_text='respiratory rate of 20'),426 # _Result(match_text='oxygen saturation of 96% on 2 liters')427 # ],428 # 'His vitals were a temperature of 98.1. Heart rate of 76. Blood ' +\429 # 'pressure 160/80 with intermittent rise to systolic blood pressure ' +\430 # 'of 230 and a respiratory rate of 14. His initial weight was ' +\431 # 'approximately 73 kg':[432 # _Result(match_text='temperature of 98.1'),433 # _Result(match_text='Heart rate of 76'),434 # _Result(match_text='Blood pressure 160/80'),435 # _Result(match_text='systolic blood pressure of 230'),436 # _Result(match_text='respiratory rate of 14'),437 # _Result(match_text='weight was approximately 73 kg')438 # ],439 # 'Physical examination on admission revealed temperature was 96.3, ' +\440 # 'heart rate was 76, blood pressure was 190/80, the respiratory ' +\441 # 'rate was 21,\nand the oxygen saturation was 80% to 92% on a 100% ' +\442 # 'nonrebreather mask':[443 # _Result(match_text='temperature was 96.3'),444 # _Result(match_text='heart rate was 76'),445 # _Result(match_text='blood pressure was 190/80'),446 # _Result(match_text='respiratory rate was 21'),447 # _Result(match_text='oxygen saturation was 80% to 92% on a ' \448 # '100% nonrebreather mask')449 # ],450 # 'Vital signs are heart rate of 107, blood pressure 104/58; ' +\451 # 'breathing at 16; temperature 100 F., orally. O2 saturation ' +\452 # '98% on room air; weight 115 pounds':[453 # _Result(match_text='heart rate of 107'),454 # _Result(match_text='blood pressure 104/58'),455 # _Result(match_text='breathing at 16'),456 # _Result(match_text='temperature 100 F'),457 # _Result(match_text='O2 saturation 98% on room air'),458 # _Result(match_text='weight 115 pounds')459 # ],460 # lists of numbers, each with units461 'Radiology 117 K/uL 12.6 g/dL 151 mg/dL 3.9 mg/dL 24 mEq/L':[462 _Result(match_text='117 K/uL 12.6 g/dL 151 mg/dL ' +\463 '3.9 mg/dL 24 mEq/L'),464 ],465 'Radiology 4.4 mEq/L 103 mg/dL 97 mEq/L 133 mEq/L 39.3 % 11.7 K/uL':[466 _Result(match_text='4.4 mEq/L 103 mg/dL 97 mEq/L ' +\467 '133 mEq/L 39.3 % 11.7 K/uL')468 ],469 # more lab values, ion concentrations470 'Albumin:4.2 g/dL, LDH: 332 IU/L, Ca++:8.0 mg/dL, Mg++:2.1 mg/dL':[471 _Result(match_text='Albumin:4.2 g/dL'),472 _Result(match_text='LDH: 332 IU/L'),473 _Result(match_text='Ca++:8.0 mg/dL'),474 _Result(match_text='Mg++:2.1 mg/dL')475 ],476 # values with embedded commas477 'Total out: 1,621 mL 2,715 mL':[478 _Result(match_text='1,621 mL 2,715 mL')479 ],480 'In: 2,405 mL 2,588 mL PO: 840 mL 100 mL TF: IVF: 1,565 mL 2,488 mL':[481 _Result(match_text='2,405 mL 2,588 mL'),482 _Result(match_text='840 mL 100 mL'),483 _Result(match_text='1,565 mL 2,488 mL')484 ],485 'Balance: -911 mL -76 mL -32 mL':[486 _Result(match_text='-911 mL -76 mL -32 mL')487 ],488 'Performed at WEST STAT LAB Phosphate 3.7 2.7 - 4.5 mg/dL PERFORMED ' \489 'AT WEST STAT LAB Lab Magnesium 1.8 1.6 - 2.6':[490 _Result(match_text='Phosphate 3.7 2.7 - 4.5 mg/dL'),491 _Result(match_text='Magnesium 1.8 1.6 - 2.6')492 ],493 'White Blood Cells 8.2 4.0 - 11.0 K/uL Red Blood Cells 3.95* 4.2 - ' +\494 '5.4 m/uL PERFORMED AT WEST STAT LAB Hemoglobin 12.1 12.0 - 16.0 ' +\495 'g/dL PERFORMED AT WEST STAT LAB Hematocrit 38.0 36 - 48 % ' +\496 'PERFORMED AT WEST STAT LAB MCV 96 82 - 98 fL PERFORMED AT WEST ' +\497 'STAT LAB MCH 30.7 27 - 32 pg':[498 _Result(match_text='Cells 8.2 4.0 - 11.0 K/uL'),499 _Result(match_text='Cells 3.95* 4.2 - 5.4 m/uL'),500 _Result(match_text='Hemoglobin 12.1 12.0 - 16.0 g/dL'),501 _Result(match_text='Hematocrit 38.0 36 - 48 %'),502 _Result(match_text='MCV 96 82 - 98 fL'),503 _Result(match_text='MCH 30.7 27 - 32 pg')504 ],505 'Cr 0.4 0.4 0.4 0.4 0.4 0.4 0.4 0.4 TCO2 43 47 Glucose ':[506 _Result(match_text='0.4 0.4 0.4 0.4 0.4 0.4 0.4 0.4')507 ],508 'CO(LVOT): 3.3 l/min SV(LVOT): 55.2 ml SV(MOD-sp4): 43.0 ml':[509 _Result(match_text='CO(LVOT): 3.3 l/min'),510 _Result(match_text='SV(LVOT): 55.2 ml'),511 _Result(match_text='SV(MOD-sp4): 43.0 ml'),512 ],513 "E/E': 20.2, E/E' lat: 27.4 E/E' med: 12.9 and ...":[514 _Result(match_text="E/E': 20.2"),515 _Result(match_text="E/E' lat: 27.4"),516 _Result(match_text="E/E' med: 12.9"),517 ],518 'Ao V2 max 266 cm/sec\r Ao max PG ' +\519 '29 mmHg\r Ao V2 mean 172 cm/sec\r ' +\520 'Ao mean PG 14 mmHg\r':[521 _Result(match_text="Ao V2 max 266 cm/sec"),522 _Result(match_text="Ao max PG 29 mmHg"),523 _Result(match_text="Ao V2 mean 172 cm/sec"),524 _Result(match_text="Ao mean PG 14 mmHg"),525 ],526 }527 if not _run_tests(test_data):528 return False529 return True530###############################################################################531def get_version():532 return '{0} {1}.{2}'.format(_MODULE_NAME, _VERSION_MAJOR, _VERSION_MINOR)533###############################################################################534if __name__ == '__main__':535 parser = argparse.ArgumentParser(536 description='Run validation tests on the recognizer modules.'537 )538 539 parser.add_argument('-v', '--version',540 help='show version and exit',541 action='store_true')542 parser.add_argument('-d', '--debug',543 help='log debug information to stdout',544 action='store_true')545 args = parser.parse_args()546 if 'version' in args and args.version:547 print(_get_version())548 sys.exit(0)549 if 'debug' in args and args.debug:550 lvm.enable_debug()...

Full Screen

Full Screen

gokulang.py

Source:gokulang.py Github

copy

Full Screen

1import re2from janome.tokenizer import Tokenizer3from pykakasi import kakasi as Kakasi4from .romakana import romaji_to_hiragana5class GokuLang:6 _detail = {7 'surface': '',8 'part_of_speech': '',9 'reading': '',10 'base_form': '',11 'original_romaji': '',12 'translated_romaji': '',13 'translated': ''14 }15 _result = {16 'original': '',17 'translated': '',18 'details': [],19 }20 def __init__(self):21 self._result['original'] = ''22 self._result['translated'] = ''23 self._result['details'] = []24 def __str__(self):25 return self._result['translated']26 def translate(self, text):27 self.__init__()28 self._result['original'] = text29 self._morphological_analysis(text)30 self._goku_translation()31 self._romaji_to_japanese()32 for detail in self._result['details']:33 self._result['translated'] += detail['translated']34 return self._result['translated']35 def _morphological_analysis(self, text):36 T = Tokenizer()37 tokens = T.tokenize(text.replace('\n', ''))38 for token in tokens:39 self._detail['surface'] = token.surface40 self._detail['part_of_speech'] = token.part_of_speech.split(',')[0]41 self._detail['reading'] = token.reading42 self._detail['base_form'] = token.base_form43 if self._detail['reading'] != '*':44 self._detail['original_romaji'] = self._kana_to_romaji(self._detail['reading'])45 else:46 self._detail['original_romaji'] = self._kana_to_romaji(self._detail['surface'])47 self._result['details'].append(self._detail.copy())48 def _goku_translation(self):49 self._changing_verb()50 for detail in self._result['details']:51 if detail['translated_romaji'] == '':52 detail['translated_romaji'] = detail['original_romaji']53 detail['translated_romaji'] = re.sub('(a|e|o)(i|e)', 'ele', detail['translated_romaji'])54 def _changing_verb(self):55 for i in range(len(self._result['details'])):56 # i + 1 を参照するとIndexErrorとなるため、ループを終了させる57 if i == len(self._result['details']) - 1:58 break59 # 助動詞が文末以外だと想定外の変化が発生してしまうため、判定を追加60 # e.g.) し(動詞) + た(助動詞) + ぞ(助詞) => すっ + ぞ + ぞ61 if i != len(self._result['details']) - 2:62 continue63 if self._result['details'][i + 1]['part_of_speech'] != '助動詞':64 continue65 if re.match('^た|だ|ない$', self._result['details'][i + 1]['base_form']):66 continue67 if self._result['details'][i]['part_of_speech'] == '動詞':68 # e.g.) します => する(動詞)+ます(助動詞) => suru + masu => sultu + zo => すっ + ぞ69 t = self._result['details'][i]['base_form']70 t = self._kana_to_romaji(t)71 self._result['details'][i]['translated_romaji'] = t.replace('ru', 'ltu')72 self._result['details'][i + 1]['translated_romaji'] = 'zo'73 '''74 越えるよ => けぇっよ になるのでコメントアウト75 for i in range(len(self._result['details'])):76 if i == len(self._result['details']) - 1:77 break78 if self._result['details'][i + 1]['part_of_speech'] != '助詞':79 continue80 if self._result['details'][i - 1]['part_of_speech'] != '助詞':81 continue82 if self._result['details'][i]['part_of_speech'] == '動詞':83 # e.g.) 〜てみるか => 〜(動詞)+て(助詞)+みる(動詞)+か(助詞) => te + miru + ka => te + miltu + ka => て + みっ + か84 t = self._result['details'][i]['original_romaji']85 self._result['details'][i]['translated_romaji'] = t.replace('ru', 'ltu')86 '''87 def _romaji_to_japanese(self):88 for detail in self._result['details']:89 if detail['translated_romaji'] == detail['original_romaji'] or detail['translated_romaji'] == '':90 detail['translated'] = detail['surface']91 else:92 detail['translated'] = romaji_to_hiragana(detail['translated_romaji'])93 def _kana_to_romaji(self, text):94 kakasi = Kakasi()95 kakasi.setMode("H", "a") # Hiragana to ascii96 kakasi.setMode("K", "a") # Katakana to ascii97 kakasi.setMode("J", "a") # Japanese(kanji) to ascii98 kakasi.setMode("r", "Hepburn") # Use Hepburn romanization99 conv = kakasi.getConverter()100 result = conv.do(text)101 return result102if __name__ == '__main__':103 text = 'FF外から失礼します'104 g = GokuLang()105 g.translate(text)106 print(g._result['details'])107 print(g._result['original'])...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run rester automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful