switches: Group topology terms into switch terms

This commit changes the internal representation of topology terms within
the automaton-based dehopification algorithm. Previously, the algorithm
treated link terms in parallel composition as independent entities.

  topo = (1@1 => 2@1 | 1@2 => 3@1 | 2@1 => 3@2)

This meant that link-free policies would be distributed across the
entire parallel composition:

  lfp ; topo = (lfp ; 1@1 => 2@1) | (lfp ; 1@2 => 3@1) | ...

which would lead to rapid growth in transformed program size.

Instead, the algorithm now recognizes when link terms with the same
source switch are combined in parallel composition, and consider that a
single link term for the purposes of distributing sequences. The
distribution is actually done at a later point in the algorithm where it
can be implemented more efficiently as a port filter on the local
policy.

Note that this currently only applies for compositions that associate to
the left, which means you will only see the effect on one or two switch
policies if the policies are not crafted carefully. To clarify,

  (1@1 => 2@1 | 1@2 => 3@1 | 2@1 => 4@1 | 2@2 => 4@2)

will only group switch 1, whereas

  (1@1 => 2@1 | 1@2 => 3@1) | (2@1 => 4@1 | 2@2 => 4@2)

will group both switch 1 and switch 2.
switches: collect whole topolgy terms

This commit is a follow-up to the last, with further grouping of link
terms. Now, rather than just grouping links on the same switch, any
parallel composition of link terms is stored as a single unit. In other
orwds, the automaton now works over sequence of link-free policies and
topology terms.

Results: abfattree-tables-fail-full-4-3.kat

  Generate using the script in ocaml-topology:

    python abfattree.py -k abfattree-tables-fail-full-4-3.kat -t tables\
    -f fail -l full -o /tmp/f10.dot 4 3

  Running time:
    real    0m5.438s
    user    0m5.088s
    sys     0m0.036s

  Size of flowtables: 26 to 144

  Number of states used: 4 (including initial)

  Correctness: spot-checked but not confirmed.
Build native binary.
(cherry picked from commit 162ec547297e8d57eec545bea0b416da7fc72a47)
switches: fix stack overflow in transformations

The transformations from a policy to a regex, as well as a link-free
policy to a policy, were not tail recursive and were therefore blowing
the stack on large in large inputs. This commit fixes that by CPS-ing
these functions, thus making them tail recursive.

Fixes #185
switches: elminiate redundant policy transformations

The code was distributing link-free policies across topology terms,
which meant that later on the copies of the link-free policies would
have to each copy would have to be transformed into a policy, thus
duplicating work. This commit transforms like-free polices into regular
policies before distributing across topology terms, thus elminating the
redundant work.
Merge branch 'switches' of github.com:frenetic-lang/frenetic into switches
switches: Revert 6e31112