Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions run/scribblec-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

DIR=`dirname "$0"`/..
PARSERDIR=$DIR'/parser'

if [ ! -d "$PARSERDIR" ]; then
mkdir $PARSERDIR
fi

java -cp $DIR/lib/antlr-3.1.3.jar org.antlr.Tool -o $PARSERDIR $DIR/src/scribble/Scribble.g
39 changes: 39 additions & 0 deletions test/popl14/Negotiation1.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* https://confluence.oceanobservatories.org/display/syseng/CIAD+COI+OV+Negotiate+Protocol
*
*$ bin/scribblec test/demo/popl14/Negotiation1.scr -project popl14.Negotiation1.Negotiate Consumer -o output
*
*$ ./scribble-fsm -o tmp.dot -d tmp.png ../scribblec/output/popl14/Negotiation1_Negotiate_Consumer.scr popl14.Negotiation1_Negotiate_Consumer.Negotiate_Consumer
*/

module popl14.Negotiation1;


type <yml> "SAPDoc1" from "SAPDoc1.yml" as SAP;


global protocol Negotiate(role Consumer as C, role Producer as P)
{
propose(SAP) from C to P;
rec X {
choice at P
{
accept() from P to C;
confirm() from C to P;
} or {
reject() from P to C;
} or {
propose(SAP) from P to C;
choice at C {
accept() from C to P;
confirm() from P to C;
} or {
reject() from C to P;
} or {
propose(SAP) from C to P;
continue X;
}
}
}
}

30 changes: 30 additions & 0 deletions test/popl14/Negotiation2.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* https://confluence.oceanobservatories.org/display/syseng/CIAD+COI+OV+Negotiate+Protocol
*
*$ bin/scribblec test/demo/popl14/Negotiation2.scr -project popl14.Negotiation2.Negotiate Consumer -o output
*/

module popl14.Negotiation2;


type <yml> "SAPDoc1" from "SAPDoc1.yml" as SAP;


global protocol Negotiate(role Consumer, role Producer) {
propose(SAP) from Consumer to Producer;
do NegotiateAux(Consumer as Proposer, Producer as CounterParty);
}

global protocol NegotiateAux(
role Proposer as A, role CounterParty as B) {
choice at B {
accept() from B to A;
confirm() from A to B;
} or {
reject() from B to A;
} or {
propose(SAP) from B to A;
do NegotiateAux(B as Proposer, A as CounterParty);
}
}

47 changes: 47 additions & 0 deletions test/popl14/RPCcomposition.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* https://confluence.oceanobservatories.org/display/syseng/CIAD+COI+OV+Conversation+Management
*
*$ run/scribblec test/demo/popl14/RPCcomposition.scr -project popl14.RPCcomposition.Comp1 Service1 -o output
*/

module popl14.RPCcomposition;


global protocol Comp1(role Client as C,
role Service1 as S1, role Service2 as S2,
role Service3 as S3, role Service4 as S4) {
m1() from C to S1;
m2() from S1 to S2;
m2a() from S2 to S1;
m3() from S1 to S3;
m4() from S3 to S4;
m4a() from S4 to S3;
m5() from S3 to S4;
m5a() from S4 to S3;
m3a() from S3 to S1;
m1a() from S1 to C;
}


global protocol RPC<sig M1, sig M2>(role Client as C, role Server as S)
{
M1 from C to S;
M2 from S to C;
}

global protocol Relay<sig M1, sig M2>(
role First as F, role Middle as M, role Last as L) {
M1 from F to M;
M2 from M to L;
}

global protocol Comp2(role Client as C,
role Service1 as S1, role Service2 as S2,
role Service3 as S3, role Service4 as S4) {
do Relay<m1(), m2()>(C as First, S1 as Middle, S2 as Last);
do Relay<m2a(), m3()>(S2 as First, S1 as Middle, S3 as Last);
do RPC<m4(), m4a()>(S3 as Client, S4 as Server);
do RPC<m5(), m5a()>(S3 as Client, S4 as Server);
do Relay<m3a(), m1a()>(S2 as First, S1 as Middle, C as Last);
}

36 changes: 36 additions & 0 deletions test/popl14/RUC.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* https://confluence.oceanobservatories.org/display/CIDev/
Resource+Control+in+Scribble
*
*$ bin/scribblec test/demo/popl14/RUC.scr -project popl14.RUC.RUC User -o output
*/

module popl14.RUC;


type <py> "IntType" from "Types.py" as int;


global protocol RUC(
role User as U, role Controller as C, role Agent as A) {
req(int) from U to C;
start() from C to A;
interruptible {
rec X {
interruptible {
rec Y {
data() from A to U;
continue Y;
}
} with {
pause() by U;
}
resume() from U to A;
continue X;
}
} with {
stop() by U;
timeout() by C;
}
}

43 changes: 43 additions & 0 deletions test/popl14/ResourceControl.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* https://confluence.oceanobservatories.org/display/CIDev/Resource+Control+in+Scribble
*/

module popl14.ResourceControl;


type <py> "types.IntType" from "types.py" as int;


global protocol RC(role User as U,
role Controller as C,
role Agent as A)
{
req(int) from U to C;
start() from C to A;
interruptible
{
rec X
{
interruptible
{
rec Y
{
data() from A to U;
continue Y;
}
}
with
{
pause() by U;
}
resume() from U to A;
continue X;
}
}
with
{
stop() by U;
timeout() by C;
}
}

48 changes: 48 additions & 0 deletions test/popl14/WF.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//$ bin/scribblec test/demo/popl14/WF.scr

module popl14.WF;


global protocol ChoiceAmbiguous(role A, role B, role C) {
choice at A {
m1() from A to B;
m2() from B to C;
m3() from C to A;
} or {
m1() from A to B;
m5() from B to C;
m6() from C to A;
}
}


/*global protocol ChoiceNotCommunicated(role A, role B, role C) {
choice at A {
m1() from A to B;
m2() from B to C;
} or {
m4() from A to B;
}
}*/


/*global protocol ParallelNotLinear(role A, role B, role C) {
par {
m1() from A to B;
m2() from B to C;
} and {
m1() from A to B;
m4() from B to C;
}
}*/


/*global protocol RecursionNoExit(role A, role B, role C, role D) {
rec X {
m1() from A to B;
continue X;
}
m2() from B to A;
m3() from C to D;
}*/