/pypy/rlib/parsing/pypackrat.py
Python | 3134 lines | 3125 code | 3 blank | 6 comment | 704 complexity | 4fe6cd292601704f975fda35cd6bcc14 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- from pypy.rlib.parsing.tree import Nonterminal, Symbol
- from pypy.rlib.parsing.makepackrat import PackratParser, BacktrackException, Status
- class Parser(object):
- def NAME(self):
- return self._NAME().result
- def _NAME(self):
- _key = self._pos
- _status = self._dict_NAME.get(_key, None)
- if _status is None:
- _status = self._dict_NAME[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _result = self._regex1074651696()
- assert _status.status != _status.LEFTRECURSION
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = _exc.error
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def SPACE(self):
- return self._SPACE().result
- def _SPACE(self):
- _key = self._pos
- _status = self._dict_SPACE.get(_key, None)
- if _status is None:
- _status = self._dict_SPACE[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _result = self.__chars__(' ')
- assert _status.status != _status.LEFTRECURSION
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = _exc.error
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def COMMENT(self):
- return self._COMMENT().result
- def _COMMENT(self):
- _key = self._pos
- _status = self._dict_COMMENT.get(_key, None)
- if _status is None:
- _status = self._dict_COMMENT[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _result = self._regex528667127()
- assert _status.status != _status.LEFTRECURSION
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = _exc.error
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def IGNORE(self):
- return self._IGNORE().result
- def _IGNORE(self):
- _key = self._pos
- _status = self._dict_IGNORE.get(_key, None)
- if _status is None:
- _status = self._dict_IGNORE[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _result = self._regex1979538501()
- assert _status.status != _status.LEFTRECURSION
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = _exc.error
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def newline(self):
- return self._newline().result
- def _newline(self):
- _key = self._pos
- _status = self._dict_newline.get(_key, None)
- if _status is None:
- _status = self._dict_newline[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- while 1:
- _choice0 = self._pos
- try:
- _call_status = self._COMMENT()
- _result = _call_status.result
- _error = _call_status.error
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice0
- _choice1 = self._pos
- try:
- _result = self._regex299149370()
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice1
- raise BacktrackException(_error)
- _result = self._regex299149370()
- break
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._newline()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = self._combine_errors(_error, _exc.error)
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def REGEX(self):
- return self._REGEX().result
- def _REGEX(self):
- _key = self._pos
- _status = self._dict_REGEX.get(_key, None)
- if _status is None:
- _status = self._dict_REGEX[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _result = self._regex1006631623()
- r = _result
- _result = (Symbol('REGEX', r, None))
- assert _status.status != _status.LEFTRECURSION
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = _exc.error
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def QUOTE(self):
- return self._QUOTE().result
- def _QUOTE(self):
- _key = self._pos
- _status = self._dict_QUOTE.get(_key, None)
- if _status is None:
- _status = self._dict_QUOTE[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _result = self._regex1124192327()
- r = _result
- _result = (Symbol('QUOTE', r, None))
- assert _status.status != _status.LEFTRECURSION
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = _exc.error
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def PYTHONCODE(self):
- return self._PYTHONCODE().result
- def _PYTHONCODE(self):
- _key = self._pos
- _status = self._dict_PYTHONCODE.get(_key, None)
- if _status is None:
- _status = self._dict_PYTHONCODE[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _result = self._regex291086639()
- r = _result
- _result = (Symbol('PYTHONCODE', r, None))
- assert _status.status != _status.LEFTRECURSION
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = _exc.error
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def EOF(self):
- return self._EOF().result
- def _EOF(self):
- _key = self._pos
- _status = self._dict_EOF.get(_key, None)
- if _status is None:
- _status = self._dict_EOF[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _choice0 = self._pos
- _stored_result1 = _result
- try:
- _result = self.__any__()
- except BacktrackException:
- self._pos = _choice0
- _result = _stored_result1
- else:
- raise BacktrackException(None)
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._EOF()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = _exc.error
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def file(self):
- return self._file().result
- def _file(self):
- _key = self._pos
- _status = self._dict_file.get(_key, None)
- if _status is None:
- _status = self._dict_file[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _all0 = []
- while 1:
- _choice1 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = _call_status.error
- _all0.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice1
- break
- _result = _all0
- _call_status = self._list()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _before_discard2 = _result
- _call_status = self._EOF()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _result = _before_discard2
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._file()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = self._combine_errors(_error, _exc.error)
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def list(self):
- return self._list().result
- def _list(self):
- _key = self._pos
- _status = self._dict_list.get(_key, None)
- if _status is None:
- _status = self._dict_list[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _all0 = []
- _call_status = self._production()
- _result = _call_status.result
- _error = _call_status.error
- _all0.append(_result)
- while 1:
- _choice1 = self._pos
- try:
- _call_status = self._production()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all0.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice1
- break
- _result = _all0
- content = _result
- _result = (Nonterminal('list', content))
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._list()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = self._combine_errors(_error, _exc.error)
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def production(self):
- return self._production().result
- def _production(self):
- _key = self._pos
- _status = self._dict_production.get(_key, None)
- if _status is None:
- _status = self._dict_production[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _call_status = self._NAME()
- _result = _call_status.result
- _error = _call_status.error
- name = _result
- _all0 = []
- while 1:
- _choice1 = self._pos
- try:
- _call_status = self._SPACE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all0.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice1
- break
- _result = _all0
- _call_status = self._productionargs()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- args = _result
- _result = self.__chars__(':')
- _all2 = []
- while 1:
- _choice3 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all2.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice3
- break
- _result = _all2
- _call_status = self._or_()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- what = _result
- _all4 = []
- while 1:
- _choice5 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all4.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice5
- break
- _result = _all4
- _result = self.__chars__(';')
- _all6 = []
- while 1:
- _choice7 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all6.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice7
- break
- _result = _all6
- _result = (Nonterminal('production', [name, args, what]))
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._production()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = self._combine_errors(_error, _exc.error)
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def productionargs(self):
- return self._productionargs().result
- def _productionargs(self):
- _key = self._pos
- _status = self._dict_productionargs.get(_key, None)
- if _status is None:
- _status = self._dict_productionargs[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- while 1:
- _choice0 = self._pos
- try:
- _result = self.__chars__('(')
- _all1 = []
- while 1:
- _choice2 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = _call_status.error
- _all1.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice2
- break
- _result = _all1
- _all3 = []
- while 1:
- _choice4 = self._pos
- try:
- _call_status = self._NAME()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _before_discard5 = _result
- _all6 = []
- while 1:
- _choice7 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all6.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice7
- break
- _result = _all6
- _result = self.__chars__(',')
- _all8 = []
- while 1:
- _choice9 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all8.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice9
- break
- _result = _all8
- _result = _before_discard5
- _all3.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice4
- break
- _result = _all3
- args = _result
- _call_status = self._NAME()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- arg = _result
- _all10 = []
- while 1:
- _choice11 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all10.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice11
- break
- _result = _all10
- _result = self.__chars__(')')
- _all12 = []
- while 1:
- _choice13 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all12.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice13
- break
- _result = _all12
- _result = (Nonterminal('productionargs', args + [arg]))
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice0
- _choice14 = self._pos
- try:
- _result = (Nonterminal('productionargs', []))
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice14
- raise BacktrackException(_error)
- _result = (Nonterminal('productionargs', []))
- break
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._productionargs()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = self._combine_errors(_error, _exc.error)
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def or_(self):
- return self._or_().result
- def _or_(self):
- _key = self._pos
- _status = self._dict_or_.get(_key, None)
- if _status is None:
- _status = self._dict_or_[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- while 1:
- _choice0 = self._pos
- try:
- _all1 = []
- _call_status = self._commands()
- _result = _call_status.result
- _error = _call_status.error
- _before_discard2 = _result
- _result = self.__chars__('|')
- _all3 = []
- while 1:
- _choice4 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all3.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice4
- break
- _result = _all3
- _result = _before_discard2
- _all1.append(_result)
- while 1:
- _choice5 = self._pos
- try:
- _call_status = self._commands()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _before_discard6 = _result
- _result = self.__chars__('|')
- _all7 = []
- while 1:
- _choice8 = self._pos
- try:
- _call_status = self._IGNORE()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all7.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice8
- break
- _result = _all7
- _result = _before_discard6
- _all1.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice5
- break
- _result = _all1
- l = _result
- _call_status = self._commands()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- last = _result
- _result = (Nonterminal('or', l + [last]))
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice0
- _choice9 = self._pos
- try:
- _call_status = self._commands()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice9
- raise BacktrackException(_error)
- _call_status = self._commands()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._or_()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = self._combine_errors(_error, _exc.error)
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def commands(self):
- return self._commands().result
- def _commands(self):
- _key = self._pos
- _status = self._dict_commands.get(_key, None)
- if _status is None:
- _status = self._dict_commands[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- while 1:
- _choice0 = self._pos
- try:
- _call_status = self._command()
- _result = _call_status.result
- _error = _call_status.error
- cmd = _result
- _call_status = self._newline()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _all1 = []
- _call_status = self._command()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _before_discard2 = _result
- _call_status = self._newline()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _result = _before_discard2
- _all1.append(_result)
- while 1:
- _choice3 = self._pos
- try:
- _call_status = self._command()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _before_discard4 = _result
- _call_status = self._newline()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- _result = _before_discard4
- _all1.append(_result)
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice3
- break
- _result = _all1
- cmds = _result
- _result = (Nonterminal('commands', [cmd] + cmds))
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice0
- _choice5 = self._pos
- try:
- _call_status = self._command()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice5
- raise BacktrackException(_error)
- _call_status = self._command()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._commands()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = self._combine_errors(_error, _exc.error)
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def command(self):
- return self._command().result
- def _command(self):
- _key = self._pos
- _status = self._dict_command.get(_key, None)
- if _status is None:
- _status = self._dict_command[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- _call_status = self._simplecommand()
- _result = _call_status.result
- _error = _call_status.error
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._command()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- except BacktrackException, _exc:
- _status.pos = -1
- _status.result = None
- _error = self._combine_errors(_error, _exc.error)
- _status.error = _error
- _status.status = _status.ERROR
- raise BacktrackException(_error)
- def simplecommand(self):
- return self._simplecommand().result
- def _simplecommand(self):
- _key = self._pos
- _status = self._dict_simplecommand.get(_key, None)
- if _status is None:
- _status = self._dict_simplecommand[_key] = Status()
- else:
- _statusstatus = _status.status
- if _statusstatus == _status.NORMAL:
- self._pos = _status.pos
- return _status
- elif _statusstatus == _status.ERROR:
- raise BacktrackException(_status.error)
- elif (_statusstatus == _status.INPROGRESS or
- _statusstatus == _status.LEFTRECURSION):
- _status.status = _status.LEFTRECURSION
- if _status.result is not None:
- self._pos = _status.pos
- return _status
- else:
- raise BacktrackException(None)
- elif _statusstatus == _status.SOMESOLUTIONS:
- _status.status = _status.INPROGRESS
- _startingpos = self._pos
- try:
- _result = None
- _error = None
- while 1:
- _choice0 = self._pos
- try:
- _call_status = self._return_()
- _result = _call_status.result
- _error = _call_status.error
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice0
- _choice1 = self._pos
- try:
- _call_status = self._if_()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice1
- _choice2 = self._pos
- try:
- _call_status = self._named_command()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice2
- _choice3 = self._pos
- try:
- _call_status = self._repetition()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice3
- _choice4 = self._pos
- try:
- _call_status = self._choose()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice4
- _choice5 = self._pos
- try:
- _call_status = self._negation()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- except BacktrackException, _exc:
- _error = self._combine_errors(_error, _exc.error)
- self._pos = _choice5
- raise BacktrackException(_error)
- _call_status = self._negation()
- _result = _call_status.result
- _error = self._combine_errors(_error, _call_status.error)
- break
- if _status.status == _status.LEFTRECURSION:
- if _status.result is not None:
- if _status.pos >= self._pos:
- _status.status = _status.NORMAL
- self._pos = _status.pos
- return _status
- _status.pos = self._pos
- _status.status = _status.SOMESOLUTIONS
- _status.result = _result
- _status.error = _error
- self._pos = _startingpos
- return self._simplecommand()
- _status.status = _status.NORMAL
- _status.pos = self._pos
- _status.result = _result
- _status.error = _error
- return _status
- …
Large files files are truncated, but you can click here to view the full file