| 109 | 'lookbehind subpattern') |
| 110 | |
| 111 | class SubPattern: |
| 112 | # a subpattern, in intermediate form |
| 113 | def __init__(self, state, data=None): |
| 114 | self.state = state |
| 115 | if data is None: |
| 116 | data = [] |
| 117 | self.data = data |
| 118 | self.width = None |
| 119 | |
| 120 | def dump(self, level=0): |
| 121 | seqtypes = (tuple, list) |
| 122 | for op, av in self.data: |
| 123 | print(level*" " + str(op), end='') |
| 124 | if op is IN: |
| 125 | # member sublanguage |
| 126 | print() |
| 127 | for op, a in av: |
| 128 | print((level+1)*" " + str(op), a) |
| 129 | elif op is BRANCH: |
| 130 | print() |
| 131 | for i, a in enumerate(av[1]): |
| 132 | if i: |
| 133 | print(level*" " + "OR") |
| 134 | a.dump(level+1) |
| 135 | elif op is GROUPREF_EXISTS: |
| 136 | condgroup, item_yes, item_no = av |
| 137 | print('', condgroup) |
| 138 | item_yes.dump(level+1) |
| 139 | if item_no: |
| 140 | print(level*" " + "ELSE") |
| 141 | item_no.dump(level+1) |
| 142 | elif isinstance(av, SubPattern): |
| 143 | print() |
| 144 | av.dump(level+1) |
| 145 | elif isinstance(av, seqtypes): |
| 146 | nl = False |
| 147 | for a in av: |
| 148 | if isinstance(a, SubPattern): |
| 149 | if not nl: |
| 150 | print() |
| 151 | a.dump(level+1) |
| 152 | nl = True |
| 153 | else: |
| 154 | if not nl: |
| 155 | print(' ', end='') |
| 156 | print(a, end='') |
| 157 | nl = False |
| 158 | if not nl: |
| 159 | print() |
| 160 | else: |
| 161 | print('', av) |
| 162 | def __repr__(self): |
| 163 | return repr(self.data) |
| 164 | def __len__(self): |
| 165 | return len(self.data) |
| 166 | def __delitem__(self, index): |
| 167 | del self.data[index] |
| 168 | def __getitem__(self, index): |
no outgoing calls
no test coverage detected
searching dependent graphs…