frenetic-lang/frenetic — pull request #155 by seliopou (2013-11-10 01:32:46+00:00)
Title: Fix bug in regex_of_policy for certain seq cases

In certain cases, the transformation wasn't using the fact that
sequencing is associative. For example in this program

(filter switch = 1; port := 1 ;
(1@1 => 2@1; filter switch = 2; port := 4)); 9@2 => 2@3

the transformation descends to the sequence of the link and the filter
on switch = 2. The link term will create a TP continuation, and the
filter will crate an NL continuation. The sequencing rule for TP, NL
would properly create a NL continuation in this case. But, if this NL
continuation is ever called with None as its second argument (indicating
no link-free policies are available), it will force the TP continuation
to turn the link into a character.

This is exactly what happens once you go up one constructor level,
where you're dealing with this expression:

`(1@1 => 2@1; filter switch = 2); port := 4`

The left-hand side is the aforementioned NL continuation with the
embedded TP call. Passing that continuation None as its second argument
forced the link to become a character, causing the error.

What this code should have done is create a new NL continuation that
will be able to receive more link-free policies from its context, and
pass those along.

I've added an ascii "truth-table" showing the valid continuation
transitions. In the case of NL, NL, it should always transition to NL,
but just forcing the left-hand side continuation does not ensure that in
the general case. Therefore, you have to wrap the call in the proper
constructor.

Closes #152.