You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2007/12/11 01:17:58 UTC
svn commit: r603103 - in /ode/sandbox/simpel/src:
main/antlr/org/apache/ode/simpel/antlr/SimPEL.g
main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g
test/resources/compile-tests-ok.simpel
Author: mriou
Date: Mon Dec 10 16:17:58 2007
New Revision: 603103
URL: http://svn.apache.org/viewvc?rev=603103&view=rev
Log:
Support for variable and partner link declarations, now mandates semi-colons for line endings to keep my sanity.
Modified:
ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g
ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g
ode/sandbox/simpel/src/test/resources/compile-tests-ok.simpel
Modified: ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g?rev=603103&r1=603102&r2=603103&view=diff
==============================================================================
--- ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g (original)
+++ ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g Mon Dec 10 16:17:58 2007
@@ -8,7 +8,7 @@
tokens {
PROCESS; PICK; SEQUENCE; FLOW; IF; ELSEIF; ELSE; WHILE; UNTIL; FOREACH; FORALL; INVOKE;
RECEIVE; REPLY; ASSIGN; THROW; WAIT; EXIT; TIMEOUT; TRY; CATCH; CATCH_ALL; SCOPE; EVENT;
- ALARM; COMPENSATION; COMPENSATE; CORRELATION; CORR_MAP;
+ ALARM; COMPENSATION; COMPENSATE; CORRELATION; CORR_MAP; PARTNERLINK; VARIABLE;
EXPR; EXT_EXPR; XML_LITERAL;
}
@parser::header {
@@ -78,7 +78,8 @@
process_stmt
: (pick | flow | if_ex | while_ex | until_ex | foreach | forall | try_ex | scope_ex
- | invoke | receive | reply | assign | throw_ex | wait_ex | exit)+;
+ | receive | ((invoke | reply | assign | throw_ex | wait_ex | exit
+ | variables) SEMI!) )+;
// Structured activities
pick : 'pick' '{' receive* timeout* '}' -> ^(PICK receive* timeout*);
@@ -115,13 +116,17 @@
// Simple activities
invoke : 'invoke' '(' p=ID ',' o=ID (',' in=ID)? ')' -> ^(INVOKE $p $o $in?);
-receive : 'receive' '(' p=ID ',' o=ID (',' m=ID)? (',' correlation)? ')' block? -> ^(RECEIVE $p $o $m? correlation? block?);
+receive : receive_block | (receive_stmt SEMI!);
+receive_block
+ : 'receive' '(' p=ID ',' o=ID (',' m=ID)? (',' correlation)? ')' block -> ^(RECEIVE $p $o $m? correlation? block);
+receive_stmt
+ : 'receive' '(' p=ID ',' o=ID (',' m=ID)? (',' correlation)? ')' -> ^(RECEIVE $p $o $m? correlation?);
reply : 'reply' '(' ID ')' -> ^(REPLY ID);
assign : ID '=' rvalue -> ^(ASSIGN ID rvalue);
rvalue
- : receive | invoke | expr | xml_literal;
+ : receive_block | receive_stmt | invoke | expr | xml_literal;
throw_ex: 'throw' '('ID')' -> ^(THROW ID);
@@ -134,6 +139,12 @@
// Others
+variables
+ : 'var'! v+=variable (','! v+=variable)*;
+variable: ID VAR_MODS* -> ^(VARIABLE ID VAR_MODS*);
+
+partner_link
+ : 'partnerLink' pl+=ID (',' pl+=ID)* -> ^(PARTNERLINK $pl);
// TODO This will not work for any function whose code contains braces
correlation
: '{' corr_mapping (',' corr_mapping)* '}' -> ^(CORRELATION corr_mapping*);
@@ -170,6 +181,8 @@
: '[' (options {greedy=false;} : .)* ']';
// Basic tokens
+VAR_MODS: 'unique' | 'external' | ('string' | 'int' | 'float');
+SEMI : ';';
ID : (LETTER | '_' ) (LETTER | DIGIT | '_' )*;
INT : (DIGIT )+ ;
STRING : '"' ( ESCAPE_SEQ | ~('\\'|'"') )* '"';
Modified: ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g?rev=603103&r1=603102&r2=603103&view=diff
==============================================================================
--- ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g (original)
+++ ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPELWalker.g Mon Dec 10 16:17:58 2007
@@ -33,7 +33,8 @@
process_stmt
: (pick | sequence | flow | if_ex | while_ex | until_ex | foreach | forall | try_ex | scope_ex
- | invoke | receive | reply | assign | throw_ex | wait_ex | exit)+;
+ | invoke | receive | reply | assign | throw_ex | wait_ex | exit
+ | variable)+;
block : ^(SEQUENCE process_stmt);
@@ -88,6 +89,10 @@
exit : EXIT;
// Other
+variable: ^(VARIABLE ID VAR_MODS*);
+
+partner_link
+ : ^(PARTNERLINK ID*);
correlation
: ^(CORRELATION corr_mapping*);
corr_mapping
Modified: ode/sandbox/simpel/src/test/resources/compile-tests-ok.simpel
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/test/resources/compile-tests-ok.simpel?rev=603103&r1=603102&r2=603103&view=diff
==============================================================================
--- ode/sandbox/simpel/src/test/resources/compile-tests-ok.simpel (original)
+++ ode/sandbox/simpel/src/test/resources/compile-tests-ok.simpel Mon Dec 10 16:17:58 2007
@@ -6,7 +6,7 @@
process ReceiveReply {
receive(my_pl, start_op, msg_in) {
- reply(msg_in)
+ reply(msg_in);
}
}
@@ -15,8 +15,19 @@
#
process ReceiveInvoke {
- msg_in = receive(my_pl, start_op)
- invoke(other_pl, other_op, msg_in)
+ msg_in = receive(my_pl, start_op);
+ invoke(other_pl, other_op, msg_in);
+}
+
+#=============================================================
+# Variable declaration
+#
+
+process VariableDecl {
+ msg_in = receive(my_pl, start_op);
+ var temp unique;
+# temp = [$msg_in.part/count + 2]
+ invoke(other_pl, other_op, temp);
}
#=============================================================
@@ -24,11 +35,11 @@
#
process ScopeAlarm {
- msg_in = receive(my_pl, start_op)
+ msg_in = receive(my_pl, start_op);
scope {
- wait([PT59S])
+ wait([PT59S]);
} alarm([PT60S]) {
- exit
+ exit;
}
}
@@ -36,12 +47,12 @@
# Scope with event
#
-process ScopeAlarm {
- msg_in = receive(my_pl, start_op)
+process ScopeEvent {
+ msg_in = receive(my_pl, start_op);
scope {
- wait([PT60S])
+ wait([PT60S]);
} event(stop_pl, stop, msg) {
- exit
+ exit;
}
}
@@ -49,12 +60,12 @@
# Scope with compensate
#
-process ScopeAlarm {
- msg_in = receive(my_pl, start_op)
+process ScopeCompensate {
+ msg_in = receive(my_pl, start_op);
scope {
- wait([PT60S])
+ wait([PT60S]);
} compensation {
- invoke(pl, op, msg)
+ invoke(pl, op, msg);
}
}
@@ -63,15 +74,15 @@
#
process ScopeAll {
- msg_in = receive(my_pl, start_op)
+ msg_in = receive(my_pl, start_op);
scope {
- wait([PT60S])
+ wait([PT60S]);
} alarm([PT60S]) {
- exit
+ exit;
} event(stop_pl, stop, msg) {
- exit
+ exit;
} compensation {
- invoke(pl, op, msg)
+ invoke(pl, op, msg);
}
}
@@ -81,8 +92,8 @@
process HelloWorld {
receive(my_pl, hello_op, msg_in) {
- msg_out = msg_in + " World"
- reply(msg_out)
+ msg_out = msg_in + " World";
+ reply(msg_out);
}
}
@@ -91,15 +102,15 @@
#
process TryCatch {
- msg_in = receive(my_pl, start_op)
+ msg_in = receive(my_pl, start_op);
try {
- invoke(other_pl, other_op, msg_in)
+ invoke(other_pl, other_op, msg_in);
} catch(SomeFault f1) {
- invoke(fault_pl, inform_f1, f1)
+ invoke(fault_pl, inform_f1, f1);
} catch(OtherFault f2) {
- invoke(fault_pl, inform_f2, f2)
+ invoke(fault_pl, inform_f2, f2);
} catch(unknown) {
- invoke(fault_pl, inform_unknown_fault, unknown)
+ invoke(fault_pl, inform_unknown_fault, unknown);
}
}
@@ -112,12 +123,12 @@
}
process ExternalCounter {
receive(my_pl, start_op, msg_in) {
- resp = <root><count start="0">0</count></root>
+ resp = <root><count start="0">0</count></root>;
while(resp < 10) {
- invoke(partner_pl, partner_start_op, msg_in)
- resp = receive(partner_pl, partner_reply_op)
+ invoke(partner_pl, partner_start_op, msg_in);
+ resp = receive(partner_pl, partner_reply_op);
}
- reply(resp)
+ reply(resp);
}
}
@@ -130,10 +141,10 @@
}
process SimpleCorrel {
- orderMsg = receive(my_pl, start_op)
+ orderMsg = receive(my_pl, start_op);
# The correlation implies orderId(incoming_msg) == orderId(init_msg)
- receive(my_pl, corr_op, {orderId: orderId(orderMsg)})
+ receive(my_pl, corr_op, {orderId: orderId(orderMsg)});
}
#=============================================================
@@ -154,13 +165,13 @@
}
process DoubleCorrel {
- orderMsg = receive(my_pl, start_op)
+ orderMsg = receive(my_pl, start_op);
# The correlation implies orderIdFromShippment(incoming_msg) == orderIdFromOrder(order_msg)
# and shipIdFromShippment(incoming_msg) == shipIdFromOrder(order_msg),
receive(my_pl, corr_op, {
orderIdFromShippment: orderIdFromOrder(order_msg),
shipIdFromShippment: shipIdFromOrder(order_msg)
- })
+ });
}