Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis15/doc/syntax.md
ViewVC logotype

View of /branches/vis15/doc/syntax.md

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4125 - (download) (annotate)
Thu Jun 30 22:14:09 2016 UTC (2 years, 11 months ago) by jhr
File size: 5185 byte(s)
bring syntax documentation up to date
## Collected syntax of Diderot


:---------------|:--:|:-----------
_Program_ | ::= | { _GlobalDcl_ } [ _Block_ ] _StrandDcl_ _InitialStrands_ [ _GlobalInitially_ ] [ _GlobalUpdate_ ]
| | | |
_GlobalDcl_ | ::= | _InputDcl_
  | \| | _ConstDcl_
  | \| | _GlobalVarDcl_
  | \| | _FunctionDcl_
| | | |
_InputDcl_ | ::= | **input** _ValueType_ Id [ `(` String `)` ] [ `=` _ConstExpr_ ] `;`
| | | |
_ConstDcl_ | ::= | **const** _ValueType_ Id [ `=` _ConstExpr_ ] `;`
| | | |
_GlobalVarDcl_ | ::= | _Type_ Id [ `=` _Expression_ ] `;`
| | | |
_FunctionDcl_ | ::= | **function** _Type_ Id `(` _Parameters_ `)` `=` _Expression_ `;`
  | \| | **function** _Type_ Id `(` _Parameters_ `)` _Block_
| | | |
_Parameters_ | ::= | [ _Parameter_ { `,` _Parameter_ } ]
| | | |
_Parameter_ | ::= | _Type_ Id
| | | |
_StrandDcl_ | ::= | **strand** Id _Parameters_ `{` { _StateVarDcl_ } [ _Block_ ] { _MethodDcl_ } `}`
| | | |
_MethodDcl_ | ::= | _MethodName_ _Block_
| | | |
_MethodName_ | ::= | **initially** \| **update** \| **stabilize**
| | | |
_InitialStrands_ | ::= | **collection** _Comprehension_
  | \| | **grid** `(` _ConstExpr_ `)` _Comprehension_
| | | |
_GlobalInitially_ | ::= | **initially** _Block_
| | | |
_GlobalUpdate_ | ::= | **update** _Block_
| | | |
_Block_ | ::= | `{` { _Statement_ } `}`
| | | |
_Statement_ | ::= | _Block_
  | \| | **if** `(` _Expression_ `)` _Block_ { _ElseIf_ } [ **else** _Block_ ]
  | \| | **foreach** `(` _Iterator_ `)` _Block_
  | \| | **print** `(` _Expression_ { `,` _Expression_ } `)` `;`
  | \| | **new** Id `(` _Arguments_ `)` `;`
  | \| | **stabilize** `;`
  | \| | **die** `;`
  | \| | **continue** `;`
  | \| | **return** _Expression_ `;`
  | \| | _Type_ Id `=` _Expression_ `;`
  | \| | Id _AssignOp_ _Expression_ `;`
| | | |
_ElseIf_ | ::= | **else** **if** `(` _Expression_ `)` _Block_
| | | |
_AssignOp_ | ::= | `=` \| `+=` \| `-=` \| `*=` \| `/=` \| `%=`
| | | |
_Type_ | ::= | **image** `(` _ConstExpr_ `)` _Shape_
  | \| | **field** `#` _Dimension_ `(` _ConstExpr_ `)` _Shape_
  | \| | **kernel** `#` _Dimension_
  | \| | _ConcreteType_
| | | |
_Dimension_ | ::= | Int
| | | |
_ConcreteType_ | ::= | _PrimitiveType_ [ _SequenceDims_ ]
| | | |
_SequenceDims_ | ::= |
  | \| | `[` `]`
  | \| | `[` _ConstExpr_ `]`
| | | |
_PrimitiveType_ | ::= | **tensor** _Shape_
  | \| | **vec2**
  | \| | **vec3**
  | \| | **vec4**
  | \| | **mat2**
  | \| | **mat3**
  | \| | **mat4**
  | \| | **bool**
  | \| | **int**
  | \| | **real**
  | \| | **string**
