Changes between Version 7 and Version 8 of CIVLite
- Timestamp:
- 09/22/23 07:37:22 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CIVLite
v7 v8 9 9 No boolean type. Instead, int is used. 0 is false, every other int is true (like C). 10 10 11 Parameters have a value that is fixed for the lifetime of the program. They can be 12 hard coded into the program, or set on command line, like CIVL's $input variables. 11 Parameters have a value that is fixed for the lifetime of the program. 12 They don't go in the state. 13 They can be hard coded into the program, or set on command line, like CIVL's $input variables. 13 14 14 15 There is a global scope and a local scope for each function. That's it. … … 16 17 No need to "declare" a function before it is used. There is no notion of a function declaration. 17 18 18 print?19 20 19 Grammar: 21 20 22 21 {{{ 22 constant: INT | 'null' | '{' (constant (',' constant)*)? '}' 23 string: '"' .* '"' 24 type: 'int' | 'proc' | type[] | 'void' 25 typedvar: type ID 26 paramdecl: 'param' typedvar ('=' constant)? ';' 27 vardecl: 'var' typedvar ';' 28 formallist: typedvar (',' typedvar)* 29 function: 'fun' type ID '(' formallist? ')' '{' (typedvar ';')* transition* '}' 23 30 24 constant: INT | 'null' | '{' (constant (',' constant)*)? '}' 31 // OOPS I messed this up. Need to have multiple transitions departing from 32 // one location.... 25 33 26 string: '"' .* '"'27 28 type: 'int' | 'proc' | type[]29 30 typedvar: type ID31 32 paramdecl: 'param' typedvar ('=' constant)? ';'33 34 vardecl: 'var' typedvar ';'35 36 formallist: typedvar (',' typedvar)*37 38 function: 'fun' type ID '(' formallist? ')' '{' (typedvar ';')* transition* '}'39 34 40 35 transition: (ID ':')? ('when' expr)? action ('goto' ID ';')? … … 44 39 45 40 action: assignment call spawn noop return wait begin_atomic end_atomic assertion print 46 47 41 assignment: lval '=' expr ';' 48 49 42 invocation: ID '(' exprlist? ')' 50 51 43 call: (lval '=')? 'call' invocation ';' 52 53 44 spawn: (lval '=')? 'spawn' invocation ';' 54 55 45 noop: ';' 56 57 46 return: 'return' expr? ';' 58 59 47 wait : 'wait' expr ';' 60 61 48 begin_atomic: 'begin_atomic' ';' 62 63 49 end_atomic: 'end_atomic' ';' 64 65 50 assertion: 'assert' expr ';' 66 67 51 print: 'print' exprstrlst ';' 68 69 52 exprstrlst: exprstr (',' exprstr)* 70 71 53 exprstr: expr | string 72 73 54 exprlist: expr (',' expr)* 74 75 55 lval: ID | lval '[' expr ']' 76 56 … … 78 58 | 'array' '(' type ',' expr ',' expr ')' // array(element-type, length, value) 79 59 60 program: paramdecl* vardecl* function* 61 }}} 80 62 81 program: paramdecl* vardecl* function* 82 83 Example: 84 63 Array example: 64 {{{ 85 65 fun int[][] %zero2d(int %n, int %m) { 86 66 int[][] %a; … … 88 68 return %a; 89 69 } 90 91 70 }}} 92 71 72 Example: two threads are generated and go through a barrier: 73 {{{ 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 79 } 80 }}}
