| 3 | | |
| 4 | | Questions: |
| 5 | | * fix notation for contracts |
| 6 | | * can labels, whens, chooses be optional? See proposed statement grammar below. |
| 7 | | * quotes around variables in declarations? Could be awkward but might simplify parsing. |
| 8 | | * quotes around function names in definitions, prototypes? Could be awkward. |
| 9 | | * is there ever a need for a function prototype? Could variable decl notation be used instead? NO, variable decls are different, those are state variables. |
| 10 | | * should we leave our parameter names in abstract and system functions? They are not needed for anything. THEY ARE NEEDED FOR CONTRACTS, sometimes, and maybe for documentation. Consider making them optional. |
| 11 | | |
| 12 | | Proposed statement grammar: |
| 13 | | {{{ |
| 14 | | statement: (ID ':')? (simpleStmt | chooseStmt) |
| 15 | | |
| 16 | | simpleStmt: |
| 17 | | (guardedStmt | primitiveStmt) ('goto' ID ';')? |
| 18 | | |
| 19 | | guardedStmt: |
| 20 | | 'when' expr 'do' primitiveStmt |
| 21 | | |
| 22 | | chooseStmt: 'begin choose' simpleStmt+ 'end choose' |
| 23 | | }}} |
| 24 | | |
| 25 | | If goto is missing, default is the next location. |
| 26 | | If guard missing, deafult is true. |
| 27 | | |
| | 22 | == Grammar == |
| | 23 | |
| | 24 | This is not the complete grammar, but the high-level overview. |
| | 25 | |
| | 26 | {{{ |
| | 27 | program: block ; |
| | 28 | block: typedef* vardecl* fundef* statement+ ; |
| | 29 | statement: (ID ':')? (simpleStmt | chooseStmt | blockStmt) ; |
| | 30 | simpleStmt: (guardedStmt | primitiveStmt) ('goto' ID)? ; |
| | 31 | guardedStmt: 'when' expr 'do' primitiveStmt ; |
| | 32 | chooseStmt: 'begin choose' simpleStmt+ 'end choose' ; |
| | 33 | blockStmt: '{' block '}' ; |
| | 34 | typedef: 'type' ID '=' typeName ';' ; |
| | 35 | vardecl: 'var' varopts? ID ':' typeName ';' ; |
| | 36 | varopts: '[' varopt+ ']' ; |
| | 37 | varopt: 'input' | 'output' ; |
| | 38 | fundef: 'fun' funopts? ... |
| | 39 | }}} |
| | 40 | |
| | 41 | Notes: |
| | 42 | * If goto is missing, default is the next location. |
| | 43 | * If guard missing, deafult is true. |
| | 44 | |
| | 402 | |
| | 403 | == Questions == |
| | 404 | |
| | 405 | * fix notation for contracts |
| | 406 | * can labels, whens, chooses be optional? See proposed statement grammar below. |
| | 407 | * quotes around variables in declarations? Could be awkward but might simplify parsing. |
| | 408 | * quotes around function names in definitions, prototypes? Could be awkward. |
| | 409 | * is there ever a need for a function prototype? Could variable decl notation be used instead? NO, variable decls are different, those are state variables. |
| | 410 | * should we leave our parameter names in abstract and system functions? They are not needed for anything. THEY ARE NEEDED FOR CONTRACTS, sometimes, and maybe for documentation. Consider making them optional. |
| | 411 | |
| | 412 | |