Changes between Version 95 and Version 96 of IR
- Timestamp:
- 11/30/15 09:15:28 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IR
v95 v96 7 7 * a CIVL-IR program represents a guarded-transition system explicitly 8 8 * as in CIVL-C, there are functions, scopes, and functions can be defined in any scope 9 * all blocks (including a function body) consist of the following elements, in this order: 9 * all blocks (including a function definition) consist of the following elements, in this order: 10 * a sequence of contract clauses (for function definitions only) 10 11 * a sequence of type definitions 11 * a sequence of variable declarations with no initializers12 * a sequence of variable declarations (with no initializers) 12 13 * a sequence of function definitions 13 * a sequence of labeled statements. Each clause in the labeled statement is a `when` statement with some guard and a primitive statement, followed by a `goto` statement14 * a body, which encodes a program graph. 14 15 * an array is declared without any length expression. When it is initialized it can specify length. 15 16 * curly braces are used only to indicate scopes, as in `{ // new scope ... }` … … 19 20 * unlike C, there is no "array-pointer pun". If an array `a` needs to be converted to a pointer, you must use addr(asub(a, 0))`. 20 21 * there are no automatic conversions. All conversions must be by explicit casts or other functions. Operations such as numeric addition (`add`) require that both operands have the exact same type. 22 * in general, symbols can be used before they are defined, as long as they are in scope. For example, a function `f` can call `g`, even if `g` is defined after `f` in the same scope. There is no need for a "prototype". Similarly, a type definition can refer to a type defined later, or can refer to itself in its own definition. 21 23 22 24 == Grammar == … … 26 28 {{{ 27 29 program: block ; 28 block : typedef* vardecl* fundef* statement+;29 statement: blockStmt| basicStmt ;30 blockitems: typedef* vardecl* fundef* statement* ; 31 statement: '{' blockitems '}' | basicStmt ; 30 32 basicStmt: (ID ':')? (simpleStmt | chooseStmt) ; 31 33 simpleStmt: (guardedStmt | primitiveStmt) ('goto' ID)? ; 32 34 guardedStmt: 'when' expr 'do' primitiveStmt ; 33 35 chooseStmt: 'begin choose' simpleStmt+ 'end choose' ; 34 blockStmt: '{' block '}' ;35 36 typedef: 'type' ID '=' typeName ';' ; 36 37 vardecl: 'var' varopts? ID ':' typeName ';' ; 37 38 varopts: '[' varopt+ ']' ; 38 39 varopt: 'input' | 'output' ; 39 fundef: 'fun' funopts? ... 40 fundef: 'fun' funopts? ID '(' paramlist ')' ':' typeName '{' conclause* blockitems '}' ; 41 funopts: '[' funopt+ ']' ; 42 conclause : 'assigns' expr ';' 43 | 'requires' expr ';' 44 | 'ensures' expr ';' 45 ... 46 ; 40 47 }}} 41 48
