| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  | #!/usr/bin/env python3.8 | 
					
						
							| 
									
										
										
										
											2021-11-26 11:50:34 +01:00
										 |  |  | # @generated by pegen from metagrammar.gram | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | import ast | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  | import sys | 
					
						
							|  |  |  | import tokenize | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from typing import Any, Optional | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | from pegen.parser import memoize, memoize_left_rec, logger, Parser | 
					
						
							|  |  |  | from ast import literal_eval | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from pegen.grammar import ( | 
					
						
							|  |  |  |     Alt, | 
					
						
							|  |  |  |     Cut, | 
					
						
							| 
									
										
										
										
											2021-02-02 19:54:22 +00:00
										 |  |  |     Forced, | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |     Gather, | 
					
						
							|  |  |  |     Group, | 
					
						
							|  |  |  |     Item, | 
					
						
							|  |  |  |     Lookahead, | 
					
						
							|  |  |  |     LookaheadOrCut, | 
					
						
							|  |  |  |     MetaTuple, | 
					
						
							|  |  |  |     MetaList, | 
					
						
							|  |  |  |     NameLeaf, | 
					
						
							|  |  |  |     NamedItem, | 
					
						
							|  |  |  |     NamedItemList, | 
					
						
							|  |  |  |     NegativeLookahead, | 
					
						
							|  |  |  |     Opt, | 
					
						
							|  |  |  |     Plain, | 
					
						
							|  |  |  |     PositiveLookahead, | 
					
						
							|  |  |  |     Repeat0, | 
					
						
							|  |  |  |     Repeat1, | 
					
						
							|  |  |  |     Rhs, | 
					
						
							|  |  |  |     Rule, | 
					
						
							|  |  |  |     RuleList, | 
					
						
							|  |  |  |     RuleName, | 
					
						
							|  |  |  |     Grammar, | 
					
						
							|  |  |  |     StringLeaf, | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  | # Keywords and soft keywords are listed at the end of the parser definition. | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  | class GeneratedParser(Parser): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def start(self) -> Optional[Grammar]: | 
					
						
							|  |  |  |         # start: grammar $ | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (grammar := self.grammar()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_endmarker := self.expect('ENDMARKER')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							|  |  |  |             return grammar | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def grammar(self) -> Optional[Grammar]: | 
					
						
							|  |  |  |         # grammar: metas rules | rules | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (metas := self.metas()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (rules := self.rules()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Grammar ( rules , metas ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (rules := self.rules()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return Grammar ( rules , [] ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def metas(self) -> Optional[MetaList]: | 
					
						
							|  |  |  |         # metas: meta metas | meta | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (meta := self.meta()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (metas := self.metas()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return [meta] + metas | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (meta := self.meta()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return [meta] | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def meta(self) -> Optional[MetaTuple]: | 
					
						
							|  |  |  |         # meta: "@" NAME NEWLINE | "@" NAME NAME NEWLINE | "@" NAME STRING NEWLINE | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("@")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_newline := self.expect('NEWLINE')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							|  |  |  |             return ( name . string , None ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("@")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (a := self.name()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (b := self.name()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_newline := self.expect('NEWLINE')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							|  |  |  |             return ( a . string , b . string ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("@")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (string := self.string()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_newline := self.expect('NEWLINE')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							|  |  |  |             return ( name . string , literal_eval ( string . string ) ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def rules(self) -> Optional[RuleList]: | 
					
						
							|  |  |  |         # rules: rule rules | rule | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (rule := self.rule()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (rules := self.rules()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return [rule] + rules | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (rule := self.rule()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return [rule] | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def rule(self) -> Optional[Rule]: | 
					
						
							|  |  |  |         # rule: rulename memoflag? ":" alts NEWLINE INDENT more_alts DEDENT | rulename memoflag? ":" NEWLINE INDENT more_alts DEDENT | rulename memoflag? ":" alts NEWLINE | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (rulename := self.rulename()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (opt := self.memoflag(),) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect(":")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (alts := self.alts()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_newline := self.expect('NEWLINE')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_indent := self.expect('INDENT')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |             and | 
					
						
							|  |  |  |             (more_alts := self.more_alts()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_dedent := self.expect('DEDENT')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return Rule ( rulename [0] , rulename [1] , Rhs ( alts . alts + more_alts . alts ) , memo = opt ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (rulename := self.rulename()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (opt := self.memoflag(),) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect(":")) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_newline := self.expect('NEWLINE')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_indent := self.expect('INDENT')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |             and | 
					
						
							|  |  |  |             (more_alts := self.more_alts()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_dedent := self.expect('DEDENT')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return Rule ( rulename [0] , rulename [1] , more_alts , memo = opt ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (rulename := self.rulename()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (opt := self.memoflag(),) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect(":")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (alts := self.alts()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_newline := self.expect('NEWLINE')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return Rule ( rulename [0] , rulename [1] , alts , memo = opt ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def rulename(self) -> Optional[RuleName]: | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         # rulename: NAME annotation | NAME | 
					
						
							|  |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (annotation := self.annotation()) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return ( name . string , annotation ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return ( name . string , None ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def memoflag(self) -> Optional[str]: | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         # memoflag: '(' "memo" ')' | 
					
						
							|  |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect('(')) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (literal_1 := self.expect("memo")) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |             and | 
					
						
							|  |  |  |             (literal_2 := self.expect(')')) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return "memo" | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def alts(self) -> Optional[Rhs]: | 
					
						
							|  |  |  |         # alts: alt "|" alts | alt | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (alt := self.alt()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect("|")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (alts := self.alts()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return Rhs ( [alt] + alts . alts ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (alt := self.alt()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return Rhs ( [alt] ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def more_alts(self) -> Optional[Rhs]: | 
					
						
							|  |  |  |         # more_alts: "|" alts NEWLINE more_alts | "|" alts NEWLINE | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("|")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (alts := self.alts()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_newline := self.expect('NEWLINE')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |             and | 
					
						
							|  |  |  |             (more_alts := self.more_alts()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Rhs ( alts . alts + more_alts . alts ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("|")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (alts := self.alts()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (_newline := self.expect('NEWLINE')) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         ): | 
					
						
							|  |  |  |             return Rhs ( alts . alts ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def alt(self) -> Optional[Alt]: | 
					
						
							|  |  |  |         # alt: items '$' action | items '$' | items action | items | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (items := self.items()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect('$')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (action := self.action()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return Alt ( items + [NamedItem ( None , NameLeaf ( 'ENDMARKER' ) )] , action = action ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (items := self.items()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect('$')) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return Alt ( items + [NamedItem ( None , NameLeaf ( 'ENDMARKER' ) )] , action = None ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (items := self.items()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (action := self.action()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Alt ( items , action = action ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (items := self.items()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Alt ( items , action = None ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def items(self) -> Optional[NamedItemList]: | 
					
						
							|  |  |  |         # items: named_item items | named_item | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (named_item := self.named_item()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (items := self.items()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return [named_item] + items | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (named_item := self.named_item()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return [named_item] | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def named_item(self) -> Optional[NamedItem]: | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         # named_item: NAME annotation '=' ~ item | NAME '=' ~ item | item | forced_atom | lookahead | 
					
						
							|  |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-09-16 19:42:00 +01:00
										 |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (annotation := self.annotation()) | 
					
						
							| 
									
										
										
										
											2020-09-16 19:42:00 +01:00
										 |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (literal := self.expect('=')) | 
					
						
							| 
									
										
										
										
											2020-09-16 19:42:00 +01:00
										 |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (item := self.item()) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return NamedItem ( name . string , item , annotation ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-09-16 19:42:00 +01:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         cut = False | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect('=')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (item := self.item()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return NamedItem ( name . string , item ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (item := self.item()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return NamedItem ( None , item ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2021-02-02 19:54:22 +00:00
										 |  |  |         if ( | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (forced := self.forced_atom()) | 
					
						
							| 
									
										
										
										
											2021-02-02 19:54:22 +00:00
										 |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return NamedItem ( None , forced ) | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (it := self.lookahead()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return NamedItem ( None , it ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-02 19:54:22 +00:00
										 |  |  |     @memoize | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |     def forced_atom(self) -> Optional[Forced]: | 
					
						
							| 
									
										
										
										
											2021-02-02 19:54:22 +00:00
										 |  |  |         # forced_atom: '&' '&' ~ atom | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2021-02-02 19:54:22 +00:00
										 |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect('&')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal_1 := self.expect('&')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (atom := self.atom()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Forced ( atom ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2021-02-02 19:54:22 +00:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |     @memoize | 
					
						
							|  |  |  |     def lookahead(self) -> Optional[LookaheadOrCut]: | 
					
						
							|  |  |  |         # lookahead: '&' ~ atom | '!' ~ atom | '~' | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect('&')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (atom := self.atom()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return PositiveLookahead ( atom ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect('!')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (atom := self.atom()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return NegativeLookahead ( atom ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect('~')) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Cut ( ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def item(self) -> Optional[Item]: | 
					
						
							|  |  |  |         # item: '[' ~ alts ']' | atom '?' | atom '*' | atom '+' | atom '.' atom '+' | atom | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect('[')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (alts := self.alts()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal_1 := self.expect(']')) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Opt ( alts ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (atom := self.atom()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect('?')) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Opt ( atom ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (atom := self.atom()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect('*')) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Repeat0 ( atom ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (atom := self.atom()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect('+')) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Repeat1 ( atom ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (sep := self.atom()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect('.')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (node := self.atom()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal_1 := self.expect('+')) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Gather ( sep , node ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (atom := self.atom()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return atom | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def atom(self) -> Optional[Plain]: | 
					
						
							|  |  |  |         # atom: '(' ~ alts ')' | NAME | STRING | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect('(')) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (alts := self.alts()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal_1 := self.expect(')')) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return Group ( alts ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return NameLeaf ( name . string ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (string := self.string()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return StringLeaf ( string . string ) | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def action(self) -> Optional[str]: | 
					
						
							|  |  |  |         # action: "{" ~ target_atoms "}" | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("{")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (target_atoms := self.target_atoms()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal_1 := self.expect("}")) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return target_atoms | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							|  |  |  |         if cut: return None | 
					
						
							|  |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def annotation(self) -> Optional[str]: | 
					
						
							|  |  |  |         # annotation: "[" ~ target_atoms "]" | 
					
						
							|  |  |  |         mark = self._mark() | 
					
						
							|  |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("[")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (target_atoms := self.target_atoms()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal_1 := self.expect("]")) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return target_atoms | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def target_atoms(self) -> Optional[str]: | 
					
						
							|  |  |  |         # target_atoms: target_atom target_atoms | target_atom | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (target_atom := self.target_atom()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (target_atoms := self.target_atoms()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return target_atom + " " + target_atoms | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (target_atom := self.target_atom()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return target_atom | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @memoize | 
					
						
							|  |  |  |     def target_atom(self) -> Optional[str]: | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         # target_atom: "{" ~ target_atoms? "}" | "[" ~ target_atoms? "]" | NAME "*" | NAME | NUMBER | STRING | "?" | ":" | !"}" !"]" OP | 
					
						
							|  |  |  |         mark = self._mark() | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         cut = False | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("{")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             (atoms := self.target_atoms(),) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |             and | 
					
						
							|  |  |  |             (literal_1 := self.expect("}")) | 
					
						
							|  |  |  |         ): | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             return "{" + ( atoms or "" ) + "}" | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if cut: return None | 
					
						
							|  |  |  |         cut = False | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("[")) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (cut := True) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (atoms := self.target_atoms(),) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal_1 := self.expect("]")) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return "[" + ( atoms or "" ) + "]" | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							|  |  |  |         if cut: return None | 
					
						
							|  |  |  |         if ( | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |             and | 
					
						
							|  |  |  |             (literal := self.expect("*")) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return name . string + "*" | 
					
						
							|  |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (name := self.name()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return name . string | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (number := self.number()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return number . string | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (string := self.string()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return string . string | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect("?")) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return "?" | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             (literal := self.expect(":")) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return ":" | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         if ( | 
					
						
							|  |  |  |             self.negative_lookahead(self.expect, "}") | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |             self.negative_lookahead(self.expect, "]") | 
					
						
							|  |  |  |             and | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |             (op := self.op()) | 
					
						
							|  |  |  |         ): | 
					
						
							|  |  |  |             return op . string | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |         self._reset(mark) | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  |         return None | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-12 17:37:30 +01:00
										 |  |  |     KEYWORDS = () | 
					
						
							|  |  |  |     SOFT_KEYWORDS = ('memo',) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-22 23:29:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  |     from pegen.parser import simple_parser_main | 
					
						
							|  |  |  |     simple_parser_main(GeneratedParser) |