diff --git a/run/scribblec-build b/run/scribblec-build new file mode 100755 index 0000000..2ce547a --- /dev/null +++ b/run/scribblec-build @@ -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 diff --git a/test/popl14/Negotiation1.scr b/test/popl14/Negotiation1.scr new file mode 100755 index 0000000..2eca9e5 --- /dev/null +++ b/test/popl14/Negotiation1.scr @@ -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 "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; + } + } + } +} + diff --git a/test/popl14/Negotiation2.scr b/test/popl14/Negotiation2.scr new file mode 100755 index 0000000..361dad1 --- /dev/null +++ b/test/popl14/Negotiation2.scr @@ -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 "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); + } +} + diff --git a/test/popl14/RPCcomposition.scr b/test/popl14/RPCcomposition.scr new file mode 100755 index 0000000..b0606c9 --- /dev/null +++ b/test/popl14/RPCcomposition.scr @@ -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(role Client as C, role Server as S) +{ + M1 from C to S; + M2 from S to C; +} + +global protocol Relay( + 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(C as First, S1 as Middle, S2 as Last); + do Relay(S2 as First, S1 as Middle, S3 as Last); + do RPC(S3 as Client, S4 as Server); + do RPC(S3 as Client, S4 as Server); + do Relay(S2 as First, S1 as Middle, C as Last); +} + diff --git a/test/popl14/RUC.scr b/test/popl14/RUC.scr new file mode 100755 index 0000000..614f259 --- /dev/null +++ b/test/popl14/RUC.scr @@ -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 "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; + } +} + diff --git a/test/popl14/ResourceControl.scr b/test/popl14/ResourceControl.scr new file mode 100755 index 0000000..17fadd0 --- /dev/null +++ b/test/popl14/ResourceControl.scr @@ -0,0 +1,43 @@ +/** + * https://confluence.oceanobservatories.org/display/CIDev/Resource+Control+in+Scribble + */ + +module popl14.ResourceControl; + + +type "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; + } +} + diff --git a/test/popl14/WF.scr b/test/popl14/WF.scr new file mode 100755 index 0000000..fd9c644 --- /dev/null +++ b/test/popl14/WF.scr @@ -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; +}*/ +