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