Paraphrasis matching

```
fun parenMatch ps =
let
fun adjustCounter (x, p) =
case x of
NONE => NONE
| SOME c =>
case p of
Paren.L => SOME (c + 1)
| Paren.R => if c = 0 then NONE else SOME (c - 1)
in
Seq.iterate adjustCounter (SOME 0) ps = SOME 0
end
fun parenMatch ps =
let
fun parenMatch' ps =
case Seq.splitMid ps of
Seq.EMPTY => (0,0)
| Seq.ONE Paren.L => (0,1)
| Seq.ONE Paren.R => (1,0)
| Seq.PAIR (a, b) =>
let val ((i,j),(k,l)) =
Primitives.par (fn () => parenMatch' a,
fn () => parenMatch' b)
in if j <= k then (i+k-j,l) else (i,l+j-k)
end
in
parenMatch' ps = (0,0)
end
```

Table of Content