-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from nevalang/new_sugar2
One-liners connections sugar. It's not finished, it has this issue #544
- Loading branch information
Showing
88 changed files
with
2,849 additions
and
2,004 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
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,9 +1,9 @@ | ||
const l list<int> = [-215] | ||
|
||
component Main(start) (stop) { | ||
nodes { Printer<any> } | ||
nodes { Println<any> } | ||
net { | ||
:start -> ($l -> printer:data) | ||
printer:sig -> :stop | ||
:start -> ($l -> println:data) | ||
println:sig -> :stop | ||
} | ||
} |
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,15 +1,15 @@ | ||
component Main(start) (stop) { | ||
nodes { | ||
Printer<int> | ||
sub PortBridge<int> { handler Subtractor<int> } | ||
Println<int> | ||
sub PortReducer<int> { reducer Sub<int> } | ||
} | ||
net { | ||
:start -> ( | ||
1 -> sub:ports[0], | ||
2 -> sub:ports[1], | ||
3 -> sub:ports[2] | ||
1 -> sub:port[0], | ||
2 -> sub:port[1], | ||
3 -> sub:port[2] | ||
) | ||
sub:res -> printer:data | ||
printer:sig -> :stop | ||
sub:res -> println:data | ||
println:sig -> :stop | ||
} | ||
} |
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,9 @@ | ||
const x float = 42 | ||
|
||
component Main(start) (stop) { | ||
nodes { Printer<float> } | ||
nodes { Println<float> } | ||
net { | ||
:start -> ($x -> printer:data) | ||
printer:sig -> :stop | ||
:start -> ($x -> println:data) | ||
println:sig -> :stop | ||
} | ||
} |
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,13 +1,13 @@ | ||
import { regexp } | ||
|
||
component Main(start) (stop) { | ||
nodes { Printer<any>, regexp.Submatcher } | ||
nodes { Println<any>, regexp.Submatch } | ||
net { | ||
:start -> ( | ||
'a(x*)b(y|z)c' -> submatcher:regexp, | ||
'-axxxbyc-' -> submatcher:data | ||
'a(x*)b(y|z)c' -> submatch:regexp, | ||
'-axxxbyc-' -> submatch:data | ||
) | ||
submatcher:res -> printer:data | ||
printer:sig -> :stop | ||
submatch:res -> println:data | ||
println:sig -> :stop | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// https://www.99-bottles-of-beer.net | ||
|
||
component Main(start) (stop) { | ||
nodes { Match<int>, next PrintNext2Lines } | ||
net { | ||
:start -> (99 -> next:n) | ||
|
||
next:n -> match:data | ||
-1 -> match:case[0] | ||
|
||
match:case[0] -> :stop | ||
match:else -> next:n | ||
} | ||
} | ||
|
||
component PrintNext2Lines(n int) (n int) { | ||
nodes { | ||
decr Decr<int> | ||
first PrintFirstLine | ||
second PrintSecondLine | ||
} | ||
net { | ||
:n -> first:n | ||
first:n -> decr:n | ||
decr:n -> second:n | ||
second:n -> :n | ||
} | ||
} | ||
|
||
// === First Line === | ||
|
||
const { | ||
firstLine1 string = '$0 bottles of beer on the wall, $0 bottles of beer.\n' | ||
firstLine2 string = '1 bottle of beer on the wall, 1 bottle of beer.' | ||
firstLine3 string = 'No more bottles of beer on the wall, no more bottles of beer.' | ||
} | ||
|
||
component PrintFirstLine(n int) (n int) { | ||
nodes { Match<int>, Println<string>, Printf<int>, Lock<int> } | ||
net { | ||
:n -> [match:data, lock:data] | ||
0 -> match:case[0] | ||
1 -> match:case[1] | ||
|
||
match:case[0] -> ($firstLine3 -> println:data) | ||
match:case[1] -> ($firstLine2 -> println:data) | ||
match:else -> printf:args[0] | ||
$firstLine1 -> printf:tpl | ||
|
||
println:sig -> lock:sig | ||
printf:args[0] -> lock:sig | ||
|
||
lock:data -> :n | ||
} | ||
} | ||
|
||
// === Second Line === | ||
|
||
const { | ||
secondLine1 string = 'Take one down and pass it around, $0 bottles of beer on the wall.\n\n' | ||
secondLine2 string = 'Take one down and pass it around, 1 bottle of beer on the wall.\n' | ||
secondLine3 string = 'Take one down and pass it around, no more bottles of beer on the wall.\n' | ||
secondLine4 string = 'Go to the store and buy some more, 99 bottles of beer on the wall.' | ||
} | ||
|
||
component PrintSecondLine(n int) (n int) { | ||
nodes { Match<int>, Lock<int>, Printf<int>, Println<string> } | ||
net { | ||
:n -> [match:data, lock:data] | ||
-1 -> match:case[0] | ||
0 -> match:case[1] | ||
1 -> match:case[2] | ||
|
||
match:case[0] -> ($secondLine4 -> println:data) | ||
match:case[1] -> ($secondLine3 -> println:data) | ||
match:case[2] -> ($secondLine2 -> println:data) | ||
match:else -> printf:args[0] | ||
$secondLine1 -> printf:tpl | ||
|
||
[println:sig, printf:args[0]] -> lock:sig | ||
lock:data -> :n | ||
} | ||
} |
Oops, something went wrong.