| | 1 | |
| | 2 | CIVLite: is an experimental light-weight model checking language and tool. |
| | 3 | |
| | 4 | Types are: ints, proc, and arrays of any type. |
| | 5 | |
| | 6 | Identifiers all start with `%`. |
| | 7 | |
| | 8 | No boolean type. Instead, int is used. 0 is false, every other int is true (like C). |
| | 9 | |
| | 10 | Parameters have a value that is fixed for the lifetime of the program. They can be |
| | 11 | hard coded into the program, or set on command line, like CIVL's $input variables. |
| | 12 | |
| | 13 | There is a global scope and a local scope for each function. That's it. |
| | 14 | |
| | 15 | Grammar: |
| | 16 | |
| | 17 | {{{ |
| | 18 | |
| | 19 | constant: INT | 'null' | '{' constant* '}' |
| | 20 | |
| | 21 | type: 'int' | 'proc' | type[] |
| | 22 | |
| | 23 | typedvar: type ID |
| | 24 | |
| | 25 | paramdecl: 'param' typedvar ('=' constant)? ';' |
| | 26 | |
| | 27 | vardecl: 'var' typedvar ';' |
| | 28 | |
| | 29 | formallist: typedvar (',' typedvar)* |
| | 30 | |
| | 31 | function: 'fun' type ID '(' formallist? ')' '{' (typedvar ';')* transition* '}' |
| | 32 | |
| | 33 | transition: (ID ':')? ('when' expr)? action ('goto' ID ';')? |
| | 34 | // if label is missing, location will be created anyway with some ID number |
| | 35 | // if when is missing, guard is 1 (true) |
| | 36 | // if goto is missing, goto the next statement |
| | 37 | |
| | 38 | action: assignment call spawn noop return wait begin_atomic end_atomic |
| | 39 | |
| | 40 | assignment: lval '=' expr ';' |
| | 41 | |
| | 42 | invocation: ID '(' exprlist? ')' |
| | 43 | |
| | 44 | call: (lval '=')? 'call' invocation ';' |
| | 45 | |
| | 46 | spawn: (lval '=')? 'spawn' invocation ';' |
| | 47 | |
| | 48 | noop: ';' |
| | 49 | |
| | 50 | return: 'return' expr? ';' |
| | 51 | |
| | 52 | wait : 'wait' expr ';' |
| | 53 | |
| | 54 | begin_atomic: 'begin_atomic' ';' |
| | 55 | |
| | 56 | end_atomic: 'end_atomic' ';' |
| | 57 | |
| | 58 | exprlist: expr (',' expr)* |
| | 59 | |
| | 60 | lval: ID | lval '[' expr ']' |
| | 61 | |
| | 62 | expr: lval | constant | '(' expr ')' | expr '+' expr | ... |
| | 63 | // operators: + - * / mod - == != >= > < <= && || ! |
| | 64 | |
| | 65 | program: paramdecl* vardecl* function* |
| | 66 | |
| | 67 | |
| | 68 | }}} |