Debian Codegraph @

rpython/rlib/parsing/pypackrat.py

raw symbols SCIP
1
2 from rpython.rlib.parsing.tree import Nonterminal, Symbol
3 from rpython.rlib.parsing.makepackrat import PackratParser, BacktrackException, Status
4
5
6 class Parser(object):
7 def NAME(self):
8 return self._NAME().result
9 def _NAME(self):
10 _key = self._pos
11 _status = self._dict_NAME.get(_key, None)
12 if _status is None:
13 _status = self._dict_NAME[_key] = Status()
14 else:
15 _statusstatus = _status.status
16 if _statusstatus == _status.NORMAL:
17 self._pos = _status.pos
18 return _status
19 elif _statusstatus == _status.ERROR:
20 raise BacktrackException(_status.error)
21 _startingpos = self._pos
22 try:
23 _result = None
24 _error = None
25 _result = self._regex1074651696()
26 assert _status.status != _status.LEFTRECURSION
27 _status.status = _status.NORMAL
28 _status.pos = self._pos
29 _status.result = _result
30 _status.error = _error
31 return _status
32 except BacktrackException as _exc:
33 _status.pos = -1
34 _status.result = None
35 _error = _exc.error
36 _status.error = _error
37 _status.status = _status.ERROR
38 raise BacktrackException(_error)
39 def SPACE(self):
40 return self._SPACE().result
41 def _SPACE(self):
42 _key = self._pos
43 _status = self._dict_SPACE.get(_key, None)
44 if _status is None:
45 _status = self._dict_SPACE[_key] = Status()
46 else:
47 _statusstatus = _status.status
48 if _statusstatus == _status.NORMAL:
49 self._pos = _status.pos
50 return _status
51 elif _statusstatus == _status.ERROR:
52 raise BacktrackException(_status.error)
53 _startingpos = self._pos
54 try:
55 _result = None
56 _error = None
57 _result = self.__chars__(' ')
58 assert _status.status != _status.LEFTRECURSION
59 _status.status = _status.NORMAL
60 _status.pos = self._pos
61 _status.result = _result
62 _status.error = _error
63 return _status
64 except BacktrackException as _exc:
65 _status.pos = -1
66 _status.result = None
67 _error = _exc.error
68 _status.error = _error
69 _status.status = _status.ERROR
70 raise BacktrackException(_error)
71 def COMMENT(self):
72 return self._COMMENT().result
73 def _COMMENT(self):
74 _key = self._pos
75 _status = self._dict_COMMENT.get(_key, None)
76 if _status is None:
77 _status = self._dict_COMMENT[_key] = Status()
78 else:
79 _statusstatus = _status.status
80 if _statusstatus == _status.NORMAL:
81 self._pos = _status.pos
82 return _status
83 elif _statusstatus == _status.ERROR:
84 raise BacktrackException(_status.error)
85 _startingpos = self._pos
86 try:
87 _result = None
88 _error = None
89 _result = self._regex528667127()
90 assert _status.status != _status.LEFTRECURSION
91 _status.status = _status.NORMAL
92 _status.pos = self._pos
93 _status.result = _result
94 _status.error = _error
95 return _status
96 except BacktrackException as _exc:
97 _status.pos = -1
98 _status.result = None
99 _error = _exc.error
100 _status.error = _error
101 _status.status = _status.ERROR
102 raise BacktrackException(_error)
103 def IGNORE(self):
104 return self._IGNORE().result
105 def _IGNORE(self):
106 _key = self._pos
107 _status = self._dict_IGNORE.get(_key, None)
108 if _status is None:
109 _status = self._dict_IGNORE[_key] = Status()
110 else:
111 _statusstatus = _status.status
112 if _statusstatus == _status.NORMAL:
113 self._pos = _status.pos
114 return _status
115 elif _statusstatus == _status.ERROR:
116 raise BacktrackException(_status.error)
117 _startingpos = self._pos
118 try:
119 _result = None
120 _error = None
121 _result = self._regex1979538501()
122 assert _status.status != _status.LEFTRECURSION
123 _status.status = _status.NORMAL
124 _status.pos = self._pos
125 _status.result = _result
126 _status.error = _error
127 return _status
128 except BacktrackException as _exc:
129 _status.pos = -1
130 _status.result = None
131 _error = _exc.error
132 _status.error = _error
133 _status.status = _status.ERROR
134 raise BacktrackException(_error)
135 def newline(self):
136 return self._newline().result
137 def _newline(self):
138 _key = self._pos
139 _status = self._dict_newline.get(_key, None)
140 if _status is None:
141 _status = self._dict_newline[_key] = Status()
142 else:
143 _statusstatus = _status.status
144 if _statusstatus == _status.NORMAL:
145 self._pos = _status.pos
146 return _status
147 elif _statusstatus == _status.ERROR:
148 raise BacktrackException(_status.error)
149 elif (_statusstatus == _status.INPROGRESS or
150 _statusstatus == _status.LEFTRECURSION):
151 _status.status = _status.LEFTRECURSION
152 if _status.result is not None:
153 self._pos = _status.pos
154 return _status
155 else:
156 raise BacktrackException(None)
157 elif _statusstatus == _status.SOMESOLUTIONS:
158 _status.status = _status.INPROGRESS
159 _startingpos = self._pos
160 try:
161 _result = None
162 _error = None
163 while 1:
164 _choice0 = self._pos
165 try:
166 _call_status = self._COMMENT()
167 _result = _call_status.result
168 _error = _call_status.error
169 break
170 except BacktrackException as _exc:
171 _error = self._combine_errors(_error, _exc.error)
172 self._pos = _choice0
173 _choice1 = self._pos
174 try:
175 _result = self._regex299149370()
176 break
177 except BacktrackException as _exc:
178 _error = self._combine_errors(_error, _exc.error)
179 self._pos = _choice1
180 raise BacktrackException(_error)
181 _result = self._regex299149370()
182 break
183 if _status.status == _status.LEFTRECURSION:
184 if _status.result is not None:
185 if _status.pos >= self._pos:
186 _status.status = _status.NORMAL
187 self._pos = _status.pos
188 return _status
189 _status.pos = self._pos
190 _status.status = _status.SOMESOLUTIONS
191 _status.result = _result
192 _status.error = _error
193 self._pos = _startingpos
194 return self._newline()
195 _status.status = _status.NORMAL
196 _status.pos = self._pos
197 _status.result = _result
198 _status.error = _error
199 return _status
200 except BacktrackException as _exc:
201 _status.pos = -1
202 _status.result = None
203 _error = self._combine_errors(_error, _exc.error)
204 _status.error = _error
205 _status.status = _status.ERROR
206 raise BacktrackException(_error)
207 def REGEX(self):
208 return self._REGEX().result
209 def _REGEX(self):
210 _key = self._pos
211 _status = self._dict_REGEX.get(_key, None)
212 if _status is None:
213 _status = self._dict_REGEX[_key] = Status()
214 else:
215 _statusstatus = _status.status
216 if _statusstatus == _status.NORMAL:
217 self._pos = _status.pos
218 return _status
219 elif _statusstatus == _status.ERROR:
220 raise BacktrackException(_status.error)
221 _startingpos = self._pos
222 try:
223 _result = None
224 _error = None
225 _result = self._regex1006631623()
226 r = _result
227 _result = (Symbol('REGEX', r, None))
228 assert _status.status != _status.LEFTRECURSION
229 _status.status = _status.NORMAL
230 _status.pos = self._pos
231 _status.result = _result
232 _status.error = _error
233 return _status
234 except BacktrackException as _exc:
235 _status.pos = -1
236 _status.result = None
237 _error = _exc.error
238 _status.error = _error
239 _status.status = _status.ERROR
240 raise BacktrackException(_error)
241 def QUOTE(self):
242 return self._QUOTE().result
243 def _QUOTE(self):
244 _key = self._pos
245 _status = self._dict_QUOTE.get(_key, None)
246 if _status is None:
247 _status = self._dict_QUOTE[_key] = Status()
248 else:
249 _statusstatus = _status.status
250 if _statusstatus == _status.NORMAL:
251 self._pos = _status.pos
252 return _status
253 elif _statusstatus == _status.ERROR:
254 raise BacktrackException(_status.error)
255 _startingpos = self._pos
256 try:
257 _result = None
258 _error = None
259 _result = self._regex1124192327()
260 r = _result
261 _result = (Symbol('QUOTE', r, None))
262 assert _status.status != _status.LEFTRECURSION
263 _status.status = _status.NORMAL
264 _status.pos = self._pos
265 _status.result = _result
266 _status.error = _error
267 return _status
268 except BacktrackException as _exc:
269 _status.pos = -1
270 _status.result = None
271 _error = _exc.error
272 _status.error = _error
273 _status.status = _status.ERROR
274 raise BacktrackException(_error)
275 def PYTHONCODE(self):
276 return self._PYTHONCODE().result
277 def _PYTHONCODE(self):
278 _key = self._pos
279 _status = self._dict_PYTHONCODE.get(_key, None)
280 if _status is None:
281 _status = self._dict_PYTHONCODE[_key] = Status()
282 else:
283 _statusstatus = _status.status
284 if _statusstatus == _status.NORMAL:
285 self._pos = _status.pos
286 return _status
287 elif _statusstatus == _status.ERROR:
288 raise BacktrackException(_status.error)
289 _startingpos = self._pos
290 try:
291 _result = None
292 _error = None
293 _result = self._regex291086639()
294 r = _result
295 _result = (Symbol('PYTHONCODE', r, None))
296 assert _status.status != _status.LEFTRECURSION
297 _status.status = _status.NORMAL
298 _status.pos = self._pos
299 _status.result = _result
300 _status.error = _error
301 return _status
302 except BacktrackException as _exc:
303 _status.pos = -1
304 _status.result = None
305 _error = _exc.error
306 _status.error = _error
307 _status.status = _status.ERROR
308 raise BacktrackException(_error)
309 def EOF(self):
310 return self._EOF().result
311 def _EOF(self):
312 _key = self._pos
313 _status = self._dict_EOF.get(_key, None)
314 if _status is None:
315 _status = self._dict_EOF[_key] = Status()
316 else:
317 _statusstatus = _status.status
318 if _statusstatus == _status.NORMAL:
319 self._pos = _status.pos
320 return _status
321 elif _statusstatus == _status.ERROR:
322 raise BacktrackException(_status.error)
323 elif (_statusstatus == _status.INPROGRESS or
324 _statusstatus == _status.LEFTRECURSION):
325 _status.status = _status.LEFTRECURSION
326 if _status.result is not None:
327 self._pos = _status.pos
328 return _status
329 else:
330 raise BacktrackException(None)
331 elif _statusstatus == _status.SOMESOLUTIONS:
332 _status.status = _status.INPROGRESS
333 _startingpos = self._pos
334 try:
335 _result = None
336 _error = None
337 _choice0 = self._pos
338 _stored_result1 = _result
339 try:
340 _result = self.__any__()
341 except BacktrackException:
342 self._pos = _choice0
343 _result = _stored_result1
344 else:
345 raise BacktrackException(None)
346 if _status.status == _status.LEFTRECURSION:
347 if _status.result is not None:
348 if _status.pos >= self._pos:
349 _status.status = _status.NORMAL
350 self._pos = _status.pos
351 return _status
352 _status.pos = self._pos
353 _status.status = _status.SOMESOLUTIONS
354 _status.result = _result
355 _status.error = _error
356 self._pos = _startingpos
357 return self._EOF()
358 _status.status = _status.NORMAL
359 _status.pos = self._pos
360 _status.result = _result
361 _status.error = _error
362 return _status
363 except BacktrackException as _exc:
364 _status.pos = -1
365 _status.result = None
366 _error = _exc.error
367 _status.error = _error
368 _status.status = _status.ERROR
369 raise BacktrackException(_error)
370 def file(self):
371 return self._file().result
372 def _file(self):
373 _key = self._pos
374 _status = self._dict_file.get(_key, None)
375 if _status is None:
376 _status = self._dict_file[_key] = Status()
377 else:
378 _statusstatus = _status.status
379 if _statusstatus == _status.NORMAL:
380 self._pos = _status.pos
381 return _status
382 elif _statusstatus == _status.ERROR:
383 raise BacktrackException(_status.error)
384 elif (_statusstatus == _status.INPROGRESS or
385 _statusstatus == _status.LEFTRECURSION):
386 _status.status = _status.LEFTRECURSION
387 if _status.result is not None:
388 self._pos = _status.pos
389 return _status
390 else:
391 raise BacktrackException(None)
392 elif _statusstatus == _status.SOMESOLUTIONS:
393 _status.status = _status.INPROGRESS
394 _startingpos = self._pos
395 try:
396 _result = None
397 _error = None
398 _all0 = []
399 while 1:
400 _choice1 = self._pos
401 try:
402 _call_status = self._IGNORE()
403 _result = _call_status.result
404 _error = _call_status.error
405 _all0.append(_result)
406 except BacktrackException as _exc:
407 _error = self._combine_errors(_error, _exc.error)
408 self._pos = _choice1
409 break
410 _result = _all0
411 _call_status = self._list()
412 _result = _call_status.result
413 _error = self._combine_errors(_error, _call_status.error)
414 _before_discard2 = _result
415 _call_status = self._EOF()
416 _result = _call_status.result
417 _error = self._combine_errors(_error, _call_status.error)
418 _result = _before_discard2
419 if _status.status == _status.LEFTRECURSION:
420 if _status.result is not None:
421 if _status.pos >= self._pos:
422 _status.status = _status.NORMAL
423 self._pos = _status.pos
424 return _status
425 _status.pos = self._pos
426 _status.status = _status.SOMESOLUTIONS
427 _status.result = _result
428 _status.error = _error
429 self._pos = _startingpos
430 return self._file()
431 _status.status = _status.NORMAL
432 _status.pos = self._pos
433 _status.result = _result
434 _status.error = _error
435 return _status
436 except BacktrackException as _exc:
437 _status.pos = -1
438 _status.result = None
439 _error = self._combine_errors(_error, _exc.error)
440 _status.error = _error
441 _status.status = _status.ERROR
442 raise BacktrackException(_error)
443 def list(self):
444 return self._list().result
445 def _list(self):
446 _key = self._pos
447 _status = self._dict_list.get(_key, None)
448 if _status is None:
449 _status = self._dict_list[_key] = Status()
450 else:
451 _statusstatus = _status.status
452 if _statusstatus == _status.NORMAL:
453 self._pos = _status.pos
454 return _status
455 elif _statusstatus == _status.ERROR:
456 raise BacktrackException(_status.error)
457 elif (_statusstatus == _status.INPROGRESS or
458 _statusstatus == _status.LEFTRECURSION):
459 _status.status = _status.LEFTRECURSION
460 if _status.result is not None:
461 self._pos = _status.pos
462 return _status
463 else:
464 raise BacktrackException(None)
465 elif _statusstatus == _status.SOMESOLUTIONS:
466 _status.status = _status.INPROGRESS
467 _startingpos = self._pos
468 try:
469 _result = None
470 _error = None
471 _all0 = []
472 _call_status = self._production()
473 _result = _call_status.result
474 _error = _call_status.error
475 _all0.append(_result)
476 while 1:
477 _choice1 = self._pos
478 try:
479 _call_status = self._production()
480 _result = _call_status.result
481 _error = self._combine_errors(_error, _call_status.error)
482 _all0.append(_result)
483 except BacktrackException as _exc:
484 _error = self._combine_errors(_error, _exc.error)
485 self._pos = _choice1
486 break
487 _result = _all0
488 content = _result
489 _result = (Nonterminal('list', content))
490 if _status.status == _status.LEFTRECURSION:
491 if _status.result is not None:
492 if _status.pos >= self._pos:
493 _status.status = _status.NORMAL
494 self._pos = _status.pos
495 return _status
496 _status.pos = self._pos
497 _status.status = _status.SOMESOLUTIONS
498 _status.result = _result
499 _status.error = _error
500 self._pos = _startingpos
501 return self._list()
502 _status.status = _status.NORMAL
503 _status.pos = self._pos
504 _status.result = _result
505 _status.error = _error
506 return _status
507 except BacktrackException as _exc:
508 _status.pos = -1
509 _status.result = None
510 _error = self._combine_errors(_error, _exc.error)
511 _status.error = _error
512 _status.status = _status.ERROR
513 raise BacktrackException(_error)
514 def production(self):
515 return self._production().result
516 def _production(self):
517 _key = self._pos
518 _status = self._dict_production.get(_key, None)
519 if _status is None:
520 _status = self._dict_production[_key] = Status()
521 else:
522 _statusstatus = _status.status
523 if _statusstatus == _status.NORMAL:
524 self._pos = _status.pos
525 return _status
526 elif _statusstatus == _status.ERROR:
527 raise BacktrackException(_status.error)
528 elif (_statusstatus == _status.INPROGRESS or
529 _statusstatus == _status.LEFTRECURSION):
530 _status.status = _status.LEFTRECURSION
531 if _status.result is not None:
532 self._pos = _status.pos
533 return _status
534 else:
535 raise BacktrackException(None)
536 elif _statusstatus == _status.SOMESOLUTIONS:
537 _status.status = _status.INPROGRESS
538 _startingpos = self._pos
539 try:
540 _result = None
541 _error = None
542 _call_status = self._NAME()
543 _result = _call_status.result
544 _error = _call_status.error
545 name = _result
546 _all0 = []
547 while 1:
548 _choice1 = self._pos
549 try:
550 _call_status = self._SPACE()
551 _result = _call_status.result
552 _error = self._combine_errors(_error, _call_status.error)
553 _all0.append(_result)
554 except BacktrackException as _exc:
555 _error = self._combine_errors(_error, _exc.error)
556 self._pos = _choice1
557 break
558 _result = _all0
559 _call_status = self._productionargs()
560 _result = _call_status.result
561 _error = self._combine_errors(_error, _call_status.error)
562 args = _result
563 _result = self.__chars__(':')
564 _all2 = []
565 while 1:
566 _choice3 = self._pos
567 try:
568 _call_status = self._IGNORE()
569 _result = _call_status.result
570 _error = self._combine_errors(_error, _call_status.error)
571 _all2.append(_result)
572 except BacktrackException as _exc:
573 _error = self._combine_errors(_error, _exc.error)
574 self._pos = _choice3
575 break
576 _result = _all2
577 _call_status = self._or_()
578 _result = _call_status.result
579 _error = self._combine_errors(_error, _call_status.error)
580 what = _result
581 _all4 = []
582 while 1:
583 _choice5 = self._pos
584 try:
585 _call_status = self._IGNORE()
586 _result = _call_status.result
587 _error = self._combine_errors(_error, _call_status.error)
588 _all4.append(_result)
589 except BacktrackException as _exc:
590 _error = self._combine_errors(_error, _exc.error)
591 self._pos = _choice5
592 break
593 _result = _all4
594 _result = self.__chars__(';')
595 _all6 = []
596 while 1:
597 _choice7 = self._pos
598 try:
599 _call_status = self._IGNORE()
600 _result = _call_status.result
601 _error = self._combine_errors(_error, _call_status.error)
602 _all6.append(_result)
603 except BacktrackException as _exc:
604 _error = self._combine_errors(_error, _exc.error)
605 self._pos = _choice7
606 break
607 _result = _all6
608 _result = (Nonterminal('production', [name, args, what]))
609 if _status.status == _status.LEFTRECURSION:
610 if _status.result is not None:
611 if _status.pos >= self._pos:
612 _status.status = _status.NORMAL
613 self._pos = _status.pos
614 return _status
615 _status.pos = self._pos
616 _status.status = _status.SOMESOLUTIONS
617 _status.result = _result
618 _status.error = _error
619 self._pos = _startingpos
620 return self._production()
621 _status.status = _status.NORMAL
622 _status.pos = self._pos
623 _status.result = _result
624 _status.error = _error
625 return _status
626 except BacktrackException as _exc:
627 _status.pos = -1
628 _status.result = None
629 _error = self._combine_errors(_error, _exc.error)
630 _status.error = _error
631 _status.status = _status.ERROR
632 raise BacktrackException(_error)
633 def productionargs(self):
634 return self._productionargs().result
635 def _productionargs(self):
636 _key = self._pos
637 _status = self._dict_productionargs.get(_key, None)
638 if _status is None:
639 _status = self._dict_productionargs[_key] = Status()
640 else:
641 _statusstatus = _status.status
642 if _statusstatus == _status.NORMAL:
643 self._pos = _status.pos
644 return _status
645 elif _statusstatus == _status.ERROR:
646 raise BacktrackException(_status.error)
647 elif (_statusstatus == _status.INPROGRESS or
648 _statusstatus == _status.LEFTRECURSION):
649 _status.status = _status.LEFTRECURSION
650 if _status.result is not None:
651 self._pos = _status.pos
652 return _status
653 else:
654 raise BacktrackException(None)
655 elif _statusstatus == _status.SOMESOLUTIONS:
656 _status.status = _status.INPROGRESS
657 _startingpos = self._pos
658 try:
659 _result = None
660 _error = None
661 while 1:
662 _choice0 = self._pos
663 try:
664 _result = self.__chars__('(')
665 _all1 = []
666 while 1:
667 _choice2 = self._pos
668 try:
669 _call_status = self._IGNORE()
670 _result = _call_status.result
671 _error = _call_status.error
672 _all1.append(_result)
673 except BacktrackException as _exc:
674 _error = self._combine_errors(_error, _exc.error)
675 self._pos = _choice2
676 break
677 _result = _all1
678 _all3 = []
679 while 1:
680 _choice4 = self._pos
681 try:
682 _call_status = self._NAME()
683 _result = _call_status.result
684 _error = self._combine_errors(_error, _call_status.error)
685 _before_discard5 = _result
686 _all6 = []
687 while 1:
688 _choice7 = self._pos
689 try:
690 _call_status = self._IGNORE()
691 _result = _call_status.result
692 _error = self._combine_errors(_error, _call_status.error)
693 _all6.append(_result)
694 except BacktrackException as _exc:
695 _error = self._combine_errors(_error, _exc.error)
696 self._pos = _choice7
697 break
698 _result = _all6
699 _result = self.__chars__(',')
700 _all8 = []
701 while 1:
702 _choice9 = self._pos
703 try:
704 _call_status = self._IGNORE()
705 _result = _call_status.result
706 _error = self._combine_errors(_error, _call_status.error)
707 _all8.append(_result)
708 except BacktrackException as _exc:
709 _error = self._combine_errors(_error, _exc.error)
710 self._pos = _choice9
711 break
712 _result = _all8
713 _result = _before_discard5
714 _all3.append(_result)
715 except BacktrackException as _exc:
716 _error = self._combine_errors(_error, _exc.error)
717 self._pos = _choice4
718 break
719 _result = _all3
720 args = _result
721 _call_status = self._NAME()
722 _result = _call_status.result
723 _error = self._combine_errors(_error, _call_status.error)
724 arg = _result
725 _all10 = []
726 while 1:
727 _choice11 = self._pos
728 try:
729 _call_status = self._IGNORE()
730 _result = _call_status.result
731 _error = self._combine_errors(_error, _call_status.error)
732 _all10.append(_result)
733 except BacktrackException as _exc:
734 _error = self._combine_errors(_error, _exc.error)
735 self._pos = _choice11
736 break
737 _result = _all10
738 _result = self.__chars__(')')
739 _all12 = []
740 while 1:
741 _choice13 = self._pos
742 try:
743 _call_status = self._IGNORE()
744 _result = _call_status.result
745 _error = self._combine_errors(_error, _call_status.error)
746 _all12.append(_result)
747 except BacktrackException as _exc:
748 _error = self._combine_errors(_error, _exc.error)
749 self._pos = _choice13
750 break
751 _result = _all12
752 _result = (Nonterminal('productionargs', args + [arg]))
753 break
754 except BacktrackException as _exc:
755 _error = self._combine_errors(_error, _exc.error)
756 self._pos = _choice0
757 _choice14 = self._pos
758 try:
759 _result = (Nonterminal('productionargs', []))
760 break
761 except BacktrackException as _exc:
762 _error = self._combine_errors(_error, _exc.error)
763 self._pos = _choice14
764 raise BacktrackException(_error)
765 _result = (Nonterminal('productionargs', []))
766 break
767 if _status.status == _status.LEFTRECURSION:
768 if _status.result is not None:
769 if _status.pos >= self._pos:
770 _status.status = _status.NORMAL
771 self._pos = _status.pos
772 return _status
773 _status.pos = self._pos
774 _status.status = _status.SOMESOLUTIONS
775 _status.result = _result
776 _status.error = _error
777 self._pos = _startingpos
778 return self._productionargs()
779 _status.status = _status.NORMAL
780 _status.pos = self._pos
781 _status.result = _result
782 _status.error = _error
783 return _status
784 except BacktrackException as _exc:
785 _status.pos = -1
786 _status.result = None
787 _error = self._combine_errors(_error, _exc.error)
788 _status.error = _error
789 _status.status = _status.ERROR
790 raise BacktrackException(_error)
791 def or_(self):
792 return self._or_().result
793 def _or_(self):
794 _key = self._pos
795 _status = self._dict_or_.get(_key, None)
796 if _status is None:
797 _status = self._dict_or_[_key] = Status()
798 else:
799 _statusstatus = _status.status
800 if _statusstatus == _status.NORMAL:
801 self._pos = _status.pos
802 return _status
803 elif _statusstatus == _status.ERROR:
804 raise BacktrackException(_status.error)
805 elif (_statusstatus == _status.INPROGRESS or
806 _statusstatus == _status.LEFTRECURSION):
807 _status.status = _status.LEFTRECURSION
808 if _status.result is not None:
809 self._pos = _status.pos
810 return _status
811 else:
812 raise BacktrackException(None)
813 elif _statusstatus == _status.SOMESOLUTIONS:
814 _status.status = _status.INPROGRESS
815 _startingpos = self._pos
816 try:
817 _result = None
818 _error = None
819 while 1:
820 _choice0 = self._pos
821 try:
822 _all1 = []
823 _call_status = self._commands()
824 _result = _call_status.result
825 _error = _call_status.error
826 _before_discard2 = _result
827 _result = self.__chars__('|')
828 _all3 = []
829 while 1:
830 _choice4 = self._pos
831 try:
832 _call_status = self._IGNORE()
833 _result = _call_status.result
834 _error = self._combine_errors(_error, _call_status.error)
835 _all3.append(_result)
836 except BacktrackException as _exc:
837 _error = self._combine_errors(_error, _exc.error)
838 self._pos = _choice4
839 break
840 _result = _all3
841 _result = _before_discard2
842 _all1.append(_result)
843 while 1:
844 _choice5 = self._pos
845 try:
846 _call_status = self._commands()
847 _result = _call_status.result
848 _error = self._combine_errors(_error, _call_status.error)
849 _before_discard6 = _result
850 _result = self.__chars__('|')
851 _all7 = []
852 while 1:
853 _choice8 = self._pos
854 try:
855 _call_status = self._IGNORE()
856 _result = _call_status.result
857 _error = self._combine_errors(_error, _call_status.error)
858 _all7.append(_result)
859 except BacktrackException as _exc:
860 _error = self._combine_errors(_error, _exc.error)
861 self._pos = _choice8
862 break
863 _result = _all7
864 _result = _before_discard6
865 _all1.append(_result)
866 except BacktrackException as _exc:
867 _error = self._combine_errors(_error, _exc.error)
868 self._pos = _choice5
869 break
870 _result = _all1
871 l = _result
872 _call_status = self._commands()
873 _result = _call_status.result
874 _error = self._combine_errors(_error, _call_status.error)
875 last = _result
876 _result = (Nonterminal('or', l + [last]))
877 break
878 except BacktrackException as _exc:
879 _error = self._combine_errors(_error, _exc.error)
880 self._pos = _choice0
881 _choice9 = self._pos
882 try:
883 _call_status = self._commands()
884 _result = _call_status.result
885 _error = self._combine_errors(_error, _call_status.error)
886 break
887 except BacktrackException as _exc:
888 _error = self._combine_errors(_error, _exc.error)
889 self._pos = _choice9
890 raise BacktrackException(_error)
891 _call_status = self._commands()
892 _result = _call_status.result
893 _error = self._combine_errors(_error, _call_status.error)
894 break
895 if _status.status == _status.LEFTRECURSION:
896 if _status.result is not None:
897 if _status.pos >= self._pos:
898 _status.status = _status.NORMAL
899 self._pos = _status.pos
900 return _status
901 _status.pos = self._pos
902 _status.status = _status.SOMESOLUTIONS
903 _status.result = _result
904 _status.error = _error
905 self._pos = _startingpos
906 return self._or_()
907 _status.status = _status.NORMAL
908 _status.pos = self._pos
909 _status.result = _result
910 _status.error = _error
911 return _status
912 except BacktrackException as _exc:
913 _status.pos = -1
914 _status.result = None
915 _error = self._combine_errors(_error, _exc.error)
916 _status.error = _error
917 _status.status = _status.ERROR
918 raise BacktrackException(_error)
919 def commands(self):
920 return self._commands().result
921 def _commands(self):
922 _key = self._pos
923 _status = self._dict_commands.get(_key, None)
924 if _status is None:
925 _status = self._dict_commands[_key] = Status()
926 else:
927 _statusstatus = _status.status
928 if _statusstatus == _status.NORMAL:
929 self._pos = _status.pos
930 return _status
931 elif _statusstatus == _status.ERROR:
932 raise BacktrackException(_status.error)
933 elif (_statusstatus == _status.INPROGRESS or
934 _statusstatus == _status.LEFTRECURSION):
935 _status.status = _status.LEFTRECURSION
936 if _status.result is not None:
937 self._pos = _status.pos
938 return _status
939 else:
940 raise BacktrackException(None)
941 elif _statusstatus == _status.SOMESOLUTIONS:
942 _status.status = _status.INPROGRESS
943 _startingpos = self._pos
944 try:
945 _result = None
946 _error = None
947 while 1:
948 _choice0 = self._pos
949 try:
950 _call_status = self._command()
951 _result = _call_status.result
952 _error = _call_status.error
953 cmd = _result
954 _call_status = self._newline()
955 _result = _call_status.result
956 _error = self._combine_errors(_error, _call_status.error)
957 _all1 = []
958 _call_status = self._command()
959 _result = _call_status.result
960 _error = self._combine_errors(_error, _call_status.error)
961 _before_discard2 = _result
962 _call_status = self._newline()
963 _result = _call_status.result
964 _error = self._combine_errors(_error, _call_status.error)
965 _result = _before_discard2
966 _all1.append(_result)
967 while 1:
968 _choice3 = self._pos
969 try:
970 _call_status = self._command()
971 _result = _call_status.result
972 _error = self._combine_errors(_error, _call_status.error)
973 _before_discard4 = _result
974 _call_status = self._newline()
975 _result = _call_status.result
976 _error = self._combine_errors(_error, _call_status.error)
977 _result = _before_discard4
978 _all1.append(_result)
979 except BacktrackException as _exc:
980 _error = self._combine_errors(_error, _exc.error)
981 self._pos = _choice3
982 break
983 _result = _all1
984 cmds = _result
985 _result = (Nonterminal('commands', [cmd] + cmds))
986 break
987 except BacktrackException as _exc:
988 _error = self._combine_errors(_error, _exc.error)
989 self._pos = _choice0
990 _choice5 = self._pos
991 try:
992 _call_status = self._command()
993 _result = _call_status.result
994 _error = self._combine_errors(_error, _call_status.error)
995 break
996 except BacktrackException as _exc:
997 _error = self._combine_errors(_error, _exc.error)
998 self._pos = _choice5
999 raise BacktrackException(_error)
1000 _call_status = self._command()
1001 _result = _call_status.result
1002 _error = self._combine_errors(_error, _call_status.error)
1003 break
1004 if _status.status == _status.LEFTRECURSION:
1005 if _status.result is not None:
1006 if _status.pos >= self._pos:
1007 _status.status = _status.NORMAL
1008 self._pos = _status.pos
1009 return _status
1010 _status.pos = self._pos
1011 _status.status = _status.SOMESOLUTIONS
1012 _status.result = _result
1013 _status.error = _error
1014 self._pos = _startingpos
1015 return self._commands()
1016 _status.status = _status.NORMAL
1017 _status.pos = self._pos
1018 _status.result = _result
1019 _status.error = _error
1020 return _status
1021 except BacktrackException as _exc:
1022 _status.pos = -1
1023 _status.result = None
1024 _error = self._combine_errors(_error, _exc.error)
1025 _status.error = _error
1026 _status.status = _status.ERROR
1027 raise BacktrackException(_error)
1028 def command(self):
1029 return self._command().result
1030 def _command(self):
1031 _key = self._pos
1032 _status = self._dict_command.get(_key, None)
1033 if _status is None:
1034 _status = self._dict_command[_key] = Status()
1035 else:
1036 _statusstatus = _status.status
1037 if _statusstatus == _status.NORMAL:
1038 self._pos = _status.pos
1039 return _status
1040 elif _statusstatus == _status.ERROR:
1041 raise BacktrackException(_status.error)
1042 elif (_statusstatus == _status.INPROGRESS or
1043 _statusstatus == _status.LEFTRECURSION):
1044 _status.status = _status.LEFTRECURSION
1045 if _status.result is not None:
1046 self._pos = _status.pos
1047 return _status
1048 else:
1049 raise BacktrackException(None)
1050 elif _statusstatus == _status.SOMESOLUTIONS:
1051 _status.status = _status.INPROGRESS
1052 _startingpos = self._pos
1053 try:
1054 _result = None
1055 _error = None
1056 _call_status = self._simplecommand()
1057 _result = _call_status.result
1058 _error = _call_status.error
1059 if _status.status == _status.LEFTRECURSION:
1060 if _status.result is not None:
1061 if _status.pos >= self._pos:
1062 _status.status = _status.NORMAL
1063 self._pos = _status.pos
1064 return _status
1065 _status.pos = self._pos
1066 _status.status = _status.SOMESOLUTIONS
1067 _status.result = _result
1068 _status.error = _error
1069 self._pos = _startingpos
1070 return self._command()
1071 _status.status = _status.NORMAL
1072 _status.pos = self._pos
1073 _status.result = _result
1074 _status.error = _error
1075 return _status
1076 except BacktrackException as _exc:
1077 _status.pos = -1
1078 _status.result = None
1079 _error = self._combine_errors(_error, _exc.error)
1080 _status.error = _error
1081 _status.status = _status.ERROR
1082 raise BacktrackException(_error)
1083 def simplecommand(self):
1084 return self._simplecommand().result
1085 def _simplecommand(self):
1086 _key = self._pos
1087 _status = self._dict_simplecommand.get(_key, None)
1088 if _status is None:
1089 _status = self._dict_simplecommand[_key] = Status()
1090 else:
1091 _statusstatus = _status.status
1092 if _statusstatus == _status.NORMAL:
1093 self._pos = _status.pos
1094 return _status
1095 elif _statusstatus == _status.ERROR:
1096 raise BacktrackException(_status.error)
1097 elif (_statusstatus == _status.INPROGRESS or
1098 _statusstatus == _status.LEFTRECURSION):
1099 _status.status = _status.LEFTRECURSION
1100 if _status.result is not None:
1101 self._pos = _status.pos
1102 return _status
1103 else:
1104 raise BacktrackException(None)
1105 elif _statusstatus == _status.SOMESOLUTIONS:
1106 _status.status = _status.INPROGRESS
1107 _startingpos = self._pos
1108 try:
1109 _result = None
1110 _error = None
1111 while 1:
1112 _choice0 = self._pos
1113 try:
1114 _call_status = self._return_()
1115 _result = _call_status.result
1116 _error = _call_status.error
1117 break
1118 except BacktrackException as _exc:
1119 _error = self._combine_errors(_error, _exc.error)
1120 self._pos = _choice0
1121 _choice1 = self._pos
1122 try:
1123 _call_status = self._if_()
1124 _result = _call_status.result
1125 _error = self._combine_errors(_error, _call_status.error)
1126 break
1127 except BacktrackException as _exc:
1128 _error = self._combine_errors(_error, _exc.error)
1129 self._pos = _choice1
1130 _choice2 = self._pos
1131 try:
1132 _call_status = self._named_command()
1133 _result = _call_status.result
1134 _error = self._combine_errors(_error, _call_status.error)
1135 break
1136 except BacktrackException as _exc:
1137 _error = self._combine_errors(_error, _exc.error)
1138 self._pos = _choice2
1139 _choice3 = self._pos
1140 try:
1141 _call_status = self._repetition()
1142 _result = _call_status.result
1143 _error = self._combine_errors(_error, _call_status.error)
1144 break
1145 except BacktrackException as _exc:
1146 _error = self._combine_errors(_error, _exc.error)
1147 self._pos = _choice3
1148 _choice4 = self._pos
1149 try:
1150 _call_status = self._choose()
1151 _result = _call_status.result
1152 _error = self._combine_errors(_error, _call_status.error)
1153 break
1154 except BacktrackException as _exc:
1155 _error = self._combine_errors(_error, _exc.error)
1156 self._pos = _choice4
1157 _choice5 = self._pos
1158 try:
1159 _call_status = self._negation()
1160 _result = _call_status.result
1161 _error = self._combine_errors(_error, _call_status.error)
1162 break
1163 except BacktrackException as _exc:
1164 _error = self._combine_errors(_error, _exc.error)
1165 self._pos = _choice5
1166 raise BacktrackException(_error)
1167 _call_status = self._negation()
1168 _result = _call_status.result
1169 _error = self._combine_errors(_error, _call_status.error)
1170 break
1171 if _status.status == _status.LEFTRECURSION:
1172 if _status.result is not None:
1173 if _status.pos >= self._pos:
1174 _status.status = _status.NORMAL
1175 self._pos = _status.pos
1176 return _status
1177 _status.pos = self._pos
1178 _status.status = _status.SOMESOLUTIONS
1179 _status.result = _result
1180 _status.error = _error
1181 self._pos = _startingpos
1182 return self._simplecommand()
1183 _status.status = _status.NORMAL
1184 _status.pos = self._pos
1185 _status.result = _result
1186 _status.error = _error
1187 return _status
1188 except BacktrackException as _exc:
1189 _status.pos = -1
1190 _status.result = None
1191 _error = self._combine_errors(_error, _exc.error)
1192 _status.error = _error
1193 _status.status = _status.ERROR
1194 raise BacktrackException(_error)
1195 def return_(self):
1196 return self._return_().result
1197 def _return_(self):
1198 _key = self._pos
1199 _status = self._dict_return_.get(_key, None)
1200 if _status is None:
1201 _status = self._dict_return_[_key] = Status()
1202 else:
1203 _statusstatus = _status.status
1204 if _statusstatus == _status.NORMAL:
1205 self._pos = _status.pos
1206 return _status
1207 elif _statusstatus == _status.ERROR:
1208 raise BacktrackException(_status.error)
1209 elif (_statusstatus == _status.INPROGRESS or
1210 _statusstatus == _status.LEFTRECURSION):
1211 _status.status = _status.LEFTRECURSION
1212 if _status.result is not None:
1213 self._pos = _status.pos
1214 return _status
1215 else:
1216 raise BacktrackException(None)
1217 elif _statusstatus == _status.SOMESOLUTIONS:
1218 _status.status = _status.INPROGRESS
1219 _startingpos = self._pos
1220 try:
1221 _result = None
1222 _error = None
1223 _result = self.__chars__('return')
1224 _all0 = []
1225 while 1:
1226 _choice1 = self._pos
1227 try:
1228 _call_status = self._SPACE()
1229 _result = _call_status.result
1230 _error = _call_status.error
1231 _all0.append(_result)
1232 except BacktrackException as _exc:
1233 _error = self._combine_errors(_error, _exc.error)
1234 self._pos = _choice1
1235 break
1236 _result = _all0
1237 _call_status = self._PYTHONCODE()
1238 _result = _call_status.result
1239 _error = self._combine_errors(_error, _call_status.error)
1240 code = _result
1241 _all2 = []
1242 while 1:
1243 _choice3 = self._pos
1244 try:
1245 _call_status = self._IGNORE()
1246 _result = _call_status.result
1247 _error = self._combine_errors(_error, _call_status.error)
1248 _all2.append(_result)
1249 except BacktrackException as _exc:
1250 _error = self._combine_errors(_error, _exc.error)
1251 self._pos = _choice3
1252 break
1253 _result = _all2
1254 _result = (Nonterminal('return', [code]))
1255 if _status.status == _status.LEFTRECURSION:
1256 if _status.result is not None:
1257 if _status.pos >= self._pos:
1258 _status.status = _status.NORMAL
1259 self._pos = _status.pos
1260 return _status
1261 _status.pos = self._pos
1262 _status.status = _status.SOMESOLUTIONS
1263 _status.result = _result
1264 _status.error = _error
1265 self._pos = _startingpos
1266 return self._return_()
1267 _status.status = _status.NORMAL
1268 _status.pos = self._pos
1269 _status.result = _result
1270 _status.error = _error
1271 return _status
1272 except BacktrackException as _exc:
1273 _status.pos = -1
1274 _status.result = None
1275 _error = self._combine_errors(_error, _exc.error)
1276 _status.error = _error
1277 _status.status = _status.ERROR
1278 raise BacktrackException(_error)
1279 def if_(self):
1280 return self._if_().result
1281 def _if_(self):
1282 _key = self._pos
1283 _status = self._dict_if_.get(_key, None)
1284 if _status is None:
1285 _status = self._dict_if_[_key] = Status()
1286 else:
1287 _statusstatus = _status.status
1288 if _statusstatus == _status.NORMAL:
1289 self._pos = _status.pos
1290 return _status
1291 elif _statusstatus == _status.ERROR:
1292 raise BacktrackException(_status.error)
1293 elif (_statusstatus == _status.INPROGRESS or
1294 _statusstatus == _status.LEFTRECURSION):
1295 _status.status = _status.LEFTRECURSION
1296 if _status.result is not None:
1297 self._pos = _status.pos
1298 return _status
1299 else:
1300 raise BacktrackException(None)
1301 elif _statusstatus == _status.SOMESOLUTIONS:
1302 _status.status = _status.INPROGRESS
1303 _startingpos = self._pos
1304 try:
1305 _result = None
1306 _error = None
1307 while 1:
1308 _choice0 = self._pos
1309 try:
1310 _result = self.__chars__('do')
1311 _call_status = self._newline()
1312 _result = _call_status.result
1313 _error = _call_status.error
1314 _call_status = self._command()
1315 _result = _call_status.result
1316 _error = self._combine_errors(_error, _call_status.error)
1317 cmd = _result
1318 _all1 = []
1319 while 1:
1320 _choice2 = self._pos
1321 try:
1322 _call_status = self._SPACE()
1323 _result = _call_status.result
1324 _error = self._combine_errors(_error, _call_status.error)
1325 _all1.append(_result)
1326 except BacktrackException as _exc:
1327 _error = self._combine_errors(_error, _exc.error)
1328 self._pos = _choice2
1329 break
1330 _result = _all1
1331 _result = self.__chars__('if')
1332 _all3 = []
1333 while 1:
1334 _choice4 = self._pos
1335 try:
1336 _call_status = self._SPACE()
1337 _result = _call_status.result
1338 _error = self._combine_errors(_error, _call_status.error)
1339 _all3.append(_result)
1340 except BacktrackException as _exc:
1341 _error = self._combine_errors(_error, _exc.error)
1342 self._pos = _choice4
1343 break
1344 _result = _all3
1345 _call_status = self._PYTHONCODE()
1346 _result = _call_status.result
1347 _error = self._combine_errors(_error, _call_status.error)
1348 condition = _result
1349 _all5 = []
1350 while 1:
1351 _choice6 = self._pos
1352 try:
1353 _call_status = self._IGNORE()
1354 _result = _call_status.result
1355 _error = self._combine_errors(_error, _call_status.error)
1356 _all5.append(_result)
1357 except BacktrackException as _exc:
1358 _error = self._combine_errors(_error, _exc.error)
1359 self._pos = _choice6
1360 break
1361 _result = _all5
1362 _result = (Nonterminal('if', [cmd, condition]))
1363 break
1364 except BacktrackException as _exc:
1365 _error = self._combine_errors(_error, _exc.error)
1366 self._pos = _choice0
1367 _choice7 = self._pos
1368 try:
1369 _result = self.__chars__('if')
1370 _all8 = []
1371 while 1:
1372 _choice9 = self._pos
1373 try:
1374 _call_status = self._SPACE()
1375 _result = _call_status.result
1376 _error = self._combine_errors(_error, _call_status.error)
1377 _all8.append(_result)
1378 except BacktrackException as _exc:
1379 _error = self._combine_errors(_error, _exc.error)
1380 self._pos = _choice9
1381 break
1382 _result = _all8
1383 _call_status = self._PYTHONCODE()
1384 _result = _call_status.result
1385 _error = self._combine_errors(_error, _call_status.error)
1386 condition = _result
1387 _all10 = []
1388 while 1:
1389 _choice11 = self._pos
1390 try:
1391 _call_status = self._IGNORE()
1392 _result = _call_status.result
1393 _error = self._combine_errors(_error, _call_status.error)
1394 _all10.append(_result)
1395 except BacktrackException as _exc:
1396 _error = self._combine_errors(_error, _exc.error)
1397 self._pos = _choice11
1398 break
1399 _result = _all10
1400 _result = (Nonterminal('if', [condition]))
1401 break
1402 except BacktrackException as _exc:
1403 _error = self._combine_errors(_error, _exc.error)
1404 self._pos = _choice7
1405 raise BacktrackException(_error)
1406 _result = self.__chars__('if')
1407 _all12 = []
1408 while 1:
1409 _choice13 = self._pos
1410 try:
1411 _call_status = self._SPACE()
1412 _result = _call_status.result
1413 _error = self._combine_errors(_error, _call_status.error)
1414 _all12.append(_result)
1415 except BacktrackException as _exc:
1416 _error = self._combine_errors(_error, _exc.error)
1417 self._pos = _choice13
1418 break
1419 _result = _all12
1420 _call_status = self._PYTHONCODE()
1421 _result = _call_status.result
1422 _error = self._combine_errors(_error, _call_status.error)
1423 condition = _result
1424 _all14 = []
1425 while 1:
1426 _choice15 = self._pos
1427 try:
1428 _call_status = self._IGNORE()
1429 _result = _call_status.result
1430 _error = self._combine_errors(_error, _call_status.error)
1431 _all14.append(_result)
1432 except BacktrackException as _exc:
1433 _error = self._combine_errors(_error, _exc.error)
1434 self._pos = _choice15
1435 break
1436 _result = _all14
1437 _result = (Nonterminal('if', [condition]))
1438 break
1439 if _status.status == _status.LEFTRECURSION:
1440 if _status.result is not None:
1441 if _status.pos >= self._pos:
1442 _status.status = _status.NORMAL
1443 self._pos = _status.pos
1444 return _status
1445 _status.pos = self._pos
1446 _status.status = _status.SOMESOLUTIONS
1447 _status.result = _result
1448 _status.error = _error
1449 self._pos = _startingpos
1450 return self._if_()
1451 _status.status = _status.NORMAL
1452 _status.pos = self._pos
1453 _status.result = _result
1454 _status.error = _error
1455 return _status
1456 except BacktrackException as _exc:
1457 _status.pos = -1
1458 _status.result = None
1459 _error = self._combine_errors(_error, _exc.error)
1460 _status.error = _error
1461 _status.status = _status.ERROR
1462 raise BacktrackException(_error)
1463 def choose(self):
1464 return self._choose().result
1465 def _choose(self):
1466 _key = self._pos
1467 _status = self._dict_choose.get(_key, None)
1468 if _status is None:
1469 _status = self._dict_choose[_key] = Status()
1470 else:
1471 _statusstatus = _status.status
1472 if _statusstatus == _status.NORMAL:
1473 self._pos = _status.pos
1474 return _status
1475 elif _statusstatus == _status.ERROR:
1476 raise BacktrackException(_status.error)
1477 elif (_statusstatus == _status.INPROGRESS or
1478 _statusstatus == _status.LEFTRECURSION):
1479 _status.status = _status.LEFTRECURSION
1480 if _status.result is not None:
1481 self._pos = _status.pos
1482 return _status
1483 else:
1484 raise BacktrackException(None)
1485 elif _statusstatus == _status.SOMESOLUTIONS:
1486 _status.status = _status.INPROGRESS
1487 _startingpos = self._pos
1488 try:
1489 _result = None
1490 _error = None
1491 _result = self.__chars__('choose')
1492 _all0 = []
1493 while 1:
1494 _choice1 = self._pos
1495 try:
1496 _call_status = self._SPACE()
1497 _result = _call_status.result
1498 _error = _call_status.error
1499 _all0.append(_result)
1500 except BacktrackException as _exc:
1501 _error = self._combine_errors(_error, _exc.error)
1502 self._pos = _choice1
1503 break
1504 _result = _all0
1505 _call_status = self._NAME()
1506 _result = _call_status.result
1507 _error = self._combine_errors(_error, _call_status.error)
1508 name = _result
1509 _all2 = []
1510 while 1:
1511 _choice3 = self._pos
1512 try:
1513 _call_status = self._SPACE()
1514 _result = _call_status.result
1515 _error = self._combine_errors(_error, _call_status.error)
1516 _all2.append(_result)
1517 except BacktrackException as _exc:
1518 _error = self._combine_errors(_error, _exc.error)
1519 self._pos = _choice3
1520 break
1521 _result = _all2
1522 _result = self.__chars__('in')
1523 _all4 = []
1524 while 1:
1525 _choice5 = self._pos
1526 try:
1527 _call_status = self._SPACE()
1528 _result = _call_status.result
1529 _error = self._combine_errors(_error, _call_status.error)
1530 _all4.append(_result)
1531 except BacktrackException as _exc:
1532 _error = self._combine_errors(_error, _exc.error)
1533 self._pos = _choice5
1534 break
1535 _result = _all4
1536 _call_status = self._PYTHONCODE()
1537 _result = _call_status.result
1538 _error = self._combine_errors(_error, _call_status.error)
1539 expr = _result
1540 _all6 = []
1541 while 1:
1542 _choice7 = self._pos
1543 try:
1544 _call_status = self._IGNORE()
1545 _result = _call_status.result
1546 _error = self._combine_errors(_error, _call_status.error)
1547 _all6.append(_result)
1548 except BacktrackException as _exc:
1549 _error = self._combine_errors(_error, _exc.error)
1550 self._pos = _choice7
1551 break
1552 _result = _all6
1553 _call_status = self._commands()
1554 _result = _call_status.result
1555 _error = self._combine_errors(_error, _call_status.error)
1556 cmds = _result
1557 _result = (Nonterminal('choose', [name, expr, cmds]))
1558 if _status.status == _status.LEFTRECURSION:
1559 if _status.result is not None:
1560 if _status.pos >= self._pos:
1561 _status.status = _status.NORMAL
1562 self._pos = _status.pos
1563 return _status
1564 _status.pos = self._pos
1565 _status.status = _status.SOMESOLUTIONS
1566 _status.result = _result
1567 _status.error = _error
1568 self._pos = _startingpos
1569 return self._choose()
1570 _status.status = _status.NORMAL
1571 _status.pos = self._pos
1572 _status.result = _result
1573 _status.error = _error
1574 return _status
1575 except BacktrackException as _exc:
1576 _status.pos = -1
1577 _status.result = None
1578 _error = self._combine_errors(_error, _exc.error)
1579 _status.error = _error
1580 _status.status = _status.ERROR
1581 raise BacktrackException(_error)
1582 def commandchain(self):
1583 return self._commandchain().result
1584 def _commandchain(self):
1585 _key = self._pos
1586 _status = self._dict_commandchain.get(_key, None)
1587 if _status is None:
1588 _status = self._dict_commandchain[_key] = Status()
1589 else:
1590 _statusstatus = _status.status
1591 if _statusstatus == _status.NORMAL:
1592 self._pos = _status.pos
1593 return _status
1594 elif _statusstatus == _status.ERROR:
1595 raise BacktrackException(_status.error)
1596 elif (_statusstatus == _status.INPROGRESS or
1597 _statusstatus == _status.LEFTRECURSION):
1598 _status.status = _status.LEFTRECURSION
1599 if _status.result is not None:
1600 self._pos = _status.pos
1601 return _status
1602 else:
1603 raise BacktrackException(None)
1604 elif _statusstatus == _status.SOMESOLUTIONS:
1605 _status.status = _status.INPROGRESS
1606 _startingpos = self._pos
1607 try:
1608 _result = None
1609 _error = None
1610 _all0 = []
1611 _call_status = self._simplecommand()
1612 _result = _call_status.result
1613 _error = _call_status.error
1614 _all0.append(_result)
1615 while 1:
1616 _choice1 = self._pos
1617 try:
1618 _call_status = self._simplecommand()
1619 _result = _call_status.result
1620 _error = self._combine_errors(_error, _call_status.error)
1621 _all0.append(_result)
1622 except BacktrackException as _exc:
1623 _error = self._combine_errors(_error, _exc.error)
1624 self._pos = _choice1
1625 break
1626 _result = _all0
1627 result = _result
1628 _result = (Nonterminal('commands', result))
1629 if _status.status == _status.LEFTRECURSION:
1630 if _status.result is not None:
1631 if _status.pos >= self._pos:
1632 _status.status = _status.NORMAL
1633 self._pos = _status.pos
1634 return _status
1635 _status.pos = self._pos
1636 _status.status = _status.SOMESOLUTIONS
1637 _status.result = _result
1638 _status.error = _error
1639 self._pos = _startingpos
1640 return self._commandchain()
1641 _status.status = _status.NORMAL
1642 _status.pos = self._pos
1643 _status.result = _result
1644 _status.error = _error
1645 return _status
1646 except BacktrackException as _exc:
1647 _status.pos = -1
1648 _status.result = None
1649 _error = self._combine_errors(_error, _exc.error)
1650 _status.error = _error
1651 _status.status = _status.ERROR
1652 raise BacktrackException(_error)
1653 def named_command(self):
1654 return self._named_command().result
1655 def _named_command(self):
1656 _key = self._pos
1657 _status = self._dict_named_command.get(_key, None)
1658 if _status is None:
1659 _status = self._dict_named_command[_key] = Status()
1660 else:
1661 _statusstatus = _status.status
1662 if _statusstatus == _status.NORMAL:
1663 self._pos = _status.pos
1664 return _status
1665 elif _statusstatus == _status.ERROR:
1666 raise BacktrackException(_status.error)
1667 elif (_statusstatus == _status.INPROGRESS or
1668 _statusstatus == _status.LEFTRECURSION):
1669 _status.status = _status.LEFTRECURSION
1670 if _status.result is not None:
1671 self._pos = _status.pos
1672 return _status
1673 else:
1674 raise BacktrackException(None)
1675 elif _statusstatus == _status.SOMESOLUTIONS:
1676 _status.status = _status.INPROGRESS
1677 _startingpos = self._pos
1678 try:
1679 _result = None
1680 _error = None
1681 _call_status = self._NAME()
1682 _result = _call_status.result
1683 _error = _call_status.error
1684 name = _result
1685 _all0 = []
1686 while 1:
1687 _choice1 = self._pos
1688 try:
1689 _call_status = self._SPACE()
1690 _result = _call_status.result
1691 _error = self._combine_errors(_error, _call_status.error)
1692 _all0.append(_result)
1693 except BacktrackException as _exc:
1694 _error = self._combine_errors(_error, _exc.error)
1695 self._pos = _choice1
1696 break
1697 _result = _all0
1698 _result = self.__chars__('=')
1699 _all2 = []
1700 while 1:
1701 _choice3 = self._pos
1702 try:
1703 _call_status = self._SPACE()
1704 _result = _call_status.result
1705 _error = self._combine_errors(_error, _call_status.error)
1706 _all2.append(_result)
1707 except BacktrackException as _exc:
1708 _error = self._combine_errors(_error, _exc.error)
1709 self._pos = _choice3
1710 break
1711 _result = _all2
1712 _call_status = self._command()
1713 _result = _call_status.result
1714 _error = self._combine_errors(_error, _call_status.error)
1715 cmd = _result
1716 _result = (Nonterminal('named_command', [name, cmd]))
1717 if _status.status == _status.LEFTRECURSION:
1718 if _status.result is not None:
1719 if _status.pos >= self._pos:
1720 _status.status = _status.NORMAL
1721 self._pos = _status.pos
1722 return _status
1723 _status.pos = self._pos
1724 _status.status = _status.SOMESOLUTIONS
1725 _status.result = _result
1726 _status.error = _error
1727 self._pos = _startingpos
1728 return self._named_command()
1729 _status.status = _status.NORMAL
1730 _status.pos = self._pos
1731 _status.result = _result
1732 _status.error = _error
1733 return _status
1734 except BacktrackException as _exc:
1735 _status.pos = -1
1736 _status.result = None
1737 _error = self._combine_errors(_error, _exc.error)
1738 _status.error = _error
1739 _status.status = _status.ERROR
1740 raise BacktrackException(_error)
1741 def repetition(self):
1742 return self._repetition().result
1743 def _repetition(self):
1744 _key = self._pos
1745 _status = self._dict_repetition.get(_key, None)
1746 if _status is None:
1747 _status = self._dict_repetition[_key] = Status()
1748 else:
1749 _statusstatus = _status.status
1750 if _statusstatus == _status.NORMAL:
1751 self._pos = _status.pos
1752 return _status
1753 elif _statusstatus == _status.ERROR:
1754 raise BacktrackException(_status.error)
1755 elif (_statusstatus == _status.INPROGRESS or
1756 _statusstatus == _status.LEFTRECURSION):
1757 _status.status = _status.LEFTRECURSION
1758 if _status.result is not None:
1759 self._pos = _status.pos
1760 return _status
1761 else:
1762 raise BacktrackException(None)
1763 elif _statusstatus == _status.SOMESOLUTIONS:
1764 _status.status = _status.INPROGRESS
1765 _startingpos = self._pos
1766 try:
1767 _result = None
1768 _error = None
1769 while 1:
1770 _choice0 = self._pos
1771 try:
1772 _call_status = self._enclosed()
1773 _result = _call_status.result
1774 _error = _call_status.error
1775 what = _result
1776 _all1 = []
1777 while 1:
1778 _choice2 = self._pos
1779 try:
1780 _call_status = self._SPACE()
1781 _result = _call_status.result
1782 _error = self._combine_errors(_error, _call_status.error)
1783 _all1.append(_result)
1784 except BacktrackException as _exc:
1785 _error = self._combine_errors(_error, _exc.error)
1786 self._pos = _choice2
1787 break
1788 _result = _all1
1789 _result = self.__chars__('?')
1790 _all3 = []
1791 while 1:
1792 _choice4 = self._pos
1793 try:
1794 _call_status = self._IGNORE()
1795 _result = _call_status.result
1796 _error = self._combine_errors(_error, _call_status.error)
1797 _all3.append(_result)
1798 except BacktrackException as _exc:
1799 _error = self._combine_errors(_error, _exc.error)
1800 self._pos = _choice4
1801 break
1802 _result = _all3
1803 _result = (Nonterminal('maybe', [what]))
1804 break
1805 except BacktrackException as _exc:
1806 _error = self._combine_errors(_error, _exc.error)
1807 self._pos = _choice0
1808 _choice5 = self._pos
1809 try:
1810 _call_status = self._enclosed()
1811 _result = _call_status.result
1812 _error = self._combine_errors(_error, _call_status.error)
1813 what = _result
1814 _all6 = []
1815 while 1:
1816 _choice7 = self._pos
1817 try:
1818 _call_status = self._SPACE()
1819 _result = _call_status.result
1820 _error = self._combine_errors(_error, _call_status.error)
1821 _all6.append(_result)
1822 except BacktrackException as _exc:
1823 _error = self._combine_errors(_error, _exc.error)
1824 self._pos = _choice7
1825 break
1826 _result = _all6
1827 while 1:
1828 _choice8 = self._pos
1829 try:
1830 _result = self.__chars__('*')
1831 break
1832 except BacktrackException as _exc:
1833 _error = self._combine_errors(_error, _exc.error)
1834 self._pos = _choice8
1835 _choice9 = self._pos
1836 try:
1837 _result = self.__chars__('+')
1838 break
1839 except BacktrackException as _exc:
1840 _error = self._combine_errors(_error, _exc.error)
1841 self._pos = _choice9
1842 raise BacktrackException(_error)
1843 _result = self.__chars__('+')
1844 break
1845 repetition = _result
1846 _all10 = []
1847 while 1:
1848 _choice11 = self._pos
1849 try:
1850 _call_status = self._IGNORE()
1851 _result = _call_status.result
1852 _error = self._combine_errors(_error, _call_status.error)
1853 _all10.append(_result)
1854 except BacktrackException as _exc:
1855 _error = self._combine_errors(_error, _exc.error)
1856 self._pos = _choice11
1857 break
1858 _result = _all10
1859 _result = (Nonterminal('repetition', [repetition, what]))
1860 break
1861 except BacktrackException as _exc:
1862 _error = self._combine_errors(_error, _exc.error)
1863 self._pos = _choice5
1864 raise BacktrackException(_error)
1865 _call_status = self._enclosed()
1866 _result = _call_status.result
1867 _error = self._combine_errors(_error, _call_status.error)
1868 what = _result
1869 _all12 = []
1870 while 1:
1871 _choice13 = self._pos
1872 try:
1873 _call_status = self._SPACE()
1874 _result = _call_status.result
1875 _error = self._combine_errors(_error, _call_status.error)
1876 _all12.append(_result)
1877 except BacktrackException as _exc:
1878 _error = self._combine_errors(_error, _exc.error)
1879 self._pos = _choice13
1880 break
1881 _result = _all12
1882 while 1:
1883 _choice14 = self._pos
1884 try:
1885 _result = self.__chars__('*')
1886 break
1887 except BacktrackException as _exc:
1888 _error = self._combine_errors(_error, _exc.error)
1889 self._pos = _choice14
1890 _choice15 = self._pos
1891 try:
1892 _result = self.__chars__('+')
1893 break
1894 except BacktrackException as _exc:
1895 _error = self._combine_errors(_error, _exc.error)
1896 self._pos = _choice15
1897 raise BacktrackException(_error)
1898 _result = self.__chars__('+')
1899 break
1900 repetition = _result
1901 _all16 = []
1902 while 1:
1903 _choice17 = self._pos
1904 try:
1905 _call_status = self._IGNORE()
1906 _result = _call_status.result
1907 _error = self._combine_errors(_error, _call_status.error)
1908 _all16.append(_result)
1909 except BacktrackException as _exc:
1910 _error = self._combine_errors(_error, _exc.error)
1911 self._pos = _choice17
1912 break
1913 _result = _all16
1914 _result = (Nonterminal('repetition', [repetition, what]))
1915 break
1916 if _status.status == _status.LEFTRECURSION:
1917 if _status.result is not None:
1918 if _status.pos >= self._pos:
1919 _status.status = _status.NORMAL
1920 self._pos = _status.pos
1921 return _status
1922 _status.pos = self._pos
1923 _status.status = _status.SOMESOLUTIONS
1924 _status.result = _result
1925 _status.error = _error
1926 self._pos = _startingpos
1927 return self._repetition()
1928 _status.status = _status.NORMAL
1929 _status.pos = self._pos
1930 _status.result = _result
1931 _status.error = _error
1932 return _status
1933 except BacktrackException as _exc:
1934 _status.pos = -1
1935 _status.result = None
1936 _error = self._combine_errors(_error, _exc.error)
1937 _status.error = _error
1938 _status.status = _status.ERROR
1939 raise BacktrackException(_error)
1940 def negation(self):
1941 return self._negation().result
1942 def _negation(self):
1943 _key = self._pos
1944 _status = self._dict_negation.get(_key, None)
1945 if _status is None:
1946 _status = self._dict_negation[_key] = Status()
1947 else:
1948 _statusstatus = _status.status
1949 if _statusstatus == _status.NORMAL:
1950 self._pos = _status.pos
1951 return _status
1952 elif _statusstatus == _status.ERROR:
1953 raise BacktrackException(_status.error)
1954 elif (_statusstatus == _status.INPROGRESS or
1955 _statusstatus == _status.LEFTRECURSION):
1956 _status.status = _status.LEFTRECURSION
1957 if _status.result is not None:
1958 self._pos = _status.pos
1959 return _status
1960 else:
1961 raise BacktrackException(None)
1962 elif _statusstatus == _status.SOMESOLUTIONS:
1963 _status.status = _status.INPROGRESS
1964 _startingpos = self._pos
1965 try:
1966 _result = None
1967 _error = None
1968 while 1:
1969 _choice0 = self._pos
1970 try:
1971 _result = self.__chars__('!')
1972 _all1 = []
1973 while 1:
1974 _choice2 = self._pos
1975 try:
1976 _call_status = self._SPACE()
1977 _result = _call_status.result
1978 _error = _call_status.error
1979 _all1.append(_result)
1980 except BacktrackException as _exc:
1981 _error = self._combine_errors(_error, _exc.error)
1982 self._pos = _choice2
1983 break
1984 _result = _all1
1985 _call_status = self._negation()
1986 _result = _call_status.result
1987 _error = self._combine_errors(_error, _call_status.error)
1988 what = _result
1989 _all3 = []
1990 while 1:
1991 _choice4 = self._pos
1992 try:
1993 _call_status = self._IGNORE()
1994 _result = _call_status.result
1995 _error = self._combine_errors(_error, _call_status.error)
1996 _all3.append(_result)
1997 except BacktrackException as _exc:
1998 _error = self._combine_errors(_error, _exc.error)
1999 self._pos = _choice4
2000 break
2001 _result = _all3
2002 _result = (Nonterminal('negation', [what]))
2003 break
2004 except BacktrackException as _exc:
2005 _error = self._combine_errors(_error, _exc.error)
2006 self._pos = _choice0
2007 _choice5 = self._pos
2008 try:
2009 _call_status = self._enclosed()
2010 _result = _call_status.result
2011 _error = self._combine_errors(_error, _call_status.error)
2012 break
2013 except BacktrackException as _exc:
2014 _error = self._combine_errors(_error, _exc.error)
2015 self._pos = _choice5
2016 raise BacktrackException(_error)
2017 _call_status = self._enclosed()
2018 _result = _call_status.result
2019 _error = self._combine_errors(_error, _call_status.error)
2020 break
2021 if _status.status == _status.LEFTRECURSION:
2022 if _status.result is not None:
2023 if _status.pos >= self._pos:
2024 _status.status = _status.NORMAL
2025 self._pos = _status.pos
2026 return _status
2027 _status.pos = self._pos
2028 _status.status = _status.SOMESOLUTIONS
2029 _status.result = _result
2030 _status.error = _error
2031 self._pos = _startingpos
2032 return self._negation()
2033 _status.status = _status.NORMAL
2034 _status.pos = self._pos
2035 _status.result = _result
2036 _status.error = _error
2037 return _status
2038 except BacktrackException as _exc:
2039 _status.pos = -1
2040 _status.result = None
2041 _error = self._combine_errors(_error, _exc.error)
2042 _status.error = _error
2043 _status.status = _status.ERROR
2044 raise BacktrackException(_error)
2045 def enclosed(self):
2046 return self._enclosed().result
2047 def _enclosed(self):
2048 _key = self._pos
2049 _status = self._dict_enclosed.get(_key, None)
2050 if _status is None:
2051 _status = self._dict_enclosed[_key] = Status()
2052 else:
2053 _statusstatus = _status.status
2054 if _statusstatus == _status.NORMAL:
2055 self._pos = _status.pos
2056 return _status
2057 elif _statusstatus == _status.ERROR:
2058 raise BacktrackException(_status.error)
2059 elif (_statusstatus == _status.INPROGRESS or
2060 _statusstatus == _status.LEFTRECURSION):
2061 _status.status = _status.LEFTRECURSION
2062 if _status.result is not None:
2063 self._pos = _status.pos
2064 return _status
2065 else:
2066 raise BacktrackException(None)
2067 elif _statusstatus == _status.SOMESOLUTIONS:
2068 _status.status = _status.INPROGRESS
2069 _startingpos = self._pos
2070 try:
2071 _result = None
2072 _error = None
2073 while 1:
2074 _choice0 = self._pos
2075 try:
2076 _result = self.__chars__('<')
2077 _all1 = []
2078 while 1:
2079 _choice2 = self._pos
2080 try:
2081 _call_status = self._IGNORE()
2082 _result = _call_status.result
2083 _error = _call_status.error
2084 _all1.append(_result)
2085 except BacktrackException as _exc:
2086 _error = self._combine_errors(_error, _exc.error)
2087 self._pos = _choice2
2088 break
2089 _result = _all1
2090 _call_status = self._primary()
2091 _result = _call_status.result
2092 _error = self._combine_errors(_error, _call_status.error)
2093 what = _result
2094 _all3 = []
2095 while 1:
2096 _choice4 = self._pos
2097 try:
2098 _call_status = self._IGNORE()
2099 _result = _call_status.result
2100 _error = self._combine_errors(_error, _call_status.error)
2101 _all3.append(_result)
2102 except BacktrackException as _exc:
2103 _error = self._combine_errors(_error, _exc.error)
2104 self._pos = _choice4
2105 break
2106 _result = _all3
2107 _result = self.__chars__('>')
2108 _all5 = []
2109 while 1:
2110 _choice6 = self._pos
2111 try:
2112 _call_status = self._IGNORE()
2113 _result = _call_status.result
2114 _error = self._combine_errors(_error, _call_status.error)
2115 _all5.append(_result)
2116 except BacktrackException as _exc:
2117 _error = self._combine_errors(_error, _exc.error)
2118 self._pos = _choice6
2119 break
2120 _result = _all5
2121 _result = (Nonterminal('exclusive', [what]))
2122 break
2123 except BacktrackException as _exc:
2124 _error = self._combine_errors(_error, _exc.error)
2125 self._pos = _choice0
2126 _choice7 = self._pos
2127 try:
2128 _result = self.__chars__('[')
2129 _all8 = []
2130 while 1:
2131 _choice9 = self._pos
2132 try:
2133 _call_status = self._IGNORE()
2134 _result = _call_status.result
2135 _error = self._combine_errors(_error, _call_status.error)
2136 _all8.append(_result)
2137 except BacktrackException as _exc:
2138 _error = self._combine_errors(_error, _exc.error)
2139 self._pos = _choice9
2140 break
2141 _result = _all8
2142 _call_status = self._or_()
2143 _result = _call_status.result
2144 _error = self._combine_errors(_error, _call_status.error)
2145 what = _result
2146 _all10 = []
2147 while 1:
2148 _choice11 = self._pos
2149 try:
2150 _call_status = self._IGNORE()
2151 _result = _call_status.result
2152 _error = self._combine_errors(_error, _call_status.error)
2153 _all10.append(_result)
2154 except BacktrackException as _exc:
2155 _error = self._combine_errors(_error, _exc.error)
2156 self._pos = _choice11
2157 break
2158 _result = _all10
2159 _result = self.__chars__(']')
2160 _all12 = []
2161 while 1:
2162 _choice13 = self._pos
2163 try:
2164 _call_status = self._IGNORE()
2165 _result = _call_status.result
2166 _error = self._combine_errors(_error, _call_status.error)
2167 _all12.append(_result)
2168 except BacktrackException as _exc:
2169 _error = self._combine_errors(_error, _exc.error)
2170 self._pos = _choice13
2171 break
2172 _result = _all12
2173 _result = (Nonterminal('ignore', [what]))
2174 break
2175 except BacktrackException as _exc:
2176 _error = self._combine_errors(_error, _exc.error)
2177 self._pos = _choice7
2178 _choice14 = self._pos
2179 try:
2180 _before_discard15 = _result
2181 _result = self.__chars__('(')
2182 _all16 = []
2183 while 1:
2184 _choice17 = self._pos
2185 try:
2186 _call_status = self._IGNORE()
2187 _result = _call_status.result
2188 _error = self._combine_errors(_error, _call_status.error)
2189 _all16.append(_result)
2190 except BacktrackException as _exc:
2191 _error = self._combine_errors(_error, _exc.error)
2192 self._pos = _choice17
2193 break
2194 _result = _all16
2195 _result = _before_discard15
2196 _call_status = self._or_()
2197 _result = _call_status.result
2198 _error = self._combine_errors(_error, _call_status.error)
2199 _before_discard18 = _result
2200 _result = self.__chars__(')')
2201 _all19 = []
2202 while 1:
2203 _choice20 = self._pos
2204 try:
2205 _call_status = self._IGNORE()
2206 _result = _call_status.result
2207 _error = self._combine_errors(_error, _call_status.error)
2208 _all19.append(_result)
2209 except BacktrackException as _exc:
2210 _error = self._combine_errors(_error, _exc.error)
2211 self._pos = _choice20
2212 break
2213 _result = _all19
2214 _result = _before_discard18
2215 break
2216 except BacktrackException as _exc:
2217 _error = self._combine_errors(_error, _exc.error)
2218 self._pos = _choice14
2219 _choice21 = self._pos
2220 try:
2221 _call_status = self._primary()
2222 _result = _call_status.result
2223 _error = self._combine_errors(_error, _call_status.error)
2224 break
2225 except BacktrackException as _exc:
2226 _error = self._combine_errors(_error, _exc.error)
2227 self._pos = _choice21
2228 raise BacktrackException(_error)
2229 _call_status = self._primary()
2230 _result = _call_status.result
2231 _error = self._combine_errors(_error, _call_status.error)
2232 break
2233 if _status.status == _status.LEFTRECURSION:
2234 if _status.result is not None:
2235 if _status.pos >= self._pos:
2236 _status.status = _status.NORMAL
2237 self._pos = _status.pos
2238 return _status
2239 _status.pos = self._pos
2240 _status.status = _status.SOMESOLUTIONS
2241 _status.result = _result
2242 _status.error = _error
2243 self._pos = _startingpos
2244 return self._enclosed()
2245 _status.status = _status.NORMAL
2246 _status.pos = self._pos
2247 _status.result = _result
2248 _status.error = _error
2249 return _status
2250 except BacktrackException as _exc:
2251 _status.pos = -1
2252 _status.result = None
2253 _error = self._combine_errors(_error, _exc.error)
2254 _status.error = _error
2255 _status.status = _status.ERROR
2256 raise BacktrackException(_error)
2257 def primary(self):
2258 return self._primary().result
2259 def _primary(self):
2260 _key = self._pos
2261 _status = self._dict_primary.get(_key, None)
2262 if _status is None:
2263 _status = self._dict_primary[_key] = Status()
2264 else:
2265 _statusstatus = _status.status
2266 if _statusstatus == _status.NORMAL:
2267 self._pos = _status.pos
2268 return _status
2269 elif _statusstatus == _status.ERROR:
2270 raise BacktrackException(_status.error)
2271 elif (_statusstatus == _status.INPROGRESS or
2272 _statusstatus == _status.LEFTRECURSION):
2273 _status.status = _status.LEFTRECURSION
2274 if _status.result is not None:
2275 self._pos = _status.pos
2276 return _status
2277 else:
2278 raise BacktrackException(None)
2279 elif _statusstatus == _status.SOMESOLUTIONS:
2280 _status.status = _status.INPROGRESS
2281 _startingpos = self._pos
2282 try:
2283 _result = None
2284 _error = None
2285 while 1:
2286 _choice0 = self._pos
2287 try:
2288 _call_status = self._call()
2289 _result = _call_status.result
2290 _error = _call_status.error
2291 break
2292 except BacktrackException as _exc:
2293 _error = self._combine_errors(_error, _exc.error)
2294 self._pos = _choice0
2295 _choice1 = self._pos
2296 try:
2297 _call_status = self._REGEX()
2298 _result = _call_status.result
2299 _error = self._combine_errors(_error, _call_status.error)
2300 _before_discard2 = _result
2301 _all3 = []
2302 while 1:
2303 _choice4 = self._pos
2304 try:
2305 _call_status = self._IGNORE()
2306 _result = _call_status.result
2307 _error = self._combine_errors(_error, _call_status.error)
2308 _all3.append(_result)
2309 except BacktrackException as _exc:
2310 _error = self._combine_errors(_error, _exc.error)
2311 self._pos = _choice4
2312 break
2313 _result = _all3
2314 _result = _before_discard2
2315 break
2316 except BacktrackException as _exc:
2317 _error = self._combine_errors(_error, _exc.error)
2318 self._pos = _choice1
2319 _choice5 = self._pos
2320 try:
2321 _call_status = self._QUOTE()
2322 _result = _call_status.result
2323 _error = self._combine_errors(_error, _call_status.error)
2324 _before_discard6 = _result
2325 _all7 = []
2326 while 1:
2327 _choice8 = self._pos
2328 try:
2329 _call_status = self._IGNORE()
2330 _result = _call_status.result
2331 _error = self._combine_errors(_error, _call_status.error)
2332 _all7.append(_result)
2333 except BacktrackException as _exc:
2334 _error = self._combine_errors(_error, _exc.error)
2335 self._pos = _choice8
2336 break
2337 _result = _all7
2338 _result = _before_discard6
2339 break
2340 except BacktrackException as _exc:
2341 _error = self._combine_errors(_error, _exc.error)
2342 self._pos = _choice5
2343 raise BacktrackException(_error)
2344 _call_status = self._QUOTE()
2345 _result = _call_status.result
2346 _error = self._combine_errors(_error, _call_status.error)
2347 _before_discard9 = _result
2348 _all10 = []
2349 while 1:
2350 _choice11 = self._pos
2351 try:
2352 _call_status = self._IGNORE()
2353 _result = _call_status.result
2354 _error = self._combine_errors(_error, _call_status.error)
2355 _all10.append(_result)
2356 except BacktrackException as _exc:
2357 _error = self._combine_errors(_error, _exc.error)
2358 self._pos = _choice11
2359 break
2360 _result = _all10
2361 _result = _before_discard9
2362 break
2363 if _status.status == _status.LEFTRECURSION:
2364 if _status.result is not None:
2365 if _status.pos >= self._pos:
2366 _status.status = _status.NORMAL
2367 self._pos = _status.pos
2368 return _status
2369 _status.pos = self._pos
2370 _status.status = _status.SOMESOLUTIONS
2371 _status.result = _result
2372 _status.error = _error
2373 self._pos = _startingpos
2374 return self._primary()
2375 _status.status = _status.NORMAL
2376 _status.pos = self._pos
2377 _status.result = _result
2378 _status.error = _error
2379 return _status
2380 except BacktrackException as _exc:
2381 _status.pos = -1
2382 _status.result = None
2383 _error = self._combine_errors(_error, _exc.error)
2384 _status.error = _error
2385 _status.status = _status.ERROR
2386 raise BacktrackException(_error)
2387 def call(self):
2388 return self._call().result
2389 def _call(self):
2390 _key = self._pos
2391 _status = self._dict_call.get(_key, None)
2392 if _status is None:
2393 _status = self._dict_call[_key] = Status()
2394 else:
2395 _statusstatus = _status.status
2396 if _statusstatus == _status.NORMAL:
2397 self._pos = _status.pos
2398 return _status
2399 elif _statusstatus == _status.ERROR:
2400 raise BacktrackException(_status.error)
2401 elif (_statusstatus == _status.INPROGRESS or
2402 _statusstatus == _status.LEFTRECURSION):
2403 _status.status = _status.LEFTRECURSION
2404 if _status.result is not None:
2405 self._pos = _status.pos
2406 return _status
2407 else:
2408 raise BacktrackException(None)
2409 elif _statusstatus == _status.SOMESOLUTIONS:
2410 _status.status = _status.INPROGRESS
2411 _startingpos = self._pos
2412 try:
2413 _result = None
2414 _error = None
2415 _call_status = self._NAME()
2416 _result = _call_status.result
2417 _error = _call_status.error
2418 x = _result
2419 _call_status = self._arguments()
2420 _result = _call_status.result
2421 _error = self._combine_errors(_error, _call_status.error)
2422 args = _result
2423 _all0 = []
2424 while 1:
2425 _choice1 = self._pos
2426 try:
2427 _call_status = self._IGNORE()
2428 _result = _call_status.result
2429 _error = self._combine_errors(_error, _call_status.error)
2430 _all0.append(_result)
2431 except BacktrackException as _exc:
2432 _error = self._combine_errors(_error, _exc.error)
2433 self._pos = _choice1
2434 break
2435 _result = _all0
2436 _result = (Nonterminal("call", [x, args]))
2437 if _status.status == _status.LEFTRECURSION:
2438 if _status.result is not None:
2439 if _status.pos >= self._pos:
2440 _status.status = _status.NORMAL
2441 self._pos = _status.pos
2442 return _status
2443 _status.pos = self._pos
2444 _status.status = _status.SOMESOLUTIONS
2445 _status.result = _result
2446 _status.error = _error
2447 self._pos = _startingpos
2448 return self._call()
2449 _status.status = _status.NORMAL
2450 _status.pos = self._pos
2451 _status.result = _result
2452 _status.error = _error
2453 return _status
2454 except BacktrackException as _exc:
2455 _status.pos = -1
2456 _status.result = None
2457 _error = self._combine_errors(_error, _exc.error)
2458 _status.error = _error
2459 _status.status = _status.ERROR
2460 raise BacktrackException(_error)
2461 def arguments(self):
2462 return self._arguments().result
2463 def _arguments(self):
2464 _key = self._pos
2465 _status = self._dict_arguments.get(_key, None)
2466 if _status is None:
2467 _status = self._dict_arguments[_key] = Status()
2468 else:
2469 _statusstatus = _status.status
2470 if _statusstatus == _status.NORMAL:
2471 self._pos = _status.pos
2472 return _status
2473 elif _statusstatus == _status.ERROR:
2474 raise BacktrackException(_status.error)
2475 elif (_statusstatus == _status.INPROGRESS or
2476 _statusstatus == _status.LEFTRECURSION):
2477 _status.status = _status.LEFTRECURSION
2478 if _status.result is not None:
2479 self._pos = _status.pos
2480 return _status
2481 else:
2482 raise BacktrackException(None)
2483 elif _statusstatus == _status.SOMESOLUTIONS:
2484 _status.status = _status.INPROGRESS
2485 _startingpos = self._pos
2486 try:
2487 _result = None
2488 _error = None
2489 while 1:
2490 _choice0 = self._pos
2491 try:
2492 _result = self.__chars__('(')
2493 _all1 = []
2494 while 1:
2495 _choice2 = self._pos
2496 try:
2497 _call_status = self._IGNORE()
2498 _result = _call_status.result
2499 _error = _call_status.error
2500 _all1.append(_result)
2501 except BacktrackException as _exc:
2502 _error = self._combine_errors(_error, _exc.error)
2503 self._pos = _choice2
2504 break
2505 _result = _all1
2506 _all3 = []
2507 while 1:
2508 _choice4 = self._pos
2509 try:
2510 _call_status = self._PYTHONCODE()
2511 _result = _call_status.result
2512 _error = self._combine_errors(_error, _call_status.error)
2513 _before_discard5 = _result
2514 _all6 = []
2515 while 1:
2516 _choice7 = self._pos
2517 try:
2518 _call_status = self._IGNORE()
2519 _result = _call_status.result
2520 _error = self._combine_errors(_error, _call_status.error)
2521 _all6.append(_result)
2522 except BacktrackException as _exc:
2523 _error = self._combine_errors(_error, _exc.error)
2524 self._pos = _choice7
2525 break
2526 _result = _all6
2527 _result = self.__chars__(',')
2528 _all8 = []
2529 while 1:
2530 _choice9 = self._pos
2531 try:
2532 _call_status = self._IGNORE()
2533 _result = _call_status.result
2534 _error = self._combine_errors(_error, _call_status.error)
2535 _all8.append(_result)
2536 except BacktrackException as _exc:
2537 _error = self._combine_errors(_error, _exc.error)
2538 self._pos = _choice9
2539 break
2540 _result = _all8
2541 _result = _before_discard5
2542 _all3.append(_result)
2543 except BacktrackException as _exc:
2544 _error = self._combine_errors(_error, _exc.error)
2545 self._pos = _choice4
2546 break
2547 _result = _all3
2548 args = _result
2549 _call_status = self._PYTHONCODE()
2550 _result = _call_status.result
2551 _error = self._combine_errors(_error, _call_status.error)
2552 last = _result
2553 _result = self.__chars__(')')
2554 _all10 = []
2555 while 1:
2556 _choice11 = self._pos
2557 try:
2558 _call_status = self._IGNORE()
2559 _result = _call_status.result
2560 _error = self._combine_errors(_error, _call_status.error)
2561 _all10.append(_result)
2562 except BacktrackException as _exc:
2563 _error = self._combine_errors(_error, _exc.error)
2564 self._pos = _choice11
2565 break
2566 _result = _all10
2567 _result = (Nonterminal("args", args + [last]))
2568 break
2569 except BacktrackException as _exc:
2570 _error = self._combine_errors(_error, _exc.error)
2571 self._pos = _choice0
2572 _choice12 = self._pos
2573 try:
2574 _result = (Nonterminal("args", []))
2575 break
2576 except BacktrackException as _exc:
2577 _error = self._combine_errors(_error, _exc.error)
2578 self._pos = _choice12
2579 raise BacktrackException(_error)
2580 _result = (Nonterminal("args", []))
2581 break
2582 if _status.status == _status.LEFTRECURSION:
2583 if _status.result is not None:
2584 if _status.pos >= self._pos:
2585 _status.status = _status.NORMAL
2586 self._pos = _status.pos
2587 return _status
2588 _status.pos = self._pos
2589 _status.status = _status.SOMESOLUTIONS
2590 _status.result = _result
2591 _status.error = _error
2592 self._pos = _startingpos
2593 return self._arguments()
2594 _status.status = _status.NORMAL
2595 _status.pos = self._pos
2596 _status.result = _result
2597 _status.error = _error
2598 return _status
2599 except BacktrackException as _exc:
2600 _status.pos = -1
2601 _status.result = None
2602 _error = self._combine_errors(_error, _exc.error)
2603 _status.error = _error
2604 _status.status = _status.ERROR
2605 raise BacktrackException(_error)
2606 def __init__(self, inputstream):
2607 self._dict_NAME = {}
2608 self._dict_SPACE = {}
2609 self._dict_COMMENT = {}
2610 self._dict_IGNORE = {}
2611 self._dict_newline = {}
2612 self._dict_REGEX = {}
2613 self._dict_QUOTE = {}
2614 self._dict_PYTHONCODE = {}
2615 self._dict_EOF = {}
2616 self._dict_file = {}
2617 self._dict_list = {}
2618 self._dict_production = {}
2619 self._dict_productionargs = {}
2620 self._dict_or_ = {}
2621 self._dict_commands = {}
2622 self._dict_command = {}
2623 self._dict_simplecommand = {}
2624 self._dict_return_ = {}
2625 self._dict_if_ = {}
2626 self._dict_choose = {}
2627 self._dict_commandchain = {}
2628 self._dict_named_command = {}
2629 self._dict_repetition = {}
2630 self._dict_negation = {}
2631 self._dict_enclosed = {}
2632 self._dict_primary = {}
2633 self._dict_call = {}
2634 self._dict_arguments = {}
2635 self._pos = 0
2636 self._inputstream = inputstream
2637 def _regex299149370(self):
2638 _choice13 = self._pos
2639 _runner = self._Runner(self._inputstream, self._pos)
2640 _i = _runner.recognize_299149370(self._pos)
2641 if _runner.last_matched_state == -1:
2642 self._pos = _choice13
2643 raise BacktrackException
2644 _upto = _runner.last_matched_index + 1
2645 _pos = self._pos
2646 assert _pos >= 0
2647 assert _upto >= 0
2648 _result = self._inputstream[_pos: _upto]
2649 self._pos = _upto
2650 return _result
2651 def _regex1006631623(self):
2652 _choice14 = self._pos
2653 _runner = self._Runner(self._inputstream, self._pos)
2654 _i = _runner.recognize_1006631623(self._pos)
2655 if _runner.last_matched_state == -1:
2656 self._pos = _choice14
2657 raise BacktrackException
2658 _upto = _runner.last_matched_index + 1
2659 _pos = self._pos
2660 assert _pos >= 0
2661 assert _upto >= 0
2662 _result = self._inputstream[_pos: _upto]
2663 self._pos = _upto
2664 return _result
2665 def _regex528667127(self):
2666 _choice15 = self._pos
2667 _runner = self._Runner(self._inputstream, self._pos)
2668 _i = _runner.recognize_528667127(self._pos)
2669 if _runner.last_matched_state == -1:
2670 self._pos = _choice15
2671 raise BacktrackException
2672 _upto = _runner.last_matched_index + 1
2673 _pos = self._pos
2674 assert _pos >= 0
2675 assert _upto >= 0
2676 _result = self._inputstream[_pos: _upto]
2677 self._pos = _upto
2678 return _result
2679 def _regex291086639(self):
2680 _choice16 = self._pos
2681 _runner = self._Runner(self._inputstream, self._pos)
2682 _i = _runner.recognize_291086639(self._pos)
2683 if _runner.last_matched_state == -1:
2684 self._pos = _choice16
2685 raise BacktrackException
2686 _upto = _runner.last_matched_index + 1
2687 _pos = self._pos
2688 assert _pos >= 0
2689 assert _upto >= 0
2690 _result = self._inputstream[_pos: _upto]
2691 self._pos = _upto
2692 return _result
2693 def _regex1074651696(self):
2694 _choice17 = self._pos
2695 _runner = self._Runner(self._inputstream, self._pos)
2696 _i = _runner.recognize_1074651696(self._pos)
2697 if _runner.last_matched_state == -1:
2698 self._pos = _choice17
2699 raise BacktrackException
2700 _upto = _runner.last_matched_index + 1
2701 _pos = self._pos
2702 assert _pos >= 0
2703 assert _upto >= 0
2704 _result = self._inputstream[_pos: _upto]
2705 self._pos = _upto
2706 return _result
2707 def _regex1124192327(self):
2708 _choice18 = self._pos
2709 _runner = self._Runner(self._inputstream, self._pos)
2710 _i = _runner.recognize_1124192327(self._pos)
2711 if _runner.last_matched_state == -1:
2712 self._pos = _choice18
2713 raise BacktrackException
2714 _upto = _runner.last_matched_index + 1
2715 _pos = self._pos
2716 assert _pos >= 0
2717 assert _upto >= 0
2718 _result = self._inputstream[_pos: _upto]
2719 self._pos = _upto
2720 return _result
2721 def _regex1979538501(self):
2722 _choice19 = self._pos
2723 _runner = self._Runner(self._inputstream, self._pos)
2724 _i = _runner.recognize_1979538501(self._pos)
2725 if _runner.last_matched_state == -1:
2726 self._pos = _choice19
2727 raise BacktrackException
2728 _upto = _runner.last_matched_index + 1
2729 _pos = self._pos
2730 assert _pos >= 0
2731 assert _upto >= 0
2732 _result = self._inputstream[_pos: _upto]
2733 self._pos = _upto
2734 return _result
2735 class _Runner(object):
2736 def __init__(self, text, pos):
2737 self.text = text
2738 self.pos = pos
2739 self.last_matched_state = -1
2740 self.last_matched_index = -1
2741 self.state = -1
2742 def recognize_299149370(runner, i):
2743 #auto-generated code, don't edit
2744 assert i >= 0
2745 input = runner.text
2746 state = 0
2747 while 1:
2748 if state == 0:
2749 runner.last_matched_index = i - 1
2750 runner.last_matched_state = state
2751 try:
2752 char = input[i]
2753 i += 1
2754 except IndexError:
2755 runner.state = 0
2756 return i
2757 if char == '\n':
2758 state = 1
2759 elif char == ' ':
2760 state = 2
2761 else:
2762 break
2763 if state == 1:
2764 runner.last_matched_index = i - 1
2765 runner.last_matched_state = state
2766 try:
2767 char = input[i]
2768 i += 1
2769 except IndexError:
2770 runner.state = 1
2771 return i
2772 if char == '\n':
2773 state = 1
2774 continue
2775 elif char == ' ':
2776 state = 1
2777 continue
2778 else:
2779 break
2780 if state == 2:
2781 try:
2782 char = input[i]
2783 i += 1
2784 except IndexError:
2785 runner.state = 2
2786 return ~i
2787 if char == '\n':
2788 state = 1
2789 continue
2790 elif char == ' ':
2791 state = 2
2792 continue
2793 else:
2794 break
2795 runner.last_matched_state = state
2796 runner.last_matched_index = i - 1
2797 runner.state = state
2798 if i == len(input):
2799 return i
2800 else:
2801 return ~i
2802 break
2803 runner.state = state
2804 return ~i
2805 def recognize_1006631623(runner, i):
2806 #auto-generated code, don't edit
2807 assert i >= 0
2808 input = runner.text
2809 state = 0
2810 while 1:
2811 if state == 0:
2812 try:
2813 char = input[i]
2814 i += 1
2815 except IndexError:
2816 runner.state = 0
2817 return ~i
2818 if char == '`':
2819 state = 3
2820 else:
2821 break
2822 if state == 2:
2823 try:
2824 char = input[i]
2825 i += 1
2826 except IndexError:
2827 runner.state = 2
2828 return ~i
2829 if '\x00' <= char <= '\xff':
2830 state = 3
2831 else:
2832 break
2833 if state == 3:
2834 try:
2835 char = input[i]
2836 i += 1
2837 except IndexError:
2838 runner.state = 3
2839 return ~i
2840 if char == '`':
2841 state = 1
2842 elif char == '\\':
2843 state = 2
2844 continue
2845 elif ']' <= char <= '_':
2846 state = 3
2847 continue
2848 elif '\x00' <= char <= '[':
2849 state = 3
2850 continue
2851 elif 'a' <= char <= '\xff':
2852 state = 3
2853 continue
2854 else:
2855 break
2856 runner.last_matched_state = state
2857 runner.last_matched_index = i - 1
2858 runner.state = state
2859 if i == len(input):
2860 return i
2861 else:
2862 return ~i
2863 break
2864 runner.state = state
2865 return ~i
2866 def recognize_528667127(runner, i):
2867 #auto-generated code, don't edit
2868 assert i >= 0
2869 input = runner.text
2870 state = 0
2871 while 1:
2872 if state == 0:
2873 try:
2874 char = input[i]
2875 i += 1
2876 except IndexError:
2877 runner.state = 0
2878 return ~i
2879 if char == ' ':
2880 state = 0
2881 continue
2882 elif char == '#':
2883 state = 2
2884 else:
2885 break
2886 if state == 1:
2887 runner.last_matched_index = i - 1
2888 runner.last_matched_state = state
2889 try:
2890 char = input[i]
2891 i += 1
2892 except IndexError:
2893 runner.state = 1
2894 return i
2895 if char == ' ':
2896 state = 0
2897 continue
2898 elif char == '#':
2899 state = 2
2900 else:
2901 break
2902 if state == 2:
2903 try:
2904 char = input[i]
2905 i += 1
2906 except IndexError:
2907 runner.state = 2
2908 return ~i
2909 if char == '\n':
2910 state = 1
2911 continue
2912 elif '\x00' <= char <= '\t':
2913 state = 2
2914 continue
2915 elif '\x0b' <= char <= '\xff':
2916 state = 2
2917 continue
2918 else:
2919 break
2920 runner.last_matched_state = state
2921 runner.last_matched_index = i - 1
2922 runner.state = state
2923 if i == len(input):
2924 return i
2925 else:
2926 return ~i
2927 break
2928 runner.state = state
2929 return ~i
2930 def recognize_291086639(runner, i):
2931 #auto-generated code, don't edit
2932 assert i >= 0
2933 input = runner.text
2934 state = 0
2935 while 1:
2936 if state == 0:
2937 try:
2938 char = input[i]
2939 i += 1
2940 except IndexError:
2941 runner.state = 0
2942 return ~i
2943 if char == '{':
2944 state = 2
2945 else:
2946 break
2947 if state == 2:
2948 try:
2949 char = input[i]
2950 i += 1
2951 except IndexError:
2952 runner.state = 2
2953 return ~i
2954 if char == '}':
2955 state = 1
2956 elif '\x00' <= char <= '\t':
2957 state = 2
2958 continue
2959 elif '\x0b' <= char <= '|':
2960 state = 2
2961 continue
2962 elif '~' <= char <= '\xff':
2963 state = 2
2964 continue
2965 else:
2966 break
2967 runner.last_matched_state = state
2968 runner.last_matched_index = i - 1
2969 runner.state = state
2970 if i == len(input):
2971 return i
2972 else:
2973 return ~i
2974 break
2975 runner.state = state
2976 return ~i
2977 def recognize_1074651696(runner, i):
2978 #auto-generated code, don't edit
2979 assert i >= 0
2980 input = runner.text
2981 state = 0
2982 while 1:
2983 if state == 0:
2984 try:
2985 char = input[i]
2986 i += 1
2987 except IndexError:
2988 runner.state = 0
2989 return ~i
2990 if char == '_':
2991 state = 1
2992 elif 'A' <= char <= 'Z':
2993 state = 1
2994 elif 'a' <= char <= 'z':
2995 state = 1
2996 else:
2997 break
2998 if state == 1:
2999 runner.last_matched_index = i - 1
3000 runner.last_matched_state = state
3001 try:
3002 char = input[i]
3003 i += 1
3004 except IndexError:
3005 runner.state = 1
3006 return i
3007 if char == '_':
3008 state = 1
3009 continue
3010 elif '0' <= char <= '9':
3011 state = 1
3012 continue
3013 elif 'A' <= char <= 'Z':
3014 state = 1
3015 continue
3016 elif 'a' <= char <= 'z':
3017 state = 1
3018 continue
3019 else:
3020 break
3021 runner.last_matched_state = state
3022 runner.last_matched_index = i - 1
3023 runner.state = state
3024 if i == len(input):
3025 return i
3026 else:
3027 return ~i
3028 break
3029 runner.state = state
3030 return ~i
3031 def recognize_1124192327(runner, i):
3032 #auto-generated code, don't edit
3033 assert i >= 0
3034 input = runner.text
3035 state = 0
3036 while 1:
3037 if state == 0:
3038 try:
3039 char = input[i]
3040 i += 1
3041 except IndexError:
3042 runner.state = 0
3043 return ~i
3044 if char == "'":
3045 state = 1
3046 else:
3047 break
3048 if state == 1:
3049 try:
3050 char = input[i]
3051 i += 1
3052 except IndexError:
3053 runner.state = 1
3054 return ~i
3055 if '\x00' <= char <= '&':
3056 state = 1
3057 continue
3058 elif '(' <= char <= '\xff':
3059 state = 1
3060 continue
3061 elif char == "'":
3062 state = 2
3063 else:
3064 break
3065 runner.last_matched_state = state
3066 runner.last_matched_index = i - 1
3067 runner.state = state
3068 if i == len(input):
3069 return i
3070 else:
3071 return ~i
3072 break
3073 runner.state = state
3074 return ~i
3075 def recognize_1979538501(runner, i):
3076 #auto-generated code, don't edit
3077 assert i >= 0
3078 input = runner.text
3079 state = 0
3080 while 1:
3081 if state == 0:
3082 try:
3083 char = input[i]
3084 i += 1
3085 except IndexError:
3086 runner.state = 0
3087 return ~i
3088 if char == '#':
3089 state = 1
3090 elif char == ' ':
3091 state = 2
3092 elif char == '\t':
3093 state = 2
3094 elif char == '\n':
3095 state = 2
3096 else:
3097 break
3098 if state == 1:
3099 try:
3100 char = input[i]
3101 i += 1
3102 except IndexError:
3103 runner.state = 1
3104 return ~i
3105 if '\x00' <= char <= '\t':
3106 state = 1
3107 continue
3108 elif '\x0b' <= char <= '\xff':
3109 state = 1
3110 continue
3111 elif char == '\n':
3112 state = 2
3113 else:
3114 break
3115 runner.last_matched_state = state
3116 runner.last_matched_index = i - 1
3117 runner.state = state
3118 if i == len(input):
3119 return i
3120 else:
3121 return ~i
3122 break
3123 runner.state = state
3124 return ~i
3125 class PyPackratSyntaxParser(PackratParser):
3126 def __init__(self, stream):
3127 self.init_parser(stream)
3128 forbidden = dict.fromkeys(("__weakref__ __doc__ "
3129 "__dict__ __module__").split())
3130 initthere = "__init__" in PyPackratSyntaxParser.__dict__
3131 for key, value in Parser.__dict__.iteritems():
3132 if key not in PyPackratSyntaxParser.__dict__ and key not in forbidden:
3133 setattr(PyPackratSyntaxParser, key, value)
3134 PyPackratSyntaxParser.init_parser = Parser.__init__.im_func