forever => react, state => react, init => do, done => finally, until => react until
This commit is contained in:
parent
e54b6566f5
commit
efc444ac37
|
@ -101,7 +101,7 @@ var modifiedSourceActions = {
|
|||
ActorFacetStatement_state: function(_state, facetBlock, _until, transitionBlock) {
|
||||
return buildFacet(facetBlock, transitionBlock);
|
||||
},
|
||||
ActorFacetStatement_until: function(_until, transitionBlock) {
|
||||
ActorFacetStatement_until: function(_react, _until, transitionBlock) {
|
||||
return buildFacet(null, transitionBlock);
|
||||
},
|
||||
ActorFacetStatement_forever: function(_forever, facetBlock) {
|
||||
|
|
|
@ -9,7 +9,7 @@ ground dataspace {
|
|||
actor {
|
||||
this.balance = 0;
|
||||
|
||||
forever {
|
||||
react {
|
||||
assert account(this.balance);
|
||||
on message deposit($amount) {
|
||||
this.balance += amount;
|
||||
|
@ -18,7 +18,7 @@ ground dataspace {
|
|||
}
|
||||
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
on asserted account($balance) {
|
||||
console.log("Balance is now", balance);
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ ground dataspace {
|
|||
}
|
||||
|
||||
actor {
|
||||
state {
|
||||
init {
|
||||
react {
|
||||
do {
|
||||
console.log("Waiting for account.");
|
||||
}
|
||||
done {
|
||||
finally {
|
||||
console.log("Account became ready.");
|
||||
}
|
||||
} until {
|
||||
|
|
|
@ -12,13 +12,13 @@ ground dataspace {
|
|||
|
||||
actor {
|
||||
this.files = {};
|
||||
forever {
|
||||
react {
|
||||
during Syndicate.observe(file($name, _)) {
|
||||
init {
|
||||
do {
|
||||
console.log("At least one reader exists for:", name);
|
||||
}
|
||||
assert file(name, this.files[name]);
|
||||
done {
|
||||
finally {
|
||||
console.log("No remaining readers exist for:", name);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ ground dataspace {
|
|||
// A simple demo client of the file system
|
||||
|
||||
actor {
|
||||
state {
|
||||
react {
|
||||
on asserted file("hello.txt", $content) {
|
||||
console.log("hello.txt has content", JSON.stringify(content));
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ ground dataspace {
|
|||
}
|
||||
}
|
||||
|
||||
until {
|
||||
react until {
|
||||
case asserted Syndicate.observe(saveFile(_, _)) {
|
||||
:: saveFile("hello.txt", "a");
|
||||
:: deleteFile("hello.txt");
|
||||
|
@ -53,7 +53,7 @@ ground dataspace {
|
|||
:: saveFile("hello.txt", "quit demo");
|
||||
:: saveFile("hello.txt", "final contents");
|
||||
actor {
|
||||
until {
|
||||
react until {
|
||||
case asserted file("hello.txt", $content) {
|
||||
console.log("second observer sees that hello.txt content is",
|
||||
JSON.stringify(content));
|
||||
|
|
|
@ -22,9 +22,9 @@ Syndicate <: ES5 {
|
|||
| dataspace Block -- normal
|
||||
|
||||
ActorFacetStatement
|
||||
= state FacetBlock until FacetStateTransitionBlock -- state
|
||||
| until FacetStateTransitionBlock -- until
|
||||
| forever FacetBlock -- forever
|
||||
= react FacetBlock until FacetStateTransitionBlock -- state
|
||||
| react until FacetStateTransitionBlock -- until
|
||||
| react FacetBlock -- forever
|
||||
|
||||
AssertionTypeDeclarationStatement
|
||||
= assertion type identifier "(" FormalParameterList ")" ("=" stringLiteral)? #(sc)
|
||||
|
@ -37,8 +37,8 @@ Syndicate <: ES5 {
|
|||
FacetBlock = "{" FacetInitBlock? FacetSituation* FacetDoneBlock? "}"
|
||||
FacetStateTransitionBlock = "{" FacetStateTransition* "}"
|
||||
|
||||
FacetInitBlock = init Block
|
||||
FacetDoneBlock = done Block
|
||||
FacetInitBlock = do Block
|
||||
FacetDoneBlock = finally Block
|
||||
|
||||
FacetSituation
|
||||
= assert FacetPattern AssertWhenClause? #(sc) -- assert
|
||||
|
@ -74,16 +74,13 @@ Syndicate <: ES5 {
|
|||
asserted = "asserted" ~identifierPart
|
||||
assertion = "assertion" ~identifierPart
|
||||
dataspace = "dataspace" ~identifierPart
|
||||
done = "done" ~identifierPart
|
||||
during = "during" ~identifierPart
|
||||
forever = "forever" ~identifierPart
|
||||
ground = "ground" ~identifierPart
|
||||
init = "init" ~identifierPart
|
||||
message = "message" ~identifierPart
|
||||
metalevel = "metalevel" ~identifierPart
|
||||
on = "on" ~identifierPart
|
||||
react = "react" ~identifierPart
|
||||
retracted = "retracted" ~identifierPart
|
||||
state = "state" ~identifierPart
|
||||
type = "type" ~identifierPart
|
||||
until = "until" ~identifierPart
|
||||
when = "when" ~identifierPart
|
||||
|
|
|
@ -8,7 +8,7 @@ $(document).ready(function() {
|
|||
|
||||
actor {
|
||||
this.counter = 0;
|
||||
forever {
|
||||
react {
|
||||
assert DOM('#button-label', '', Syndicate.seal(this.counter));
|
||||
on message jQueryEvent('#counter', 'click', _) {
|
||||
this.counter++;
|
||||
|
|
|
@ -19,7 +19,7 @@ function spawnChatApp() {
|
|||
if (!($("#nym").val())) { $("#nym").val("nym" + Math.floor(Math.random() * 65536)); }
|
||||
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
on asserted jQueryInput('#nym', $v) { this.nym = v; }
|
||||
on asserted jQueryInput('#status', $v) { this.status = v; }
|
||||
|
||||
|
@ -85,11 +85,11 @@ assertion type jQueryInput(selector, value);
|
|||
|
||||
function spawnInputChangeMonitor() {
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
on asserted Syndicate.observe(jQueryInput($selector, _)) {
|
||||
actor {
|
||||
this.value = $(selector).val();
|
||||
state {
|
||||
react {
|
||||
assert jQueryInput(selector, this.value);
|
||||
on message jQueryEvent(selector, 'change', $e) {
|
||||
this.value = e.target.value;
|
||||
|
|
|
@ -13,7 +13,7 @@ var jQueryEvent = Syndicate.JQuery.jQueryEvent;
|
|||
|
||||
function spawnTV() {
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
during tvAlert($text) {
|
||||
assert DOM('#tv', 'alert', Syndicate.seal(["li", text]));
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ function spawnTV() {
|
|||
|
||||
function spawnRemoteControl() {
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
assert componentPresent('remote control');
|
||||
on message jQueryEvent('#remote-control', 'click', _) {
|
||||
:: remoteClick();
|
||||
|
@ -43,7 +43,7 @@ function spawnRemoteListener() {
|
|||
// state, if we've been clicked, turn it off. We don't do this
|
||||
// here, for simplicity.
|
||||
|
||||
forever {
|
||||
react {
|
||||
on asserted powerDraw($watts) {
|
||||
this.stoveIsOn = watts > 0;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ function spawnRemoteListener() {
|
|||
function spawnStoveSwitch() {
|
||||
actor {
|
||||
this.powerOn = false;
|
||||
state {
|
||||
react {
|
||||
assert componentPresent('stove switch');
|
||||
assert switchState(this.powerOn);
|
||||
|
||||
|
@ -87,7 +87,7 @@ function spawnStoveSwitch() {
|
|||
function spawnPowerDrawMonitor() {
|
||||
actor {
|
||||
this.watts = 0;
|
||||
state {
|
||||
react {
|
||||
assert componentPresent('power draw monitor');
|
||||
assert powerDraw(this.watts);
|
||||
|
||||
|
@ -110,14 +110,14 @@ function spawnPowerDrawMonitor() {
|
|||
|
||||
function spawnTimeoutListener() {
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
during powerDraw($watts) {
|
||||
init {
|
||||
do {
|
||||
if (watts > 0) {
|
||||
var powerOnTime = Date.now();
|
||||
forever {
|
||||
react {
|
||||
on asserted Syndicate.Timer.timeLaterThan(powerOnTime + 3000) {
|
||||
forever { assert tvAlert('Stove on too long?'); }
|
||||
react { assert tvAlert('Stove on too long?'); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,13 +129,13 @@ function spawnTimeoutListener() {
|
|||
|
||||
// function spawnTimeoutListener() {
|
||||
// actor {
|
||||
// forever {
|
||||
// react {
|
||||
// on asserted powerDraw($watts) {
|
||||
// if (watts > 0) {
|
||||
// var powerOnTime = Date.now();
|
||||
// state {
|
||||
// react {
|
||||
// on asserted Syndicate.Timer.timeLaterThan(powerOnTime + 3000) {
|
||||
// forever { assert tvAlert('Stove on too long?'); }
|
||||
// react { assert tvAlert('Stove on too long?'); }
|
||||
// }
|
||||
// } until {
|
||||
// case asserted powerDraw(0); // alt: on retracted powerDraw(watts);
|
||||
|
@ -150,7 +150,7 @@ function spawnTimeoutListener() {
|
|||
// actor {
|
||||
// this.mostRecentTime = 0;
|
||||
// this.powerOnTime = null;
|
||||
// forever {
|
||||
// react {
|
||||
// on asserted powerDraw($watts) {
|
||||
// this.powerOnTime = (watts > 0) ? this.mostRecentTime : null;
|
||||
// }
|
||||
|
@ -168,9 +168,9 @@ function spawnTimeoutListener() {
|
|||
|
||||
function spawnFailureMonitor() {
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
on retracted componentPresent($who) {
|
||||
state {
|
||||
react {
|
||||
assert tvAlert('FAILURE: ' + who);
|
||||
} until {
|
||||
case asserted componentPresent(who);
|
||||
|
@ -185,7 +185,7 @@ function spawnFailureMonitor() {
|
|||
|
||||
function spawnChaosMonkey() {
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
on message jQueryEvent('#spawn-power-draw-monitor', 'click', _) {
|
||||
spawnPowerDrawMonitor();
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ ground dataspace {
|
|||
console.log('starting ground boot');
|
||||
|
||||
actor {
|
||||
until {
|
||||
react until {
|
||||
case asserted Syndicate.observe(beep(_)) {
|
||||
var counter = 0;
|
||||
state {
|
||||
init {
|
||||
react {
|
||||
do {
|
||||
:: beep(counter++);
|
||||
}
|
||||
on message beep(_) {
|
||||
|
@ -22,7 +22,7 @@ ground dataspace {
|
|||
}
|
||||
|
||||
actor {
|
||||
forever {
|
||||
react {
|
||||
on message beep($counter) {
|
||||
console.log("beep!", counter);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ $(document).ready(function () {
|
|||
:: time(+(new Date()));
|
||||
}), 1000);
|
||||
|
||||
forever {
|
||||
react {
|
||||
on message time($now) {
|
||||
this.angle = (((now / 1000) % 60) / 60) * 2 * Math.PI;
|
||||
this.handX = 50 + 40 * Math.cos(this.angle);
|
||||
|
|
|
@ -43,7 +43,7 @@ function spawnGui() {
|
|||
: piece(text, pos, 0, text.length + 1, "normal");
|
||||
};
|
||||
|
||||
forever {
|
||||
react {
|
||||
on message jQueryEvent("#inputRow", "+keypress", $event) {
|
||||
var keycode = event.keyCode;
|
||||
var character = String.fromCharCode(event.charCode);
|
||||
|
@ -82,7 +82,7 @@ function spawnModel() {
|
|||
this.fieldValue = "initial";
|
||||
this.cursorPos = this.fieldValue.length; /* positions address gaps between characters */
|
||||
|
||||
forever {
|
||||
react {
|
||||
assert fieldContents(this.fieldValue, this.cursorPos);
|
||||
|
||||
on message fieldCommand("cursorLeft") {
|
||||
|
@ -135,7 +135,7 @@ function spawnSearch() {
|
|||
}
|
||||
};
|
||||
|
||||
forever {
|
||||
react {
|
||||
assert highlight(this.highlight);
|
||||
|
||||
on message jQueryEvent("#searchBox", "input", $event) {
|
||||
|
|
Loading…
Reference in New Issue