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/06 02:08:54 UTC

svn commit: r601590 - 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: Wed Dec  5 17:08:46 2007
New Revision: 601590

URL: http://svn.apache.org/viewvc?rev=601590&view=rev
Log:
Scope, alarm, event, compensation and compensate.

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=601590&r1=601589&r2=601590&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 Wed Dec  5 17:08:46 2007
@@ -7,7 +7,8 @@
 }
 tokens {
     PROCESS; PICK; SEQUENCE; FLOW; IF; ELSEIF; ELSE; WHILE; UNTIL; FOREACH; FORALL; INVOKE;
-    RECEIVE; REPLY; ASSIGN; THROW; WAIT; EXIT; TIMEOUT; TRY; CATCH; CATCH_ALL;
+    RECEIVE; REPLY; ASSIGN; THROW; WAIT; EXIT; TIMEOUT; TRY; CATCH; CATCH_ALL; SCOPE; EVENT;
+    ALARM; COMPENSATION; COMPENSATE;
     EXPR; EXT_EXPR; XML_LITERAL;
 }
 @parser::header {
@@ -71,7 +72,7 @@
 block	:	'{' process_stmt '}' -> ^(SEQUENCE process_stmt);
 
 process_stmt
-	:	(pick | flow | if_ex | while_ex | until_ex | foreach | forall | try_ex
+	:	(pick | flow | if_ex | while_ex | until_ex | foreach | forall | try_ex | scope_ex
 		| invoke | receive | reply | assign | throw_ex | wait_ex |  exit)+;
 		
 // Structured activities
@@ -95,7 +96,16 @@
 
 try_ex	:	'try' tb=block catch_ex* ('catch' '(' ID ')' cb=block)? -> ^(TRY $tb catch_ex* ^(CATCH_ALL ID $cb)?);
 		
-catch_ex:	'catch''(' ns_id ID ')' block -> ^(CATCH ns_id ID block);
+catch_ex:	'catch' '(' ns_id ID ')' block -> ^(CATCH ns_id ID block);
+
+scope_ex:	'scope' ('(' ID ')')? block scope_stmt* -> ^(SCOPE ID? block scope_stmt*);
+scope_stmt
+	:	event | alarm | compensation;
+
+event	:	'event' '(' p=ID ',' o=ID ',' m=ID ')' block -> ^(EVENT $p $o $m block);
+alarm	:	'alarm' '(' expr ')' block -> ^(ALARM expr block);
+compensation
+	:	'compensation' block -> ^(COMPENSATION block);
 
 // Simple activities
 invoke	:	'invoke' '(' p=ID ',' o=ID (',' in=ID)? ')' -> ^(INVOKE $p $o $in?);
@@ -108,9 +118,12 @@
 rvalue
 	:	 receive | invoke | expr | xml_literal;
 	
-throw_ex:	'throw' ID -> ^(THROW ID);
+throw_ex:	'throw' '('ID')' -> ^(THROW ID);
+
+wait_ex	:	'wait' '('expr')' -> ^(WAIT expr);
 
-wait_ex	:	'wait' expr -> ^(WAIT expr);
+compensate
+	:	'compensate' ('(' ID ')')? -> ^(COMPENSATE ID?);
 
 exit	:	'exit' -> ^(EXIT);
 
@@ -140,7 +153,7 @@
 		'<' { xml=parseXMLLiteral(); } -> { xml };
 
 EXT_EXPR
-	:	'`' (options {greedy=false;} : .)* '`';
+	:	'[' (options {greedy=false;} : .)* ']';
 
 // Basic tokens
 ID	:	(LETTER | '_' ) (LETTER | DIGIT | '_' )*;

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=601590&r1=601589&r2=601590&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 Wed Dec  5 17:08:46 2007
@@ -32,7 +32,7 @@
 process	:	^(PROCESS ID block) { System.out.println("PROCESS " + $ID.text); };
 
 process_stmt
-	:	(pick | sequence | flow | if_ex | while_ex | until_ex | foreach | forall | try_ex
+	:	(pick | sequence | flow | if_ex | while_ex | until_ex | foreach | forall | try_ex | scope_ex
 		| invoke | receive | reply | assign | throw_ex | wait_ex |  exit)+;
 		
 block	:	^(SEQUENCE process_stmt);
@@ -60,6 +60,15 @@
 	:	^(CATCH_ALL ID block);
 		
 catch_ex:	^(CATCH ID ID block);
+
+scope_ex:	^(SCOPE ID? block scope_stmt*);
+scope_stmt
+	:	event | alarm | compensation;
+
+event	:	^(EVENT ID ID ID block);
+alarm	:	^(ALARM expr block);
+compensation
+	:	^(COMPENSATION block);
 
 // Simple activities
 invoke	:	^(INVOKE p=ID o=ID in=ID?);

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=601590&r1=601589&r2=601590&view=diff
==============================================================================
--- ode/sandbox/simpel/src/test/resources/compile-tests-ok.simpel (original)
+++ ode/sandbox/simpel/src/test/resources/compile-tests-ok.simpel Wed Dec  5 17:08:46 2007
@@ -20,6 +20,62 @@
 }
 
 #=============================================================
+# Scope with alarm
+#
+
+process ScopeAlarm {
+  msg_in = receive(my_pl, start_op)
+  scope {
+    wait([PT59S])
+  } alarm([PT60S]) {
+    exit
+  }
+}
+
+#=============================================================
+# Scope with event
+#
+
+process ScopeAlarm {
+  msg_in = receive(my_pl, start_op)
+  scope {
+    wait([PT60S])
+  } event(stop_pl, stop, msg) {
+    exit
+  }
+}
+
+#=============================================================
+# Scope with compensate
+#
+
+process ScopeAlarm {
+  msg_in = receive(my_pl, start_op)
+  scope {
+    wait([PT60S])
+  } compensation {
+    invoke(pl, op, msg)
+  }
+}
+
+#=============================================================
+# Scope with everything
+#
+
+process ScopeAlarm {
+  msg_in = receive(my_pl, start_op)
+  scope {
+    wait([PT60S])
+  } alarm([PT60S]) {
+    exit
+  } event(stop_pl, stop, msg) {
+    exit
+  } compensation {
+    invoke(pl, op, msg)
+  }
+}
+
+#=============================================================
 # Hello World (basic assignment)
 #
 
@@ -40,8 +96,10 @@
     invoke(other_pl, other_op, msg_in)
   } catch(SomeFault f1) {
     invoke(fault_pl, inform_f1, f1)
-  } catch(f2) {
-    invoke(fault_pl, inform_fault, f2)
+  } catch(OtherFault f2) {
+    invoke(fault_pl, inform_f2, f2)
+  } catch(unknown) {
+    invoke(fault_pl, inform_unknown_fault, unknown)
   }
 }