Changes between Version 8 and Version 9 of CIVLite
- Timestamp:
- 09/22/23 08:52:29 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CIVLite
v8 v9 27 27 vardecl: 'var' typedvar ';' 28 28 formallist: typedvar (',' typedvar)* 29 function: 'fun' type ID '(' formallist? ')' '{' (typedvar ';')* transition* '}' 30 31 // OOPS I messed this up. Need to have multiple transitions departing from 32 // one location.... 33 34 35 transition: (ID ':')? ('when' expr)? action ('goto' ID ';')? 36 // if label is missing, location will be created anyway with some ID number 37 // if when is missing, guard is 1 (true) 38 // if goto is missing, goto the next statement 39 29 function: 'fun' type ID '(' formallist? ')' '{' (typedvar ';')* labelnode* '}' 30 labelnode: (ID ':')? node 31 node: transition | '{' transition* '}' // multiple transitions may depart a node 32 transition: (expr '->')? action ('goto' ID ';')? 33 // if guard is missing, guard is 1 (true) 34 // if goto is missing, goto the next location 40 35 action: assignment call spawn noop return wait begin_atomic end_atomic assertion print 41 36 assignment: lval '=' expr ';' … … 70 65 }}} 71 66 72 Example: two threads are generated and go through a barrier:67 Example: 73 68 {{{ 74 int %s[]; 75 fun void %thread(int %id) { 76 print "Hello from thread ", %id, "\n"; 77 when %id==0 %s[0]=1; goto L1; 78 69 fun void %thread(int %tid) { 70 print "Hello from thread ", %tid, "\n"; 71 } 72 fun void %main() { 73 proc %p1; 74 proc %p2; 75 %p1 = spawn %thread(1); 76 %p2 = spawn %thread(2); 77 wait %p1; 78 wait %p2; 79 print "Done.\n"; 79 80 } 80 81 }}} 82 83 Example (2-thread barrier): 84 {{{ 85 86 }}}
