Changes between Version 8 and Version 9 of CIVLite


Ignore:
Timestamp:
09/22/23 08:52:29 (3 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CIVLite

    v8 v9  
    2727vardecl: 'var' typedvar ';'
    2828formallist: 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 
     29function: 'fun' type ID '(' formallist? ')' '{' (typedvar ';')* labelnode* '}'
     30labelnode: (ID ':')? node
     31node: transition | '{' transition* '}' // multiple transitions may depart a node
     32transition: (expr '->')? action ('goto' ID ';')?
     33// if guard is missing, guard is 1 (true)
     34// if goto is missing, goto the next location
    4035action: assignment call spawn noop return wait begin_atomic end_atomic assertion print
    4136assignment: lval '=' expr ';'
     
    7065}}}
    7166
    72 Example: two threads are generated and go through a barrier:
     67Example:
    7368{{{
    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  
     69fun void %thread(int %tid) {
     70  print "Hello from thread ", %tid, "\n";
     71}
     72fun 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";
    7980}
    8081}}}
     82
     83Example (2-thread barrier):
     84{{{
     85
     86}}}