| | | |
_Shape_ | ::= | `[` [ _ConstExpr_ { `,` _ConstExpr_ } ] `]`
| | | |
_Comprehension_ | ::= | `{` _Expression_ `|` _Iterator_ { `,` _Iterator_ } `}`
| | | |
_Iterator_ | ::= | Id **in** _Expression_
| | | |
_Expression_ | ::= | _RangeExpr_ [ `?` _Expression_ `:` _Expression_ ]
| | | |
_RangeExpr_ | ::= | _OrExpr_ `..` _OrExpr_
| | | |
_OrExpr_ | ::= | _AndExpr_ { `||` _AndExpr_ }
| | | |
_AndExpr_ | ::= | _CompareExpr_ { `&&` _CompareExpr_ }
| | | |
_CompareExpr_ | ::= | _AddExpr_ { _CompareOp_ _AddExpr_ }
| | | |
_CompareOp_ | ::= |  `<` \| `<=` \| `==` \| `!=` \| `>=` \| `>`
| | | |
_AddExpr_ | ::= | _MultiplyExpr_ { _AddOp_ _MultiplyExpr_ }
| | | |
_AddOp_ | ::= | `+` \| `-` \| `@`
| | | |
_MultiplyExpr_ | ::= | _PrefixExpr_ { _MultiplyOp_ _PrefixExpr_ }
| | | |
_MultiplyOp_ | ::= | `*` \| `/` \| `%` \| `⊛` \| `•` \| `×` \| `⊗` \| `:`
| | | |
_PrefixExpr_ | ::= | _PowerExpr_
  | \| | _PrefixOp_ _PrefixExpr_
| | | |
_PrefixOp_ | ::= | `-` \| `!`
| | | |
_PowerExpr_ | ::= | _SuffixExpr_ { `^` _SuffixExpr_ }
| | | |
_SuffixExpr_ | ::= | _DiffExpr_ { _Suffix_ }
  | \| | **real** `(` _Expression_ `)`
  | \| | **load** `(` _ConstExpr_ `)`
  | \| | **image** `(` _ConstExpr_ `)`
| | | |
_Suffix_ | ::= | _AtomicExpr_
  | \| | `[` _Indices_ `]`
  | \| | `.` Id
| | | |
_Indices_ | ::= | _IndexExpr_ [ `,` _IndexExpr_ ]
| | | |
_IndexExpr_ | ::= | _Expression_
  | \| | `:`
| | | |
_DiffExpr_ | ::= | _AtomicExpr_
  | \| | _DiffOp_ _DiffExpr_
| | | |
_DiffOp_ | ::= | `∇` \| `∇⊗` \| `∇×` \| `∇•`
| | | |
_AtomicExpr_ | ::= | Id
  |  \| | Id `#` _Dimension_
  | \| | Int
  | \| | Real
  | \| | String
  | \| | **true**
  | \| | **false**
  | \| | **identity** `[` _ConstExpr_ `]`
  | \| | **zeros** [ _Shape_ ]
  | \| | **nan** [ _Shape_ ]
  | \| | `{` _Expression_ `|` _Iterator_ `}`
  | \| | `(` _Expression_ { `,` _Expression_ } `)`
  | \| | `{` `}`
  | \| | `{` _Expression_ { `,` _Expression_ } `}`
  | \| | `[` _Expression_ { `,` _Expression_ } `]`
  | \| | `|` _Expression_ `|`
  | \| | `(` _Arguments_ `)`
| | | |
_Arguments_ | ::= | [ _Expression_ { `,` _Expression_ } ]
| | | |
_ConstExpr_ | ::= | _Expression_


### Syntactic restrictions

* Constant expressions (_ConstExpr_) are restricted to have a concrete type (_ConcreteType_)
  and be can be evaluated statically.

* When indexing a tensor or field (e.g., `e1[e2]`), the index expression must be a constant
  expression.

* Conditional expressions must have value type.

* Assignment to global variables is not permitted inside strands.

* Strands must have an `update` method

### Questions

* What about tuples?  Can we have sequences of tuples?  Tuples of sequences?  Fields inside
  tuples?

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0