changeset 38863 | 61ab546b71c3 |
parent 38832 | ca4de8ba5b5f |
child 38864 | 73731fa8d1bd |
38862:1ff45c518e6f | 38863:61ab546b71c3 |
---|---|
11 from . import ( |
11 from . import ( |
12 error, |
12 error, |
13 parser, |
13 parser, |
14 pycompat, |
14 pycompat, |
15 ) |
15 ) |
16 |
|
17 # common weight constants for static optimization |
|
18 # (see registrar.filesetpredicate for details) |
|
19 WEIGHT_CHECK_FILENAME = 0.5 |
|
20 WEIGHT_READ_CONTENTS = 30 |
|
21 WEIGHT_STATUS = 10 |
|
22 WEIGHT_STATUS_THOROUGH = 50 |
|
16 |
23 |
17 elements = { |
24 elements = { |
18 # token-type: binding-strength, primary, prefix, infix, suffix |
25 # token-type: binding-strength, primary, prefix, infix, suffix |
19 "(": (20, None, ("group", 1, ")"), ("func", 1, ")"), None), |
26 "(": (20, None, ("group", 1, ")"), ("func", 1, ")"), None), |
20 ":": (15, None, None, ("kindpat", 15), None), |
27 ":": (15, None, None, ("kindpat", 15), None), |
182 if x is None: |
189 if x is None: |
183 return 0, x |
190 return 0, x |
184 |
191 |
185 op = x[0] |
192 op = x[0] |
186 if op in {'string', 'symbol'}: |
193 if op in {'string', 'symbol'}: |
187 return 0.5, x |
194 return WEIGHT_CHECK_FILENAME, x |
188 if op == 'kindpat': |
195 if op == 'kindpat': |
189 w, t = _optimize(x[2]) |
196 w, t = _optimize(x[2]) |
190 return w, (op, x[1], t) |
197 return w, (op, x[1], t) |
191 if op == 'not': |
198 if op == 'not': |
192 w, t = _optimize(x[1]) |
199 w, t = _optimize(x[1]) |