-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Union Operator; Update AST (#69)
### Background #55 discusses a need for a modified AST that distinguishes between **set-to-stream** and **stream-to-stream** policies, and furthermore distinguishes between **sets** and **streams**. Within that, we discuss the need for a `Union` operator, which effectively 'merges several classes into one'. This is critical in the construction of Set-to-Stream transformers, to allow such polices to arbitrate independent of queue distinctions. ### Overview My work on the type system in #63 allowed us to realize that we could turn typechecking into essentially an abstraction, and have our `set` and `stream` types inferred at parsing-time itself – that is to say, with a tweak to the AST and extending it to the parser as well. That's the first part part of the PR, which entails adding in the `Union` constructor to the AST, and partitioning it into the `set` and `stream` types. ### Caveat And Explanation @polybeandip and I discussed how far we thought this change should extend. On one hand, modifying `Ast.t` contractually requires us to modify `Policy.t`. An alternative, though, is to simply establish a correspondence `Ast.t -> Policy.t`. For simplicity and to preserve the work done in `control`, we have kept `Policy.t` in its original form, and adapted that correspondence. In turn, this required modifying almost all of our programs such that they would be syntactically correct w.rt. the new AST structure and parsing mechanisms. In addition, a few extra 'reversions' to allow for parsed programs to be correctly evaluated in `control`. --------- Co-authored-by: grp loaner <grploaner@users-MacBook-Air.local>
- Loading branch information
1 parent
9517033
commit b9e6d58
Showing
32 changed files
with
132 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
classes A, B; | ||
|
||
var = rr[A, B]; | ||
final = fifo[var, B]; // B is used twice | ||
var = fifo[union[A, B]]; | ||
final = rr[var, fifo[B]]; // B is used twice | ||
|
||
return final |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A, B; | ||
|
||
x = fifo[A, A]; | ||
x = fifo[union[A, A]]; | ||
|
||
return x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
classes A, B; | ||
|
||
combined = rr[union[A, B]]; | ||
|
||
return combined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
classes A, B; | ||
|
||
//FIFO cannot be applied to multiple classes; they must be unioned first. | ||
combined = fifo[A, B]; | ||
|
||
return combined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes X, Y, Z; | ||
|
||
foo = strict[X, Y, Z]; | ||
foo = strict[fifo[X], fifo[Y], fifo[Z]]; | ||
|
||
return policy // user probably meant to return `foo` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
classes BX, BY, RP, RT; | ||
|
||
b_policy = fifo[BX, BY]; | ||
r_policy = rr[RP, RT]; | ||
b_policy = fifo[union[BX, BY]]; | ||
r_policy = rr[fifo[RP], fifo[RT]]; | ||
policy = rr[b_policy, r_polic]; // user made a typo, meant to reference `r_policy` | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes X, Y; | ||
|
||
pol = strict[X, Z]; // `Z` is undeclared, only `X` and `Y` may be used | ||
pol = strict[fifo[X], fifo[Z]]; // `Z` is undeclared, only `X` and `Y` may be used | ||
|
||
return pol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
classes A, B, C; | ||
|
||
pol_1 = rr[A, B]; | ||
pol_2 = rr[B, C]; | ||
ans = strict[pol_1, C]; | ||
pol_1 = rr[fifo[A], fifo[B]]; | ||
pol_2 = rr[fifo[B], fifo[C]]; | ||
ans = strict[pol_1, fifo[C]]; | ||
|
||
return ans |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
classes A, B; | ||
|
||
policy = leakybucket [[A, B], width=5, buffer=10]; | ||
policy = leakybucket [[fifo[A], fifo[B]], width=5, buffer=10]; | ||
// Interleave packets from flows A and B, allowing at most | ||
// 5 packets to be processed per time cycle, | ||
// and at most 10 packets to be in a buffer at once | ||
|
||
return policy | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A, B, C, D; | ||
|
||
policy = rcsp [A, B, C, D]; | ||
policy = rcsp [fifo[A], fifo[B], fifo[C], fifo[D]]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
classes A, B; | ||
|
||
policy = A; | ||
policy = fifo[A]; | ||
|
||
return policy | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A; | ||
|
||
policy = A; | ||
policy = fifo[A]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
classes A; | ||
|
||
policy = A; | ||
policy = fifo[A]; | ||
// Sample test comment | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
classes A, B; | ||
|
||
policy = fifo[union[A, B]]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A, B, C; | ||
|
||
policy = fifo[A, B, C]; | ||
policy = fifo[union[A, B, C]]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A; | ||
|
||
policy = rr[A]; | ||
policy = rr[fifo[A]]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A, B; | ||
|
||
policy = rr[A, B]; | ||
policy = rr[fifo[union[A, B]]]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A, B, C; | ||
|
||
policy = rr[A, B, C]; | ||
policy = rr[fifo[A], fifo[B], fifo[C]]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A, B, C; | ||
|
||
policy = strict[C, B, A]; | ||
policy = strict[fifo[C], fifo[B], fifo[A]]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
classes A, B, C; | ||
|
||
policy = wfq[(A, 0.1), (B, 0.2), (C, 0.3)]; | ||
policy = wfq[(fifo[A], 1), (fifo[B], 2), (fifo[C], 3)]; | ||
|
||
return policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.