( pat: Pat, expr: Expression, x: Expression, cap = 8, deadline?: number )
| 67 | * assignment, the next assignment must be tried — e.g. |
| 68 | * `(a+bx)^m (c+dx)^n` factor roles are interchangeable and conditions |
| 69 | * often hold for only one orientation. |
| 70 | */ |
| 71 | export function matchAll( |
| 72 | pat: Pat, |
| 73 | expr: Expression, |
| 74 | x: Expression, |
| 75 | cap = 8, |
| 76 | deadline?: number |
| 77 | ): Env[] { |
| 78 | const envs: Env[] = []; |
| 79 | const env: Env = new Map(); |
| 80 | const saved = _matchDeadline; |
| 81 | _matchDeadline = deadline; |
| 82 | try { |
| 83 | m(pat, expr, x, env, () => { |
| 84 | envs.push(new Map(env)); |
| 85 | return envs.length >= cap; // false ⇒ keep backtracking for more |
| 86 | }); |
| 87 | } finally { |
| 88 | _matchDeadline = saved; |
| 89 | } |
| 90 | return envs; |
| 91 | } |
| 92 |
no test coverage detected