| | 20 | |
| | 21 | \note{The chapter is not up to date.} |
| | 22 | |
| | 23 | In this chapter, we provide a simplified grammar of the Fortress concrete |
| | 24 | syntax as documentation, to enable Fortress programmers to understand it |
| | 25 | more easily. It includes unimplemented Fortress language features |
| | 26 | such as dimensions and units, tests and properties, coercions, and where |
| | 27 | clauses. The full Fortress grammar is described in \appref{cst}. |
| | 28 | |
| | 29 | |
| | 30 | The simplified grammar does not describe the details of the uses of |
| | 31 | operators, whitespaces, and semicolons. |
| | 32 | Instead, they are described as follows according to three |
| | 33 | different contexts influencing the whitespace-sensitivity of expressions: |
| | 34 | \begin{description} |
| | 35 | \item[statement] Expressions |
| | 36 | immediately enclosed by an expression block are in a statement-like context. |
| | 37 | Multiple expressions can appear on a line if they are separated |
| | 38 | (or terminated) by semicolons. If an expression can legally end |
| | 39 | at the end of a line, it does; if it cannot, it does not. |
| | 40 | A prefix or infix operator that lacks its last operand |
| | 41 | prevents an expression from ending. For example, |
| | 42 | %an = expression + |
| | 43 | % spanning + |
| | 44 | % four + |
| | 45 | % lines |
| | 46 | %a = oneLiner |
| | 47 | %four() ; on(); one(); line(); |
| | 48 | \begin{Fortress} |
| | 49 | \(\VAR{an} = \null\)\pushtabs\=\+\(\VAR{expression} +\)\\ |
| | 50 | \( \VAR{spanning} +\)\\ |
| | 51 | \( \VAR{four} +\)\\ |
| | 52 | \( \VAR{lines}\)\-\\\poptabs |
| | 53 | \(a = \VAR{oneLiner}\)\\ |
| | 54 | \(\VAR{four}() ; \VAR{on}(); \VAR{one}(); \VAR{line}();\) |
| | 55 | \end{Fortress} |
| | 56 | |
| | 57 | \item[nested] |
| | 58 | An expression or list of expressions |
| | 59 | immediately enclosed by parentheses or braces |
| | 60 | is nested. Multiple expressions are separated by commas, |
| | 61 | and the end of a line does not end an expression. Because of this |
| | 62 | effect, the meaning of a several lines of code can change if they |
| | 63 | are wrapped in parentheses. Parentheses can also be used to ensure |
| | 64 | that a multiline expression is not terminated prematurely without |
| | 65 | paying special attention to line endings. |
| | 66 | %lhs = rhs |
| | 67 | %- aSeparateExpression |
| | 68 | % |
| | 69 | %postProfit(revenue |
| | 70 | % - expenses) |
| | 71 | \begin{Fortress} |
| | 72 | \(\VAR{lhs} = \VAR{rhs}\)\\ |
| | 73 | \(- \VAR{aSeparateExpression}\)\\[4pt] |
| | 74 | \(\VAR{postProfit}(\null\)\pushtabs\=\+\(\VAR{revenue}\)\\ |
| | 75 | \( - \VAR{expenses})\)\-\\\poptabs |
| | 76 | \end{Fortress} |
| | 77 | |
| | 78 | \item[pasted] |
| | 79 | Fortress has special syntax for matrix pasting. Within square |
| | 80 | brackets, whitespace-separated expressions are treated (depending |
| | 81 | on their type) as either matrix elements or submatrices within a |
| | 82 | row. Because whitespace is the separator, it also ends expressions |
| | 83 | where possible. In addition, newline-or-semicolon-separated |
| | 84 | rows are pasted vertically along their columns. Higher-dimensional |
| | 85 | pasting is expressed with repeated semicolons, but repeated newlines |
| | 86 | do not have the same effect. |
| | 87 | %id2a = [ 1 0 ; 0 1 ] |
| | 88 | %id2b = [ 1 0 ; |
| | 89 | % 0 1 ] |
| | 90 | %id2c = [ 1 0 |
| | 91 | % 0 1 ] |
| | 92 | %cube2 = [ 1 0 ; 0 1 ;; 1 -1 ; 1 1 ] |
| | 93 | \begin{Fortress} |
| | 94 | \(\VAR{id2a} = [1\;0 ; 0\;1\,]\)\\ |
| | 95 | \(\VAR{id2b} = [\null\)\pushtabs\=\+\(1\;0 ;\)\\ |
| | 96 | \( 0\;1\,]\)\-\\\poptabs |
| | 97 | \(\VAR{id2c} = [\null\)\pushtabs\=\+\(1\;0\)\\ |
| | 98 | \( 0\;1\,]\)\-\\\poptabs |
| | 99 | \({cube}_{2} = [1\;0 ; 0\;1 ;; 1 -1 ; 1\;1\,]\) |
| | 100 | \end{Fortress} |
| | 101 | |
| | 102 | \end{description} |
| | 103 | |
| | 104 | |
| | 105 | The simplified grammar is written in the extended BNF form |
| | 106 | with the following three postfix operators: |
| | 107 | \begin{itemize} |
| | 108 | \item ?: which means that its argument (the symbol or group of symbols in |
| | 109 | parentheses to the left of the operator) can appear zero or one time |
| | 110 | \item $*$: which means that its argument can appear zero or more times |
| | 111 | \item $+$: which means that its argument can appear one or more times |
| | 112 | \end{itemize} |
| | 113 | |
| | 114 | \section{Components and APIs} |
| | 115 | \begin{tabular}{lll} |
| | 116 | \emph{File} &::=& \emph{CompilationUnit}\\ |
| | 117 | &$|$& \option{\emph{Imports}} \emph{Exports} \option{\emph{Decls}}\\ |
| | 118 | &$|$& \option{\emph{Imports}} \emph{AbsDecls} \\ |
| | 119 | &$|$& \emph{Imports} \option{\emph{AbsDecls}}\\ |
| | 120 | |
| | 121 | \emph{CompilationUnit} &::=& \emph{Component}\\ |
| | 122 | &$|$&\emph{Api}\\ |
| | 123 | |
| | 124 | \emph{Component} &::=& |
| | 125 | \option{\KWD{native}} |
| | 126 | \KWD{component} \emph{APIName} |
| | 127 | \option{\emph{Imports}} \emph{Exports} \option{\emph{Decls}} \KWD{end} |
| | 128 | \options{\option{\KWD{component}} \emph{APIName}}\\ |
| | 129 | \emph{Api} &::=& |
| | 130 | \KWD{api} \emph{APIName} |
| | 131 | \option{\emph{Imports}} \option{\emph{AbsDecls}} \KWD{end} |
| | 132 | \options{\option{\KWD{api}} \emph{APIName}}\\ |
| | 133 | |
| | 134 | \emph{Imports} &::=& \emph{Import}$^+$\\ |
| | 135 | |
| | 136 | \emph{Import} |
| | 137 | &::=& \KWD{import} \KWD{api} \emph{AliasedAPINames} \\ |
| | 138 | &$|$& \KWD{import} \emph{ImportedNames} \\ |
| | 139 | |
| | 140 | \emph{ImportedNames} |
| | 141 | &::=& \emph{APIName} \EXP{.} \{ \EXP{...} \} |
| | 142 | \options{\KWD{except} \emph{SimpleNames}}\\ |
| | 143 | &$|$& \emph{APIName} \EXP{.} \{ \emph{AliasedSimpleNameList} |
| | 144 | \options{\EXP{,} \EXP{...}} \}\\ |
| | 145 | &$|$& \emph{QualifiedName} \options{\KWD{as} \emph{Id}}\\ |
| | 146 | |
| | 147 | \emph{SimpleNames} &::=& \emph{SimpleName} \\ |
| | 148 | &$|$& \{ \emph{SimpleNameList} \}\\ |
| | 149 | |
| | 150 | \emph{SimpleNameList} &::=& \emph{SimpleName}(\EXP{,} \emph{SimpleName})$^*$ \\ |
| | 151 | |
| | 152 | \emph{AliasedSimpleName} &::=& \emph{Id} \options{\KWD{as} \emph{Id}}\\ |
| | 153 | &$|$& \KWD{opr} \option{\KWD{BIG}} (\emph{Encloser} $|$ \emph{Op}) |
| | 154 | \options{\KWD{as} (\emph{Encloser} $|$ \emph{Op})} \\ |
| | 155 | &$|$& \KWD{opr} \option{\KWD{BIG}} \emph{EncloserPair} \options{\KWD{as} \emph{EncloserPair}} \\ |
| | 156 | |
| | 157 | \emph{AliasedSimpleNameList} |
| | 158 | &::=& \emph{AliasedSimpleName}(\EXP{,} \emph{AliasedSimpleName})$^*$ \\ |
| | 159 | |
| | 160 | \emph{AliasedAPINames} &::=& \emph{AliasedAPIName} \\ |
| | 161 | &$|$& \{ \emph{AliasedAPINameList} \}\\ |
| | 162 | |
| | 163 | \emph{AliasedAPIName} &::=& \emph{APIName} \options{\KWD{as} \emph{Id}}\\ |
| | 164 | |
| | 165 | \emph{AliasedAPINameList} |
| | 166 | &::=& \emph{AliasedAPIName}(\EXP{,} \emph{AliasedAPIName})$^*$ \\ |
| | 167 | |
| | 168 | \emph{Exports} &::=& \emph{Export}$^+$\\ |
| | 169 | |
| | 170 | \emph{Export} &::=& \KWD{export} \emph{APINames} \\ |
| | 171 | |
| | 172 | \emph{APINames} &::=& \emph{APIName} \\ |
| | 173 | &$|$& \{ \emph{APINameList} \}\\ |
| | 174 | |
| | 175 | \emph{APINameList} &::=& \emph{APIName}(\EXP{,} \emph{APIName})$^*$ \\ |
| | 176 | \end{tabular} |
| | 177 | |
| | 178 | |
| | 179 | \section{Top-level Declarations} |
| | 180 | \begin{tabular}{lll} |
| | 181 | \emph{Decls} &::=& \emph{Decl}$^+$\\ |
| | 182 | |
| | 183 | \emph{Decl} &::=& \emph{TraitDecl}\\ |
| | 184 | &$|$& \emph{ObjectDecl}\\ |
| | 185 | &$|$& \emph{VarDecl}\\ |
| | 186 | &$|$& \emph{FnDecl}\\ |
| | 187 | &$|$& \emph{DimUnitDecl}\\ |
| | 188 | &$|$& \emph{TypeAlias}\\ |
| | 189 | &$|$& \emph{TestDecl}\\ |
| | 190 | &$|$& \emph{PropertyDecl}\\ |
| | 191 | &$|$& \emph{ExternalSyntax}\\ |
| | 192 | |
| | 193 | \emph{AbsDecls} &::=& \emph{AbsDecl}$^+$\\ |
| | 194 | |
| | 195 | \emph{AbsDecl} &::=& \emph{AbsTraitDecl}\\ |
| | 196 | &$|$& \emph{AbsObjectDecl}\\ |
| | 197 | &$|$& \emph{AbsVarDecl}\\ |
| | 198 | &$|$& \emph{AbsFnDecl}\\ |
| | 199 | &$|$& \emph{DimUnitDecl}\\ |
| | 200 | &$|$& \emph{TypeAlias}\\ |
| | 201 | &$|$& \emph{TestDecl}\\ |
| | 202 | &$|$& \emph{PropertyDecl}\\ |
| | 203 | &$|$& \emph{AbsExternalSyntax} |
| | 204 | \end{tabular} |
| | 205 | |
| | 206 | \section{Trait and Object Declarations} |
| | 207 | A \emph{TraitHeaderFront} may have 0 or 1 of each \emph{TraitClause}. |
| | 208 | |
| | 209 | \begin{tabular}{lll} |
| | 210 | \emph{TraitDecl} &::=& \option{\emph{TraitMods}} |
| | 211 | \emph{TraitHeaderFront} \emph{TraitClauses} \option{\emph{GoInATrait}} \KWD{end} |
| | 212 | \options{\option{\KWD{trait}} \emph{Id}} \\ |
| | 213 | |
| | 214 | \emph{TraitHeaderFront} &::=& |
| | 215 | \KWD{trait} \emph{Id} \option{\emph{StaticParams}} \option{\emph{ExtendsWhere}} \\ |
| | 216 | |
| | 217 | \emph{TraitClauses} &::=& \emph{TraitClause}$^*$\\ |
| | 218 | |
| | 219 | \emph{TraitClause} &::=& \emph{Excludes} \\ |
| | 220 | &$|$& \emph{Comprises} \\ |
| | 221 | &$|$& \emph{Where} \\ |
| | 222 | |
| | 223 | \emph{GoInATrait} |
| | 224 | &::=& \option{\emph{Coercions}} |
| | 225 | \emph{GoFrontInATrait} \option{\emph{GoBackInATrait}}\\ |
| | 226 | &$|$& \option{\emph{Coercions}} \emph{GoBackInATrait} \\ |
| | 227 | &$|$& \emph{Coercions}\\ |
| | 228 | |
| | 229 | \emph{Coercions} &::=& \emph{Coercion}$^+$\\ |
| | 230 | |
| | 231 | \emph{GoFrontInATrait} &::=& \emph{GoesFrontInATrait}$^+$\\ |
| | 232 | |
| | 233 | \emph{GoesFrontInATrait} |
| | 234 | &::=& \emph{AbsFldDecl} \\ |
| | 235 | &$|$& \emph{GetterSetterDecl} \\ |
| | 236 | &$|$& \emph{PropertyDecl} \\ |
| | 237 | |
| | 238 | \emph{GoBackInATrait} &::=& \emph{GoesBackInATrait}$^+$\\ |
| | 239 | |
| | 240 | \emph{GoesBackInATrait} |
| | 241 | &::=& \emph{MdDecl} \\ |
| | 242 | &$|$& \emph{PropertyDecl} \\ |
| | 243 | |
| | 244 | \emph{ObjectDecl} &::=& \option{\emph{ObjectMods}} |
| | 245 | \emph{ObjectHeader} \option{\emph{GoInAnObject}} \KWD{end} |
| | 246 | \options{\option{\KWD{object}} \emph{Id}}\\ |
| | 247 | |
| | 248 | \emph{ObjectHeader} &::=& \KWD{object} \emph{Id} |
| | 249 | \option{\emph{StaticParams}} \option{\emph{ObjectValParam}} |
| | 250 | \option{\emph{ExtendsWhere}} \emph{FnClauses} \\ |
| | 251 | |
| | 252 | \end{tabular} |
| | 253 | |
| | 254 | \begin{tabular}{lll} |
| | 255 | \emph{ObjectValParam} &::=& \texttt( \option{\emph{ObjectParams}} \texttt) \\ |
| | 256 | |
| | 257 | \emph{ObjectParams} |
| | 258 | &::=& (\emph{ObjectParam} \EXP{,})$^*$ \options{\emph{ObjectVarargs} \EXP{,}} |
| | 259 | \emph{ObjectKeyword}(\EXP{,}\emph{ObjectKeyword})$^*$\\ |
| | 260 | &$|$& (\emph{ObjectParam} \EXP{,})$^*$ \emph{ObjectVarargs}\\ |
| | 261 | &$|$& \emph{ObjectParam} (\EXP{,} \emph{ObjectParam})$^*$\\ |
| | 262 | |
| | 263 | \emph{ObjectVarargs} &::=& \KWD{transient} \emph{Varargs}\\ |
| | 264 | |
| | 265 | \emph{ObjectKeyword} &::=& \emph{ObjectParam}\EXP{=}\emph{Expr}\\ |
| | 266 | |
| | 267 | \emph{ObjectParam} &::=& \option{\emph{ParamFldMods}} \emph{Param} \\ |
| | 268 | &$|$& \KWD{var} \KWD{transient} \emph{ParamWType} \\ |
| | 269 | &$|$& \option{\KWD{transient}} \KWD{var} \emph{ParamWType} \\ |
| | 270 | &$|$& \KWD{transient} \emph{Param} \\ |
| | 271 | |
| | 272 | \emph{ParamWType} &::=& \emph{BindId} \option{\emph{IsType}} \\ |
| | 273 | |
| | 274 | \emph{GoInAnObject} |
| | 275 | &::=& \option{\emph{Coercions}} |
| | 276 | \emph{GoFrontInAnObject} \option{\emph{GoBackInAnObject}}\\ |
| | 277 | &$|$& \option{\emph{Coercions}} \emph{GoBackInAnObject} \\ |
| | 278 | &$|$& \emph{Coercions}\\ |
| | 279 | |
| | 280 | \emph{GoFrontInAnObject} &::=& \emph{GoesFrontInAnObject}$^+$\\ |
| | 281 | |
| | 282 | \emph{GoesFrontInAnObject} |
| | 283 | &::=& \emph{FldDecl} \\ |
| | 284 | &$|$& \emph{GetterSetterDef} \\ |
| | 285 | &$|$& \emph{PropertyDecl} \\ |
| | 286 | |
| | 287 | \emph{GoBackInAnObject} &::=& \emph{GoesBackInAnObject}$^+$\\ |
| | 288 | |
| | 289 | \emph{GoesBackInAnObject} |
| | 290 | &::=& \emph{MdDef} \\ |
| | 291 | &$|$& \emph{PropertyDecl} \\ |
| | 292 | |
| | 293 | \emph{AbsTraitDecl} &::=& \option{\emph{AbsTraitMods}} |
| | 294 | \emph{TraitHeaderFront} \emph{AbsTraitClauses} |
| | 295 | \option{\emph{AbsGoInATrait}} \KWD{end} |
| | 296 | \options{\option{\KWD{trait}} \emph{Id}} \\ |
| | 297 | |
| | 298 | \emph{AbsTraitClauses} &::=& \emph{AbsTraitClause}$^*$\\ |
| | 299 | |
| | 300 | \emph{AbsTraitClause} &::=& \emph{Excludes} \\ |
| | 301 | &$|$& \emph{AbsComprises} \\ |
| | 302 | &$|$& \emph{Where} \\ |
| | 303 | |
| | 304 | \emph{AbsGoInATrait} |
| | 305 | &::=& \option{\emph{AbsCoercions}} |
| | 306 | \emph{AbsGoFrontInATrait} \option{\emph{AbsGoBackInATrait}}\\ |
| | 307 | &$|$& \option{\emph{AbsCoercions}} \emph{AbsGoBackInATrait} \\ |
| | 308 | &$|$& \emph{AbsCoercions}\\ |
| | 309 | |
| | 310 | \emph{AbsCoercions} &::=& \emph{AbsCoercion}$^+$\\ |
| | 311 | |
| | 312 | \emph{AbsGoFrontInATrait} &::=& \emph{AbsGoesFrontInATrait}$^+$\\ |
| | 313 | |
| | 314 | \emph{AbsGoesFrontInATrait} |
| | 315 | &::=& \emph{ApiFldDecl} \\ |
| | 316 | &$|$& \emph{AbsGetterSetterDecl} \\ |
| | 317 | &$|$& \emph{PropertyDecl} \\ |
| | 318 | |
| | 319 | \emph{AbsGoBackInATrait} &::=& \emph{AbsGoesBackInATrait}$^+$\\ |
| | 320 | |
| | 321 | \emph{AbsGoesBackInATrait} |
| | 322 | &::=& \emph{AbsMdDecl} \\ |
| | 323 | &$|$& \emph{PropertyDecl} \\ |
| | 324 | |
| | 325 | \emph{AbsObjectDecl} &::=& \option{\emph{AbsObjectMods}} |
| | 326 | \emph{ObjectHeader} \option{\emph{AbsGoInAnObject}} \KWD{end} |
| | 327 | \options{\option{\KWD{object}} \emph{Id}}\\ |
| | 328 | |
| | 329 | \emph{AbsGoInAnObject} |
| | 330 | &::=& \option{\emph{AbsCoercions}} |
| | 331 | \emph{AbsGoFrontInAnObject} \option{\emph{AbsGoBackInAnObject}}\\ |
| | 332 | &$|$& \option{\emph{AbsCoercions}} \emph{AbsGoBackInAnObject} \\ |
| | 333 | &$|$& \emph{AbsCoercions}\\ |
| | 334 | |
| | 335 | \emph{AbsGoFrontInAnObject} &::=& \emph{AbsGoesFrontInAnObject}$^+$\\ |
| | 336 | |
| | 337 | \emph{AbsGoesFrontInAnObject} |
| | 338 | &::=& \emph{ApiFldDecl} \\ |
| | 339 | &$|$& \emph{AbsGetterSetterDecl} \\ |
| | 340 | &$|$& \emph{PropertyDecl} \\ |
| | 341 | |
| | 342 | \emph{AbsGoBackInAnObject} &::=& \emph{AbsGoesBackInAnObject}$^+$\\ |
| | 343 | |
| | 344 | \emph{AbsGoesBackInAnObject} |
| | 345 | &::=& \emph{AbsMdDecl} \\ |
| | 346 | &$|$& \emph{PropertyDecl} \\ |
| | 347 | |
| | 348 | \end{tabular} |
| | 349 | |
| | 350 | \section{Variable Declarations} |
| | 351 | \begin{tabular}{lll} |
| | 352 | \emph{VarDecl} |
| | 353 | &::=& \option{\emph{VarMods}} \emph{VarWTypes} \emph{InitVal} \\ |
| | 354 | &$|$& \option{\emph{VarImmutableMods}} \emph{BindIdOrBindIdTuple} \EXP{=} \emph{Expr}\\ |
| | 355 | &$|$& \option{\emph{VarMods}} \emph{BindIdOrBindIdTuple} \EXP{\mathrel{\mathtt{:}}} \emph{Type}\EXP{...} |
| | 356 | \emph{InitVal} \\ |
| | 357 | &$|$& \option{\emph{VarMods}} \emph{BindIdOrBindIdTuple} \EXP{\mathrel{\mathtt{:}}} \emph{TupleType} |
| | 358 | \emph{InitVal} \\ |
| | 359 | |
| | 360 | \emph{VarMods} &::=& \emph{VarMod}$^+$\\ |
| | 361 | |
| | 362 | \emph{VarImmutableMods} &::=& \emph{VarImmutableMod}$^+$\\ |
| | 363 | |
| | 364 | \emph{VarMod} &::=& \emph{AbsVarMod} $|$ \KWD{private}\\ |
| | 365 | |
| | 366 | \emph{VarImmutableMod} &::=& \emph{AbsVarImmutableMod} $|$ \KWD{private}\\ |
| | 367 | |
| | 368 | \emph{VarWTypes} &::=& \emph{VarWType} \\ |
| | 369 | &$|$& \texttt{(} \emph{VarWType}(\EXP{,} \emph{VarWType})$^+$ \texttt{)}\\ |
| | 370 | |
| | 371 | \emph{VarWType} &::=& \emph{BindId} \emph{IsType}\\ |
| | 372 | |
| | 373 | \emph{InitVal} &::=& (\EXP{=}$|$\EXP{\ASSIGN}) \emph{Expr} \\ |
| | 374 | |
| | 375 | \emph{AbsVarDecl} &::=& \option{\emph{AbsVarMods}} \emph{VarWTypes}\\ |
| | 376 | &$|$& \option{\emph{AbsVarMods}} \emph{BindIdOrBindIdTuple} \EXP{\mathrel{\mathtt{:}}} \emph{Type}\EXP{...}\\ |
| | 377 | &$|$& \option{\emph{AbsVarMods}} \emph{BindIdOrBindIdTuple} \EXP{\mathrel{\mathtt{:}}} \emph{TupleType}\\ |
| | 378 | |
| | 379 | \emph{AbsVarMods} &::=& \emph{AbsVarMod}$^+$\\ |
| | 380 | |
| | 381 | \emph{AbsVarMod} &::=& \KWD{var} $|$ \KWD{test}\\ |
| | 382 | |
| | 383 | \emph{AbsVarImmutableMod} &::=& \KWD{test}\\ |
| | 384 | \end{tabular} |
| | 385 | |
| | 386 | \section{Function Declarations} |
| | 387 | \begin{tabular}{lll} |
| | 388 | \emph{FnDecl} |
| | 389 | &::=& \option{\emph{FnMods}} \emph{FnHeaderFront} \emph{FnHeaderClause} |
| | 390 | \EXP{=} \emph{Expr} \\ |
| | 391 | &$|$& \option{\emph{FnMods}} \emph{AbsFnHeaderFront} \emph{FnHeaderClause}\\ |
| | 392 | &$|$& \emph{FnSig} \\ |
| | 393 | |
| | 394 | \emph{FnSig} &::=& \emph{SimpleName} \EXP{\mathrel{\mathtt{:}}} \emph{Type}\\ |
| | 395 | |
| | 396 | \emph{AbsFnDecl} &::=& \option{\emph{AbsFnMods}} \emph{AbsFnHeaderFront} |
| | 397 | \emph{FnHeaderClause}\\ |
| | 398 | &$|$& \emph{FnSig} \\ |
| | 399 | |
| | 400 | \emph{FnHeaderFront} |
| | 401 | &::=& \emph{NamedFnHeaderFront}\\ |
| | 402 | &$|$& \emph{OpHeaderFront} \\ |
| | 403 | |
| | 404 | \emph{AbsFnHeaderFront} |
| | 405 | &::=& \emph{AbsNamedFnHeaderFront}\\ |
| | 406 | &$|$& \emph{AbsOpHeaderFront} \\ |
| | 407 | |
| | 408 | \emph{NamedFnHeaderFront} |
| | 409 | &::=& \emph{Id} \option{\emph{StaticParams}} \emph{ValParam} \\ |
| | 410 | |
| | 411 | \emph{AbsNamedFnHeaderFront} |
| | 412 | &::=& \emph{Id} \option{\emph{StaticParams}} \emph{AbsValParam} \\ |
| | 413 | \end{tabular} |
| | 414 | |
| | 415 | \section{Dimension, Unit, Type Alias, Test, Property, and External Syntax |
| | 416 | Declarations} |
| | 417 | \begin{tabular}{lll} |
| | 418 | \emph{DimUnitDecl} |
| | 419 | &::=& |
| | 420 | \KWD{dim} \emph{Id} \options{\EXP{=} \emph{Type}} |
| | 421 | (\KWD{unit} $|$ \KWD{SI\_unit}) \emph{Id}$^+$ |
| | 422 | \options{\EXP{=} \emph{Expr}}\\ |
| | 423 | &$|$& |
| | 424 | \KWD{dim} \emph{Id} |
| | 425 | \options{\EXP{=} \emph{Type}} \options{\KWD{default} \emph{Id}}\\ |
| | 426 | &$|$& |
| | 427 | (\KWD{unit} $|$ \KWD{SI\_unit}) |
| | 428 | \emph{Id}$^+$ \options{\EXP{\mathrel{\mathtt{:}}} \emph{Type}} |
| | 429 | \options{\EXP{=} \emph{Expr}}\\ |
| | 430 | |
| | 431 | \emph{TypeAlias} &::=& \KWD{type} \emph{Id} \option{\emph{StaticParams}} |
| | 432 | \EXP{=} \emph{Type} \\ |
| | 433 | |
| | 434 | \emph{TestDecl} &::=& \KWD{test} \emph{Id} \texttt[\emph{GeneratorClauseList}\texttt] |
| | 435 | \EXP{=} \emph{Expr} \\ |
| | 436 | |
| | 437 | \emph{PropertyDecl} &::=& \KWD{property} \options{\emph{Id} \EXP{=}} |
| | 438 | \options{$\forall$ \emph{ValParam}} \emph{Expr} \\ |
| | 439 | |
| | 440 | \emph{ExternalSyntax} &::=& |
| | 441 | \KWD{syntax} \emph{OpenExpander} \emph{Id} \emph{CloseExpander} |
| | 442 | \EXP{=} \emph{Expr} \\ |
| | 443 | |
| | 444 | \emph{OpenExpander} &::=& \emph{Id}\\ |
| | 445 | &$|$& \emph{LeftEncloser} \\ |
| | 446 | &$|$& \emph{Encloser} \\ |
| | 447 | |
| | 448 | \emph{CloseExpander} &::=& \emph{Id} \\ |
| | 449 | &$|$& \emph{RightEncloser}\\ |
| | 450 | &$|$& \emph{Encloser} \\ |
| | 451 | &$|$& \KWD{end} \\ |
| | 452 | |
| | 453 | \emph{AbsExternalSyntax} &::=& |
| | 454 | \KWD{syntax} \emph{OpenExpander} \emph{Id} \emph{CloseExpander}\\ |
| | 455 | |
| | 456 | \end{tabular} |
| | 457 | |
| | 458 | \section{Headers} |
| | 459 | Each modifier should not appear multiple times in a declaration. |
| | 460 | |
| | 461 | \begin{tabular}{lll} |
| | 462 | \emph{IsType} &::=& \EXP{\mathrel{\mathtt{:}}} \emph{Type}\\ |
| | 463 | |
| | 464 | \emph{ExtendsWhere} &::=& \KWD{extends} \emph{TraitTypeWheres} \\ |
| | 465 | |
| | 466 | \emph{TraitTypeWheres} &::=& \emph{TraitTypeWhere} \\ |
| | 467 | &$|$& \{ \emph{TraitTypeWhereList} \} \\ |
| | 468 | |
| | 469 | \emph{TraitTypeWhereList} &::=& \emph{TraitTypeWhere}(\EXP{,} \emph{TraitTypeWhere})$^*$ \\ |
| | 470 | |
| | 471 | \emph{TraitTypeWhere} &::=& \emph{TraitType} \option{\emph{Where}}\\ |
| | 472 | |
| | 473 | \emph{Extends} &::=& \KWD{extends} \emph{TraitTypes} \\ |
| | 474 | \emph{Excludes} &::=& \KWD{excludes} \emph{TraitTypes} \\ |
| | 475 | \emph{Comprises} &::=& \KWD{comprises} \emph{TraitTypes} \\ |
| | 476 | \emph{AbsComprises} &::=& \KWD{comprises} \emph{ComprisingTypes} \\ |
| | 477 | |
| | 478 | \emph{TraitTypes} &::=& \emph{TraitType} \\ |
| | 479 | &$|$& \{ \emph{TraitTypeList} \} \\ |
| | 480 | \emph{TraitTypeList} &::=& \emph{TraitType}(\EXP{,} \emph{TraitType})$^*$ \\ |
| | 481 | |
| | 482 | \emph{ComprisingTypes} |
| | 483 | &::=& \emph{TraitType} \\ |
| | 484 | &$|$& \texttt{\{} \emph{ComprisingTypeList} \texttt{\}} \\ |
| | 485 | |
| | 486 | \emph{ComprisingTypeList} |
| | 487 | &::=& \EXP{\ldots} \\ |
| | 488 | &$|$& \emph{TraitType}(\EXP{,} \emph{TraitType})$^*$ \options{\EXP{,} \ldots}\\ |
| | 489 | |
| | 490 | \emph{Where} |
| | 491 | &::=& \KWD{where} \bTPl\ \emph{WhereBindingList} \bTPr\ |
| | 492 | \options{\{ \emph{WhereConstraintList} \}}\\ |
| | 493 | &$|$& \KWD{where} \{ \emph{WhereConstraintList} \}\\ |
| | 494 | |
| | 495 | \emph{WhereBindingList} &::=& \emph{WhereBinding}(\EXP{,} |
| | 496 | \emph{WhereBinding})$^*$ \\ |
| | 497 | |
| | 498 | \emph{WhereBinding} &::=& \emph{Id} \option{\emph{Extends}}\\ |
| | 499 | &$|$& \KWD{nat} \emph{Id}\\ |
| | 500 | &$|$& \KWD{int} \emph{Id}\\ |
| | 501 | &$|$& \KWD{bool} \emph{Id}\\ |
| | 502 | &$|$& \KWD{unit} \emph{Id}\\ |
| | 503 | |
| | 504 | \emph{WhereConstraintList} &::=& \emph{WhereConstraint}(\EXP{,} |
| | 505 | \emph{WhereConstraint})$^*$ \\ |
| | 506 | |
| | 507 | \emph{WhereConstraint} |
| | 508 | &::=& \emph{Id} \emph{Extends}\\ |
| | 509 | &$|$& \emph{TypeAlias} \\ |
| | 510 | &$|$& \emph{Type} \KWD{coerces} \emph{Type}\\ |
| | 511 | &$|$& \emph{Type} \KWD{widens} \emph{Type}\\ |
| | 512 | &$|$& \emph{UnitConstraint} \\ |
| | 513 | &$|$& \emph{QualifiedName} \EXP{=} \emph{QualifiedName}\\ |
| | 514 | &$|$& \emph{IntConstraint} \\ |
| | 515 | &$|$& \emph{BoolConstraint} \\ |
| | 516 | |
| | 517 | \emph{UnitConstraint} |
| | 518 | &::=& \TYP{dimensionless} \EXP{=} \emph{Id}\\ |
| | 519 | &$|$& \emph{Id} \EXP{=} \TYP{dimensionless} \\ |
| | 520 | |
| | 521 | \emph{IntConstraint} |
| | 522 | &::=& \emph{IntExpr} $\le$ \emph{IntExpr} \\ |
| | 523 | &$|$& \emph{IntExpr} $<$ \emph{IntExpr} \\ |
| | 524 | &$|$& \emph{IntExpr} $\ge$ \emph{IntExpr} \\ |
| | 525 | &$|$& \emph{IntExpr} $>$ \emph{IntExpr} \\ |
| | 526 | &$|$& \emph{IntExpr} \EXP{=} \emph{IntExpr} \\ |
| | 527 | |
| | 528 | \emph{IntVal} |
| | 529 | &::=& \emph{IntLiteralExpr}\\ |
| | 530 | &$|$& \emph{QualifiedName}\\ |
| | 531 | |
| | 532 | \end{tabular} |
| | 533 | |
| | 534 | \begin{tabular}{lll} |
| | 535 | \emph{IntExpr} |
| | 536 | &::=& \emph{IntVal}\\ |
| | 537 | &$|$& \emph{IntExpr} \EXP{+} \emph{IntExpr}\\ |
| | 538 | &$|$& \emph{IntExpr} \EXP{-} \emph{IntExpr}\\ |
| | 539 | &$|$& \emph{IntExpr} $\csdot$ \emph{IntExpr}\\ |
| | 540 | &$|$& \emph{IntExpr} \emph{IntExpr}\\ |
| | 541 | &$|$& \emph{IntExpr} \texttt{\^} \emph{IntVal}\\ |
| | 542 | &$|$& \texttt{(}\emph{IntExpr}\texttt{)} \\ |
| | 543 | |
| | 544 | \emph{BoolConstraint} |
| | 545 | &::=& \OPR{NOT} \emph{BoolExpr} \\ |
| | 546 | &$|$& \emph{BoolExpr} \OPR{OR} \emph{BoolExpr} \\ |
| | 547 | &$|$& \emph{BoolExpr} \OPR{AND} \emph{BoolExpr} \\ |
| | 548 | &$|$& \emph{BoolExpr} \OPR{IMPLIES} \emph{BoolExpr} \\ |
| | 549 | &$|$& \emph{BoolExpr} \EXP{=} \emph{BoolExpr} \\ |
| | 550 | |
| | 551 | \emph{BoolVal} |
| | 552 | &::=& \VAR{true}\\ |
| | 553 | &$|$& \VAR{false}\\ |
| | 554 | &$|$& \emph{QualifiedName}\\ |
| | 555 | |
| | 556 | \emph{BoolExpr} |
| | 557 | &::=& \emph{BoolVal}\\ |
| | 558 | &$|$& \emph{BoolConstraint}\\ |
| | 559 | &$|$& \texttt{(}\emph{BoolExpr}\texttt{)} \\ |
| | 560 | |
| | 561 | \emph{UnitExpr} |
| | 562 | &::=& \VAR{dimensionless}\\ |
| | 563 | &$|$& \emph{QualifiedName}\\ |
| | 564 | &$|$& \emph{UnitExpr} $\csdot$ \emph{UnitExpr}\\ |
| | 565 | &$|$& \emph{UnitExpr} \emph{UnitExpr}\\ |
| | 566 | &$|$& \emph{UnitExpr} \EXP{/} \emph{UnitExpr}\\ |
| | 567 | &$|$& \emph{UnitExpr} \TYP{per} \emph{UnitExpr}\\ |
| | 568 | &$|$& \emph{UnitExpr} \texttt{\^} \emph{UnitExpr}\\ |
| | 569 | &$|$& \texttt{(}\emph{UnitExpr}\texttt{)} \\ |
| | 570 | |
| | 571 | \emph{FnHeaderClause} &::=& \option{\emph{IsType}} \emph{FnClauses} \\ |
| | 572 | |
| | 573 | \emph{FnClauses} &::=& \option{\emph{Throws}} \option{\emph{Where}} \emph{Contract} \\ |
| | 574 | |
| | 575 | \emph{Throws} &::=& \KWD{throws} \emph{MayTraitTypes}\\ |
| | 576 | |
| | 577 | \emph{MayTraitTypes} &::=& \texttt{\{\}} \\ |
| | 578 | &$|$& \emph{TraitTypes} \\ |
| | 579 | |
| | 580 | \emph{Contract} &::=& \option{\emph{Requires}} \option{\emph{Ensures}} \option{\emph{Invariant}}\\ |
| | 581 | |
| | 582 | \emph{Requires} &::=& |
| | 583 | \KWD{requires} \{ \option{\emph{ExprList}} \} \\ |
| | 584 | |
| | 585 | \emph{Ensures} &::=& |
| | 586 | \KWD{ensures} \{ \option{\emph{EnsuresClauseList}} \} \\ |
| | 587 | |
| | 588 | \emph{EnsuresClauseList} &::=& |
| | 589 | \emph{EnsuresClause}(\EXP{,} \emph{EnsuresClause})$^*$ \\ |
| | 590 | |
| | 591 | \emph{EnsuresClause} &::=& \emph{Expr} \options{\KWD{provided} \emph{Expr}} \\ |
| | 592 | |
| | 593 | \emph{Invariant}&::=& |
| | 594 | \KWD{invariant} \{ \option{\emph{ExprList}} \} \\ |
| | 595 | |
| | 596 | \emph{TraitMods} &::=& \emph{TraitMod}$^+$\\ |
| | 597 | |
| | 598 | \emph{TraitMod} &::=& \emph{AbsTraitMod} $|$ \KWD{private}\\ |
| | 599 | |
| | 600 | \emph{AbsTraitMods} &::=& \emph{AbsTraitMod}$^+$\\ |
| | 601 | |
| | 602 | \emph{AbsTraitMod} &::=& \KWD{value} $|$ \KWD{test}\\ |
| | 603 | |
| | 604 | \emph{ObjectMods} &::=& \emph{TraitMods}\\ |
| | 605 | |
| | 606 | \emph{AbsObjectMods} &::=& \emph{AbsTraitMods}\\ |
| | 607 | |
| | 608 | \emph{MdMods} &::=& \emph{MdMod}$^+$\\ |
| | 609 | |
| | 610 | \emph{MdMod} &::=& \emph{FnMod} $|$ \KWD{override}\\ |
| | 611 | |
| | 612 | \emph{AbsMdMods} &::=& \emph{AbsMdMod}$^+$\\ |
| | 613 | |
| | 614 | \emph{AbsMdMod} &::=& \emph{AbsFnMod} $|$ \KWD{override}\\ |
| | 615 | |
| | 616 | \emph{FnMods} &::=& \emph{FnMod}$^+$\\ |
| | 617 | |
| | 618 | \emph{FnMod} &::=& \emph{AbsFnMod} $|$ \KWD{private}\\ |
| | 619 | |
| | 620 | \emph{AbsFnMods} &::=& \emph{AbsFnMod}$^+$\\ |
| | 621 | |
| | 622 | \emph{AbsFnMod} &::=& \emph{LocalFnMod} $|$ \KWD{test}\\ |
| | 623 | |
| | 624 | \emph{LocalFnMods} &::=& \emph{LocalFnMod}$^+$\\ |
| | 625 | |
| | 626 | \emph{LocalFnMod} &::=& \KWD{atomic} $|$ \KWD{io}\\ |
| | 627 | |
| | 628 | \end{tabular} |
| | 629 | |
| | 630 | \begin{tabular}{lll} |
| | 631 | \emph{ParamFldMods} &::=& \emph{ParamFldMod}$^+$\\ |
| | 632 | |
| | 633 | \emph{ParamFldMod} &::=& |
| | 634 | \KWD{hidden} $|$ \KWD{settable} $|$ \KWD{wrapped}\\ |
| | 635 | |
| | 636 | \emph{FldMods} &::=& \emph{FldMod}$^+$\\ |
| | 637 | |
| | 638 | \emph{FldImmutableMods} &::=& \emph{FldImmutableMod}$^+$\\ |
| | 639 | |
| | 640 | \emph{FldMod} &::=& \KWD{var} $|$ \emph{AbsFldMod}\\ |
| | 641 | |
| | 642 | \emph{FldImmutableMod} &::=& \emph{AbsFldMod}\\ |
| | 643 | |
| | 644 | \emph{AbsFldMods} &::=& \emph{AbsFldMod}$^+$\\ |
| | 645 | |
| | 646 | \emph{AbsFldMod} &::=& \emph{ApiFldMod} $|$ \KWD{wrapped} $|$ \KWD{private}\\ |
| | 647 | |
| | 648 | \emph{ApiFldMods} &::=& \emph{ApiFldMod}$^+$\\ |
| | 649 | |
| | 650 | \emph{ApiFldMod} &::=& \KWD{hidden} $|$ \KWD{settable} $|$ \KWD{test}\\ |
| | 651 | |
| | 652 | \emph{StaticParams} &::=& \bTPl \emph{StaticParamList}\bTPr\\ |
| | 653 | |
| | 654 | \emph{StaticParamList} &::=& \emph{StaticParam}(\EXP{,} \emph{StaticParam})$^*$\\ |
| | 655 | |
| | 656 | \emph{StaticParam} |
| | 657 | &::=& \emph{Id} \option{\emph{Extends}} \options{\KWD{absorbs} \KWD{unit}} \\ |
| | 658 | &$|$& \KWD{nat} \emph{Id} \\ |
| | 659 | &$|$& \KWD{int} \emph{Id} \\ |
| | 660 | &$|$& \KWD{bool} \emph{Id} \\ |
| | 661 | &$|$& \KWD{dim} \emph{Id} \\ |
| | 662 | &$|$& \KWD{unit} \emph{Id} \options{\EXP{\mathrel{\mathtt{:}}} \emph{Type}} |
| | 663 | \options{\KWD{absorbs} \KWD{unit}}\\ |
| | 664 | &$|$& \KWD{opr} \emph{Op} \\ |
| | 665 | |
| | 666 | \emph{StaticArgs} &::=& \bTPl \emph{StaticArgList} \bTPr \\ |
| | 667 | |
| | 668 | \emph{StaticArgList} &::=& \emph{StaticArg}(\EXP{,} \emph{StaticArg})$^*$ \\ |
| | 669 | |
| | 670 | \emph{StaticArg} &::=& |
| | 671 | \emph{Op} \\ |
| | 672 | &$|$& \TYP{Unity} \\ |
| | 673 | &$|$& \TYP{dimensionless}\\ |
| | 674 | &$|$& \EXP{1}\EXP{/}\emph{Type}\\ |
| | 675 | &$|$& \emph{DimPrefixOp} \emph{Type}\\ |
| | 676 | &$|$& \emph{IntExpr}\\ |
| | 677 | &$|$& \emph{BoolExpr}\\ |
| | 678 | &$|$& \emph{Type}\\ |
| | 679 | &$|$& \emph{UnitExpr}\\ |
| | 680 | |
| | 681 | \end{tabular} |
| | 682 | |
| | 683 | \section{Parameters} |
| | 684 | \begin{tabular}{lll} |
| | 685 | \emph{ValParam} &::=& \emph{BindId}\\ |
| | 686 | &$|$& \texttt(\option{\emph{Params}}\texttt)\\ |
| | 687 | |
| | 688 | \emph{AbsValParam} &::=& \texttt(\option{\emph{AbsParams}}\texttt)\\ |
| | 689 | &$|$& \emph{Type}\\ |
| | 690 | |
| | 691 | \emph{Params} |
| | 692 | &::=& (\emph{Param}\EXP{,})$^*$ \options{\emph{Varargs}\EXP{,}} \emph{Keyword}(\EXP{,}\emph{Keyword})$^*$\\ |
| | 693 | &$|$& (\emph{Param}\EXP{,})$^*$ \emph{Varargs}\\ |
| | 694 | &$|$& \emph{Param}(\EXP{,} \emph{Param})$^*$\\ |
| | 695 | |
| | 696 | \emph{AbsParams} |
| | 697 | &::=& (\emph{AbsParam}\EXP{,})$^*$ \options{\emph{Varargs}\EXP{,}} \emph{Keyword}(\EXP{,}\emph{Keyword})$^*$\\ |
| | 698 | &$|$& (\emph{AbsParam}\EXP{,})$^*$ \emph{Varargs}\\ |
| | 699 | &$|$& \emph{AbsParam}(\EXP{,} \emph{AbsParam})$^*$\\ |
| | 700 | |
| | 701 | \emph{VarargsParam} &::=& \emph{BindId}\EXP{\COLONOP}\emph{Type}\EXP{...} \\ |
| | 702 | |
| | 703 | \emph{Varargs} &::=& \emph{VarargsParam}\\ |
| | 704 | |
| | 705 | \emph{Keyword} &::=& \emph{Param}\EXP{=}\emph{Expr} \\ |
| | 706 | |
| | 707 | \emph{PlainParam} &::=& \emph{BindId} \option{\emph{IsType}} \\ |
| | 708 | |
| | 709 | \emph{Param} &::=& \emph{PlainParam}\\ |
| | 710 | |
| | 711 | \emph{AbsPlainParam} &::=& \emph{BindId} \emph{IsType} \\ |
| | 712 | &$|$& \emph{Type} \\ |
| | 713 | |
| | 714 | \emph{AbsParam} &::=& \emph{AbsPlainParam}\\ |
| | 715 | |
| | 716 | \emph{OpHeaderFront} |
| | 717 | &::=& \KWD{opr} \option{\KWD{BIG}} |
| | 718 | (\{\EXP{\mapsto} $|$ \emph{LeftEncloser} $|$ \emph{Encloser}) \option{\emph{StaticParams}} |
| | 719 | \option{\emph{Params}} (\emph{RightEncloser} $|$ \emph{Encloser}) \\ |
| | 720 | &$|$& \KWD{opr} \emph{ValParam} |
| | 721 | (\emph{Op} $|$ \emph{ExponentOp}) \option{\emph{StaticParams}} \\ |
| | 722 | &$|$& \KWD{opr} \option{\KWD{BIG}} |
| | 723 | (\emph{Op} $|$ \texttt{\^} $|$ \emph{Encloser} $|$ $\sum$ $|$ $\prod$) |
| | 724 | \option{\emph{StaticParams}} \emph{ValParam} \\ |
| | 725 | |
| | 726 | \emph{AbsOpHeaderFront} |
| | 727 | &::=& \KWD{opr} \option{\KWD{BIG}} |
| | 728 | (\{\EXP{\mapsto} $|$ \emph{LeftEncloser} $|$ \emph{Encloser}) \option{\emph{StaticParams}} |
| | 729 | \option{\emph{AbsParams}} (\emph{RightEncloser} $|$ \emph{Encloser}) \\ |
| | 730 | &$|$& \KWD{opr} \emph{AbsValParam} |
| | 731 | (\emph{Op} $|$ \emph{ExponentOp}) \option{\emph{StaticParams}} \\ |
| | 732 | &$|$& \KWD{opr} \option{\KWD{BIG}} |
| | 733 | (\emph{Op} $|$ \texttt{\^} $|$ \emph{Encloser} $|$ $\sum$ $|$ $\prod$) |
| | 734 | \option{\emph{StaticParams}} \emph{AbsValParam} \\ |
| | 735 | \end{tabular} |
| | 736 | |
| | 737 | \section{Method Declarations} |
| | 738 | \begin{tabular}{lll} |
| | 739 | \emph{MdDecl} &::=& \emph{MdDef} \\ |
| | 740 | &$|$& \option{\KWD{abstract}} \option{\emph{MdMods}} \emph{AbsMdHeaderFront} |
| | 741 | \emph{FnHeaderClause} \\ |
| | 742 | |
| | 743 | \emph{MdDef} &::=& \option{\emph{MdMods}} \emph{MdHeaderFront} \emph{FnHeaderClause} |
| | 744 | \EXP{=} \emph{Expr} \\ |
| | 745 | |
| | 746 | \emph{AbsMdDecl} &::=& |
| | 747 | \option{\KWD{abstract}} \option{\emph{AbsMdMods}} \emph{AbsMdHeaderFront} |
| | 748 | \emph{FnHeaderClause} \\ |
| | 749 | |
| | 750 | \emph{MdHeaderFront} &::=& \emph{NamedMdHeaderFront}\\ |
| | 751 | &$|$& \emph{OpMdHeaderFront} \\ |
| | 752 | |
| | 753 | \emph{AbsMdHeaderFront} &::=& \emph{AbsNamedMdHeaderFront}\\ |
| | 754 | &$|$& \emph{AbsOpMdHeaderFront} \\ |
| | 755 | |
| | 756 | \emph{NamedMdHeaderFront} &::=& |
| | 757 | \emph{Id} \option{\emph{StaticParams}} \emph{MdValParam} \\ |
| | 758 | |
| | 759 | \emph{AbsNamedMdHeaderFront} &::=& |
| | 760 | \emph{Id} \option{\emph{StaticParams}} \emph{AbsMdValParam} \\ |
| | 761 | |
| | 762 | \emph{GetterSetterDecl} &::=& \emph{GetterSetterDef} \\ |
| | 763 | &$|$& \option{\KWD{abstract}} \option{\emph{FnMods}} |
| | 764 | \emph{GetterSetterMod} \emph{AbsMdHeaderFront} \emph{FnHeaderClause} \\ |
| | 765 | |
| | 766 | \emph{GetterSetterDef} &::=& \option{\emph{FnMods}} \emph{GetterSetterMod} |
| | 767 | \emph{MdHeaderFront} \emph{FnHeaderClause} |
| | 768 | \EXP{=} \emph{Expr} \\ |
| | 769 | |
| | 770 | \emph{GetterSetterMod} &::=& \KWD{getter} $|$ \KWD{setter}\\ |
| | 771 | |
| | 772 | \emph{AbsGetterSetterDecl} &::=& \option{\KWD{abstract}} \option{\emph{AbsFnMods}} |
| | 773 | \emph{GetterSetterMod} \emph{AbsMdHeaderFront} \emph{FnHeaderClause} \\ |
| | 774 | |
| | 775 | \emph{Coercion} &::=& |
| | 776 | \KWD{coerce}\option{\emph{StaticParams}}\texttt(\emph{BindId} \emph{IsType}\texttt)\emph{CoercionClauses} \option{\KWD{widens}} \EXP{=} \emph{Expr}\\ |
| | 777 | |
| | 778 | \emph{AbsCoercion} &::=& |
| | 779 | \KWD{coerce}\option{\emph{StaticParams}}\texttt(\emph{BindId} \emph{IsType}\texttt)\emph{CoercionClauses} \option{\KWD{widens}}\\ |
| | 780 | |
| | 781 | \emph{CoercionClauses} &::=& |
| | 782 | \option{\emph{CoercionWhere}} |
| | 783 | \option{\emph{Ensures}} \option{\emph{Invariant}}\\ |
| | 784 | |
| | 785 | \emph{CoercionWhere} |
| | 786 | &::=& \KWD{where} \bTPl\ \emph{WhereBindingList} \bTPr\ |
| | 787 | \options{\{ \emph{CoercionWhereConstraintList} \}}\\ |
| | 788 | &$|$& \KWD{where} \{ \emph{CoercionWhereConstraintList} \}\\ |
| | 789 | |
| | 790 | \emph{CoercionWhereConstraintList} &::=& \emph{CoercionWhereConstraint}(\EXP{,} |
| | 791 | \emph{CoercionWhereConstraint})$^*$ \\ |
| | 792 | |
| | 793 | \emph{CoercionWhereConstraint} &::=& \emph{WhereConstraint}\\ |
| | 794 | &$|$& \emph{Type} \KWD{widens} \KWD{or} \KWD{coerces} \emph{Type}\\ |
| | 795 | |
| | 796 | \end{tabular} |
| | 797 | |
| | 798 | \section{Method Parameters} |
| | 799 | \begin{tabular}{lll} |
| | 800 | \emph{MdValParam} &::=& \texttt( \option{\emph{MdParams}} \texttt) \\ |
| | 801 | |
| | 802 | \emph{AbsMdValParam} &::=& \texttt( \option{\emph{AbsMdParams}} \texttt) \\ |
| | 803 | |
| | 804 | \emph{MdParams} |
| | 805 | &::=& (\emph{MdParam}\EXP{,})$^*$ \options{\emph{Varargs}\EXP{,}} \emph{MdKeyword}(\EXP{,}\emph{MdKeyword})$^*$\\ |
| | 806 | &$|$& (\emph{MdParam}\EXP{,})$^*$ \emph{Varargs}\\ |
| | 807 | &$|$& \emph{MdParam}(\EXP{,} \emph{MdParam})$^*$\\ |
| | 808 | |
| | 809 | \emph{AbsMdParams} |
| | 810 | &::=& (\emph{AbsMdParam}\EXP{,})$^*$ \options{\emph{Varargs}\EXP{,}} \emph{MdKeyword}(\EXP{,}\emph{MdKeyword})$^*$\\ |
| | 811 | &$|$& (\emph{AbsMdParam}\EXP{,})$^*$ \emph{Varargs}\\ |
| | 812 | &$|$& \emph{AbsMdParam}(\EXP{,} \emph{AbsMdParam})$^*$\\ |
| | 813 | |
| | 814 | \emph{MdKeyword} &::=& \emph{MdParam}\EXP{=}\emph{Expr} \\ |
| | 815 | |
| | 816 | \emph{MdParam} &::=& \emph{Param} \\ |
| | 817 | &$|$& \KWD{self} \\ |
| | 818 | |
| | 819 | \emph{AbsMdParam} &::=& \KWD{self} \\ |
| | 820 | &$|$& \emph{AbsParam} \\ |
| | 821 | |
| | 822 | \emph{OpMdHeaderFront} |
| | 823 | &::=& \KWD{opr} \option{\KWD{BIG}} |
| | 824 | (\{\EXP{\mapsto} $|$ \emph{LeftEncloser} $|$ \emph{Encloser}) \option{\emph{StaticParams}} |
| | 825 | \option{\emph{Params}}\\ |
| | 826 | && (\emph{RightEncloser} $|$ \emph{Encloser}) |
| | 827 | \options{\EXP{\ASSIGN} \texttt( \emph{SubscriptAssignParam} \texttt)} |
| | 828 | \\ |
| | 829 | &$|$& \KWD{opr} \emph{ValParam} |
| | 830 | (\emph{Op} $|$ \emph{ExponentOp}) \option{\emph{StaticParams}} \\ |
| | 831 | &$|$& \KWD{opr} \option{\KWD{BIG}} |
| | 832 | (\emph{Op} $|$ \texttt{\^} $|$ \emph{Encloser} $|$ $\sum$ $|$ $\prod$) |
| | 833 | \option{\emph{StaticParams}} \emph{ValParam} \\ |
| | 834 | |
| | 835 | \emph{AbsOpMdHeaderFront} |
| | 836 | &::=& \KWD{opr} \option{\KWD{BIG}} |
| | 837 | (\{\EXP{\mapsto} $|$ \emph{LeftEncloser} $|$ \emph{Encloser}) \option{\emph{StaticParams}} |
| | 838 | \option{\emph{AbsParams}}\\ |
| | 839 | && (\emph{RightEncloser} $|$ \emph{Encloser}) |
| | 840 | \options{\EXP{\ASSIGN} \texttt( \emph{AbsSubscriptAssignParam} \texttt)} |
| | 841 | \\ |
| | 842 | &$|$& \KWD{opr} \emph{AbsValParam} |
| | 843 | (\emph{Op} $|$ \emph{ExponentOp}) \option{\emph{StaticParams}} \\ |
| | 844 | &$|$& \KWD{opr} \option{\KWD{BIG}} |
| | 845 | (\emph{Op} $|$ \texttt{\^} $|$ \emph{Encloser} $|$ $\sum$ $|$ $\prod$) |
| | 846 | \option{\emph{StaticParams}} \emph{AbsValParam} \\ |
| | 847 | |
| | 848 | \emph{SubscriptAssignParam} |
| | 849 | &::=& \emph{Varargs}\\ |
| | 850 | &$|$& \emph{Param}\\ |
| | 851 | |
| | 852 | \emph{AbsSubscriptAssignParam} |
| | 853 | &::=& \emph{Varargs}\\ |
| | 854 | &$|$& \emph{AbsParam}\\ |
| | 855 | \end{tabular} |
| | 856 | |
| | 857 | \section{Field Declarations} |
| | 858 | \begin{tabular}{lll} |
| | 859 | \emph{FldDecl} |
| | 860 | &::=& \option{\emph{FldMods}} \emph{FldWTypes} \emph{InitVal} \\ |
| | 861 | &$|$& \option{\emph{FldImmutableMods}} \emph{BindIdOrBindIdTuple} \EXP{=} \emph{Expr}\\ |
| | 862 | &$|$& \option{\emph{FldMods}} \emph{BindIdOrBindIdTuple} \EXP{\mathrel{\mathtt{:}}} \emph{Type}\EXP{...} |
| | 863 | \emph{InitVal} \\ |
| | 864 | &$|$& \option{\emph{FldMods}} \emph{BindIdOrBindIdTuple} \EXP{\mathrel{\mathtt{:}}} \emph{TupleType} |
| | 865 | \emph{InitVal} \\ |
| | 866 | |
| | 867 | \emph{FldWTypes} &::=& \emph{FldWType} \\ |
| | 868 | &$|$& \texttt{(} \emph{FldWType}(\EXP{,} \emph{FldWType})$^+$ \texttt{)}\\ |
| | 869 | |
| | 870 | \emph{FldWType} &::=& \emph{BindId} \emph{IsType}\\ |
| | 871 | |
| | 872 | \end{tabular} |
| | 873 | |
| | 874 | \section{Abstract Field Declarations} |
| | 875 | \begin{tabular}{lll} |
| | 876 | \emph{AbsFldDecl} |
| | 877 | &::=& \option{\emph{AbsFldMods}} \emph{AbsFldWTypes}\\ |
| | 878 | &$|$& \option{\emph{AbsFldMods}} \emph{BindIdOrBindIdTuple} \EXP{\mathrel{\mathtt{:}}} \emph{Type}\EXP{...}\\ |
| | 879 | &$|$& \option{\emph{AbsFldMods}} \emph{BindIdOrBindIdTuple} \EXP{\mathrel{\mathtt{:}}} \emph{TupleType}\\ |
| | 880 | |
| | 881 | \emph{AbsFldWTypes} &::=& \emph{AbsFldWType} \\ |
| | 882 | &$|$& \texttt{(} \emph{AbsFldWType}(\EXP{,} \emph{AbsFldWType})$^+$ \texttt{)}\\ |
| | 883 | |
| | 884 | \emph{AbsFldWType} &::=& \emph{BindId} \emph{IsType}\\ |
| | 885 | |
| | 886 | \emph{ApiFldDecl} &::=& \option{\emph{ApiFldMods}} \emph{BindId} \emph{IsType}\\ |
| | 887 | |
| | 888 | \end{tabular} |
| | 889 | |
| | 890 | \section{Expressions} |
| | 891 | \begin{tabular}{lll} |
| | 892 | \emph{Expr} |
| | 893 | &::=& \emph{AssignExpr}\\ |
| | 894 | &$|$& \emph{OpExpr}\\ |
| | 895 | &$|$& \emph{DelimitedExpr}\\ |
| | 896 | &$|$& \emph{FlowExpr}\\ |
| | 897 | &$|$& \KWD{fn} \emph{ValParam} \option{\emph{IsType}} \option{\emph{Throws}} \EXP{\Rightarrow} \emph{Expr}\\ |
| | 898 | &$|$& \emph{Expr} \KWD{as} \emph{Type}\\ |
| | 899 | &$|$& \emph{Expr} \KWD{asif} \emph{Type}\\ |
| | 900 | |
| | 901 | \emph{AssignExpr} |
| | 902 | &::=& \emph{AssignLefts} \emph{AssignOp} \emph{Expr}\\ |
| | 903 | |
| | 904 | \emph{AssignLefts} |
| | 905 | &::=& \texttt( \emph{AssignLeft}(\EXP{,} \emph{AssignLeft})$^*$ \texttt)\\ |
| | 906 | &$|$& \emph{AssignLeft}\\ |
| | 907 | |
| | 908 | \emph{AssignLeft} |
| | 909 | &::=& \emph{SubscriptExpr}\\ |
| | 910 | &$|$& \emph{FieldSelection}\\ |
| | 911 | &$|$& \emph{QualifiedName}\\ |
| | 912 | |
| | 913 | \emph{SubscriptExpr} &::=& |
| | 914 | \emph{Primary} \emph{LeftEncloser} \option{\emph{StaticArgs}} \option{\emph{ExprList}} \emph{RightEncloser} \\ |
| | 915 | |
| | 916 | \emph{FieldSelection} &::=& \emph{Primary}\EXP{.}\emph{Id}\\ |
| | 917 | |
| | 918 | \emph{OpExpr} |
| | 919 | &::=& \emph{EncloserOp} \option{\emph{OpExpr}} \option{\emph{EncloserOp}} \\ |
| | 920 | &$|$& \emph{OpExpr} \emph{EncloserOp} \option{\emph{OpExpr}} \\ |
| | 921 | &$|$& \emph{Primary}\\ |
| | 922 | |
| | 923 | \emph{EncloserOp} &::=& \emph{Encloser}\\ |
| | 924 | &$|$& \emph{Op}\\ |
| | 925 | |
| | 926 | \emph{Primary} |
| | 927 | &::=& \emph{PrimaryItem} (\EXP{,} \emph{PrimaryItem})$^*$\\ |
| | 928 | |
| | 929 | \emph{PrimaryItem} |
| | 930 | &::=& \emph{ArrayExpr}\\ |
| | 931 | &$|$& \emph{MapExpr} \\ |
| | 932 | &$|$& \emph{Comprehension} \\ |
| | 933 | &$|$& \emph{LeftEncloser} \option{\emph{StaticArgs}} \option{\emph{ExprList}} \emph{RightEncloser} \\ |
| | 934 | &$|$& \emph{ParenthesisDelimited}\\ |
| | 935 | &$|$& \emph{LiteralExpr}\\ |
| | 936 | &$|$& \emph{VarOrFnRef}\\ |
| | 937 | &$|$& \KWD{self} \\ |
| | 938 | &$|$& \emph{Primary} \emph{LeftEncloser} \option{\emph{StaticArgs}} \option{\emph{ExprList}} \emph{RightEncloser} \\ |
| | 939 | &$|$& \emph{Primary}\EXP{.}\emph{Id} |
| | 940 | \option{\emph{StaticArgs}} \emph{ParenthesisDelimited}\\ |
| | 941 | &$|$& \emph{Primary}\EXP{.}\emph{Id}\\ |
| | 942 | &$|$& \emph{Primary} \verb+^+ \emph{Exponent}\\ |
| | 943 | &$|$& \emph{Primary} \emph{ExponentOp}\\ |
| | 944 | &$|$& \emph{Primary} \emph{ArgExpr}\\ |
| | 945 | &$|$& \emph{Primary} \emph{Primary}\\ |
| | 946 | |
| | 947 | \emph{VarOrFnRef} &::=& \emph{Id} \option{\emph{StaticArgs}}\\ |
| | 948 | |
| | 949 | \end{tabular} |
| | 950 | |
| | 951 | \begin{tabular}{lll} |
| | 952 | \emph{ParenthesisDelimited} |
| | 953 | &::=& \emph{Parenthesized}\\ |
| | 954 | &$|$& \emph{ArgExpr}\\ |
| | 955 | &$|$& \texttt(\texttt)\\ |
| | 956 | |
| | 957 | \emph{Exponent} |
| | 958 | &::=& \emph{ParenthesisDelimited}\\ |
| | 959 | &$|$& \emph{LiteralExpr}\\ |
| | 960 | &$|$& \emph{Id}\\ |
| | 961 | &$|$& \KWD{self}\\ |
| | 962 | |
| | 963 | \emph{FlowExpr} |
| | 964 | &::=& \KWD{exit} \option{\emph{Id}} \options{\KWD{with} \emph{Expr}} \\ |
| | 965 | &$|$& \emph{Accumulator} \option{\emph{StaticArgs}} |
| | 966 | \options{\texttt[ \emph{GeneratorClauseList} \texttt]} \emph{Expr} \\ |
| | 967 | &$|$& \KWD{atomic} \emph{AtomicBack}\\ |
| | 968 | &$|$& \KWD{tryatomic} \emph{AtomicBack} \\ |
| | 969 | &$|$& \KWD{spawn} \emph{Expr} \\ |
| | 970 | &$|$& \KWD{throw} \emph{Expr}\\ |
| | 971 | |
| | 972 | \emph{AtomicBack} |
| | 973 | &::=& \emph{AssignExpr}\\ |
| | 974 | &$|$& \emph{OpExpr}\\ |
| | 975 | &$|$& \emph{DelimitedExpr}\\ |
| | 976 | |
| | 977 | \emph{GeneratorClauseList} &::=& \emph{GeneratorBinding}(\EXP{,} \emph{GeneratorClause})$^*$\\ |
| | 978 | |
| | 979 | \emph{GeneratorBinding} |
| | 980 | &::=& \emph{BindIdOrBindIdTuple}\EXP{\leftarrow}\emph{Expr} \\ |
| | 981 | |
| | 982 | \emph{GeneratorClause} |
| | 983 | &::=& \emph{GeneratorBinding}\\ |
| | 984 | &$|$& \emph{Expr} \\ |
| | 985 | |
| | 986 | \end{tabular} |
| | 987 | |
| | 988 | \section{Expressions Enclosed by Keywords or Symbols} |
| | 989 | \begin{tabular}{lll} |
| | 990 | \emph{DelimitedExpr} |
| | 991 | &::=& \emph{ArgExpr}\\ |
| | 992 | &$|$& \emph{Parenthesized}\\ |
| | 993 | &$|$& \KWD{object} \option{\emph{ExtendsWhere}} |
| | 994 | \option{\emph{GoInAnObject}} \KWD{end} \\ |
| | 995 | &$|$& \emph{Do}\\ |
| | 996 | &$|$& \KWD{label} \emph{Id} \emph{BlockElems} \KWD{end} \emph{Id} \\ |
| | 997 | &$|$& \KWD{while} \emph{GeneratorClause} \emph{Do} \\ |
| | 998 | &$|$& \KWD{for} \emph{GeneratorClauseList} \emph{DoFront} \KWD{end}\\ |
| | 999 | &$|$& \KWD{if} \emph{GeneratorClause} \KWD{then} \emph{BlockElems} \option{\emph{Elifs}} \option{\emph{Else}} \KWD{end}\\ |
| | 1000 | &$|$& \texttt{(}\KWD{if} \emph{GeneratorClause} \KWD{then} \emph{BlockElems} |
| | 1001 | \option{\emph{Elifs}} \emph{Else} \option{\KWD{end}}\texttt{)}\\ |
| | 1002 | &$|$& \KWD{case} \emph{Expr} \option{(\emph{Encloser} $|$ \emph{Op})} \KWD{of} \emph{CaseClauses} |
| | 1003 | \option{\emph{CaseElse}} \KWD{end} \\ |
| | 1004 | &$|$& \KWD{case} \KWD{most} (\emph{Encloser} $|$ \emph{Op}) \KWD{of} |
| | 1005 | \emph{CaseClauses} \KWD{end}\\ |
| | 1006 | &$|$& \KWD{typecase} \emph{TypecaseBindings} \KWD{of} |
| | 1007 | \emph{TypecaseClauses} \option{\emph{CaseElse}} \KWD{end}\\ |
| | 1008 | &$|$& \KWD{try} \emph{BlockElems} \option{\emph{Catch}} |
| | 1009 | \options{\KWD{forbid} \emph{TraitTypes}} |
| | 1010 | \options{\KWD{finally} \emph{BlockElems}} \KWD{end} \\ |
| | 1011 | |
| | 1012 | \emph{Do} &::=& (\emph{DoFront} \KWD{also})$^*$ \emph{DoFront} \KWD{end}\\ |
| | 1013 | |
| | 1014 | \emph{DoFront} &::=& \options{\KWD{at} \emph{Expr}} \option{\KWD{atomic}} |
| | 1015 | \KWD{do} \option{\emph{BlockElems}}\\ |
| | 1016 | |
| | 1017 | \emph{ArgExpr} &::=& |
| | 1018 | \texttt( (\emph{Expr}\EXP{,})$^*$ \options{\emph{Expr}\EXP{...}\EXP{,}} |
| | 1019 | \emph{KeywordExpr} (\EXP{,} \emph{KeywordExpr})$^*$ \texttt)\\ |
| | 1020 | &$|$& \emph{TupleExpr}\\ |
| | 1021 | &$|$& \texttt( (\emph{Expr}\EXP{,})$^*$ \emph{Expr}\EXP{...} \texttt)\\ |
| | 1022 | |
| | 1023 | \emph{TupleExpr} |
| | 1024 | &::=& \texttt( (\emph{Expr}\EXP{,})$^+$ \emph{Expr} \texttt)\\ |
| | 1025 | |
| | 1026 | \emph{KeywordExpr} &::=& \emph{BindId} \EXP{=} \emph{Expr}\\ |
| | 1027 | |
| | 1028 | \emph{Parenthesized} &::=& \texttt( \emph{Expr} \texttt)\\ |
| | 1029 | |
| | 1030 | \emph{Elifs} &::=& \emph{Elif}$^+$\\ |
| | 1031 | |
| | 1032 | \emph{Elif} &$::=$& \KWD{elif} \emph{GeneratorClause} \KWD{then} \emph{BlockElems}\\ |
| | 1033 | |
| | 1034 | \emph{Else} &$::=$& \KWD{else} \emph{BlockElems}\\ |
| | 1035 | |
| | 1036 | \emph{CaseClauses} &::=& \emph{CaseClause}$^+$\\ |
| | 1037 | |
| | 1038 | \emph{CaseClause} &::=& \emph{Expr} \EXP{\Rightarrow} \emph{BlockElems}\\ |
| | 1039 | |
| | 1040 | \emph{CaseElse} &::=& \KWD{else} \EXP{\Rightarrow} \emph{BlockElems}\\ |
| | 1041 | |
| | 1042 | \end{tabular} |
| | 1043 | |
| | 1044 | \begin{tabular}{lll} |
| | 1045 | \emph{TypecaseBindings} &::=& \emph{TypecaseVars} |
| | 1046 | \options{\EXP{=} \emph{Expr}}\\ |
| | 1047 | |
| | 1048 | \emph{TypecaseVars} &::=& \emph{BindId} \\ |
| | 1049 | &$|$& \texttt{(} \emph{BindId}(\EXP{,} \emph{BindId})$^+$ \texttt{)} \\ |
| | 1050 | |
| | 1051 | \emph{TypecaseClauses} &::=& \emph{TypecaseClause}$^+$\\ |
| | 1052 | |
| | 1053 | \emph{TypecaseClause} &::=& |
| | 1054 | \emph{TypecaseTypes} \EXP{\Rightarrow} \emph{BlockElems} \\ |
| | 1055 | |
| | 1056 | \emph{TypecaseTypes} |
| | 1057 | &::=& \texttt{(} \emph{TypeList} \texttt{)}\\ |
| | 1058 | &$|$& \emph{Type} \\ |
| | 1059 | |
| | 1060 | \emph{Catch} &::=& \KWD{catch} \emph{BindId} \emph{CatchClauses}\\ |
| | 1061 | |
| | 1062 | \emph{CatchClauses} &::=& \emph{CatchClause}$^+$\\ |
| | 1063 | |
| | 1064 | \emph{CatchClause} &::=& \emph{TraitType} \EXP{\Rightarrow} \emph{BlockElems} \\ |
| | 1065 | |
| | 1066 | \emph{MapExpr} &::=& \{ \option{\emph{StaticArgs}} \option{\emph{EntryList}} \}\\ |
| | 1067 | |
| | 1068 | \emph{Comprehension} |
| | 1069 | &::=& \option{\KWD{BIG}} \texttt{[} \option{\emph{StaticArgs}} |
| | 1070 | \emph{ArrayComprehensionClause}$^+$ \texttt{]}\\ |
| | 1071 | &$|$& \option{\KWD{BIG}} \{ \option{\emph{StaticArgs}} |
| | 1072 | \emph{Entry} \texttt{|} \emph{GeneratorClauseList} \} \\ |
| | 1073 | &$|$& \option{\KWD{BIG}} \emph{LeftEncloser} \option{\emph{StaticArgs}} |
| | 1074 | \emph{Expr} \texttt{|} \emph{GeneratorClauseList} \emph{RightEncloser} \\ |
| | 1075 | |
| | 1076 | \emph{Entry} &::=& \emph{Expr} \ensuremath{\mapsto} \emph{Expr} \\ |
| | 1077 | |
| | 1078 | \emph{ArrayComprehensionClause} &::=& |
| | 1079 | \emph{ArrayComprehensionLeft} \texttt{|} \emph{GeneratorClauseList}\\ |
| | 1080 | |
| | 1081 | \emph{ArrayComprehensionLeft} &::=& |
| | 1082 | \emph{IdOrInt} \ensuremath{\mapsto} \emph{Expr}\\ |
| | 1083 | &$|$& \texttt( \emph{IdOrInt}\EXP{,} \emph{IdOrIntList} \texttt) \ensuremath{\mapsto} \emph{Expr}\\ |
| | 1084 | |
| | 1085 | \emph{IdOrInt} &::=& \emph{Id}\\ |
| | 1086 | &$|$& \emph{IntLiteralExpr}\\ |
| | 1087 | |
| | 1088 | \emph{IdOrIntList} &::=& \emph{IdOrInt}(\EXP{,} \emph{IdOrInt})$^*$ \\ |
| | 1089 | |
| | 1090 | \emph{ExprList} &::=& \emph{Expr}(\EXP{,} \emph{Expr})$^*$ \\ |
| | 1091 | |
| | 1092 | \emph{EntryList} &::=& \emph{Entry}(\EXP{,} \emph{Entry})$^*$ \\ |
| | 1093 | |
| | 1094 | \end{tabular} |
| | 1095 | |
| | 1096 | \section{Local Declarations} |
| | 1097 | \begin{tabular}{lll} |
| | 1098 | \emph{BlockElems} &::=& \emph{BlockElem}$^+$ \\ |
| | 1099 | |
| | 1100 | \emph{BlockElem} |
| | 1101 | &::=& \emph{LocalVarFnDecl}\\ |
| | 1102 | &$|$& \emph{Expr}\options{\EXP{,} \emph{GeneratorClauseList}}\\ |
| | 1103 | |
| | 1104 | \emph{LocalVarFnDecl} |
| | 1105 | &::=& \emph{LocalFnDecl}$^+$\\ |
| | 1106 | &$|$& \emph{LocalVarDecl}\\ |
| | 1107 | |
| | 1108 | \emph{LocalFnDecl} &::=& |
| | 1109 | \option{\emph{LocalFnMods}} \emph{NamedFnHeaderFront} \emph{FnHeaderClause} \EXP{=} |
| | 1110 | \emph{Expr} \\ |
| | 1111 | |
| | 1112 | \emph{LocalVarDecl} |
| | 1113 | &::=& \option{\KWD{var}} \emph{LocalVarWTypes} \emph{InitVal} \\ |
| | 1114 | &$|$& \option{\KWD{var}} \emph{LocalVarWTypes}\\ |
| | 1115 | &$|$& \emph{LocalVarWoTypes} \EXP{=} \emph{Expr} \\ |
| | 1116 | &$|$& \option{\KWD{var}} \emph{LocalVarWoTypes} \EXP{\mathrel{\mathtt{:}}} \emph{Type}\EXP{...} |
| | 1117 | \option{\emph{InitVal}} \\ |
| | 1118 | &$|$& \option{\KWD{var}} \emph{LocalVarWoTypes} \EXP{\mathrel{\mathtt{:}}} \emph{TupleType} |
| | 1119 | \option{\emph{InitVal}} \\ |
| | 1120 | |
| | 1121 | \emph{LocalVarWTypes} &::=& \emph{LocalVarWType} \\ |
| | 1122 | &$|$& \texttt{(} \emph{LocalVarWType}(\EXP{,} \emph{LocalVarWType})$^+$ \texttt{)}\\ |
| | 1123 | \emph{LocalVarWType} &::=& \emph{BindId} \emph{IsType}\\ |
| | 1124 | |
| | 1125 | \emph{LocalVarWoTypes} &::=& \emph{LocalVarWoType} \\ |
| | 1126 | &$|$& \texttt{(} \emph{LocalVarWoType}(\EXP{,} \emph{LocalVarWoType})$^+$ \texttt{)}\\ |
| | 1127 | \emph{LocalVarWoType} &::=& \emph{BindId}\\ |
| | 1128 | &$|$& \emph{Unpasting} \\ |
| | 1129 | |
| | 1130 | \emph{Unpasting} &::=& \texttt{[} \emph{UnpastingElems} \texttt{]} \\ |
| | 1131 | |
| | 1132 | \emph{UnpastingElems} |
| | 1133 | &::=& \emph{UnpastingElem} \emph{RectSeparator} \emph{UnpastingElems} \\ |
| | 1134 | &$|$& \emph{UnpastingElem} \\ |
| | 1135 | |
| | 1136 | \emph{UnpastingElem} |
| | 1137 | &::=& \emph{BindId} \options{\texttt{[} \emph{UnpastingDim} \texttt{]}} \\ |
| | 1138 | &$|$& \emph{Unpasting} \\ |
| | 1139 | |
| | 1140 | \emph{UnpastingDim} &::=& \emph{ExtentRange} (\BY\ \emph{ExtentRange})$^+$ \\ |
| | 1141 | |
| | 1142 | \end{tabular} |
| | 1143 | |
| | 1144 | \section{Literals} |
| | 1145 | \begin{tabular}{lll} |
| | 1146 | \emph{LiteralExpr} &::=& \texttt{(} \texttt{)}\\ |
| | 1147 | &$|$& \emph{NumericLiteralExpr}\\ |
| | 1148 | &$|$& \emph{CharLiteralExpr}\\ |
| | 1149 | &$|$& \emph{StringLiteralExpr}\\ |
| | 1150 | |
| | 1151 | \emph{ArrayExpr} &::=& |
| | 1152 | \texttt{[} \option{\emph{StaticArgs}} \emph{RectElements} \texttt{]}\\ |
| | 1153 | |
| | 1154 | \emph{RectElements} &::=& \emph{Expr} \emph{MultiDimCons}$^*$\\ |
| | 1155 | |
| | 1156 | \emph{MultiDimCons} &::=& \emph{RectSeparator} \emph{Expr}\\ |
| | 1157 | \end{tabular} |
| | 1158 | |
| | 1159 | \section{Types} |
| | 1160 | \begin{tabular}{lll} |
| | 1161 | \emph{Type} |
| | 1162 | &::=& \emph{TypeRef} \\ |
| | 1163 | &$|$& \emph{TraitType} \\ |
| | 1164 | &$|$& \emph{TupleType} \\ |
| | 1165 | &$|$& \texttt( \emph{Type} \texttt) \\ |
| | 1166 | &$|$& \texttt{()} \\ |
| | 1167 | &$|$& \emph{ArgType} \EXP{\rightarrow} \emph{Type} \option{\emph{Throws}}\\ |
| | 1168 | &$|$& \emph{Type} \emph{DimType} \\ |
| | 1169 | |
| | 1170 | \emph{TypeRef} |
| | 1171 | &::=& \emph{DottedId} \option{\emph{StaticArgs}}\\ |
| | 1172 | |
| | 1173 | \emph{TraitType} |
| | 1174 | &::=& \emph{TypeRef}\\ |
| | 1175 | &$|$& \emph{Type} \texttt{[} \option{\emph{ArraySize}} \texttt{]} \\ |
| | 1176 | &$|$& \emph{Type} \verb+^+ \emph{IntExpr}\\ |
| | 1177 | &$|$& \emph{Type} \verb+^+ \texttt{(} \emph{ExtentRange} |
| | 1178 | (\EXP{\times} \emph{ExtentRange})$^*$ \texttt{)}\\ |
| | 1179 | |
| | 1180 | \emph{ArgType} |
| | 1181 | &::=& \texttt{(} (\emph{Type}\EXP{,})$^*$ |
| | 1182 | \options{\emph{Type}\EXP{...}\EXP{,}} |
| | 1183 | \emph{KeywordType}(\EXP{,} \emph{KeywordType})$^*$ \texttt{)}\\ |
| | 1184 | &$|$& \texttt{(} (\emph{Type}\EXP{,})$^*$ |
| | 1185 | \emph{Type}\EXP{...} \texttt{)}\\ |
| | 1186 | &$|$& \emph{TupleType} \\ |
| | 1187 | |
| | 1188 | \emph{KeywordType} &::-& \emph{BindId}\EXP{=}\emph{Type}\\ |
| | 1189 | |
| | 1190 | \emph{TupleType} &::=& |
| | 1191 | \texttt{(} \emph{Type}\EXP{,} \emph{TypeList} \texttt{)}\\ |
| | 1192 | |
| | 1193 | \emph{TypeList} &::=& \emph{Type}(\EXP{,} \emph{Type})$^*$ \\ |
| | 1194 | |
| | 1195 | \emph{ArraySize} &::=& \emph{ExtentRange}(\EXP{,} \emph{ExtentRange})$^*$ \\ |
| | 1196 | |
| | 1197 | \emph{ExtentRange} |
| | 1198 | &::=& \option{\emph{StaticArg}}\EXP{\mathinner{\hbox{\tt\char'43}}} |
| | 1199 | \option{\emph{StaticArg}}\\ |
| | 1200 | &$|$& \option{\emph{StaticArg}}\KWD:\option{\emph{StaticArg}}\\ |
| | 1201 | &$|$& \emph{StaticArg} \\ |
| | 1202 | |
| | 1203 | \emph{DimType} |
| | 1204 | &::=& \emph{DottedId} \\ |
| | 1205 | &$|$& \texttt( \emph{DimType} \texttt) \\ |
| | 1206 | &$|$& \EXP{1} \\ |
| | 1207 | &$|$& \emph{DimPrefixOp} \emph{DimType} \\ |
| | 1208 | &$|$& \emph{DimType} \emph{DimInfixOp} \emph{DimType} \\ |
| | 1209 | &$|$& \emph{DimType} \emph{DimPostfixOp} \\ |
| | 1210 | &$|$& \emph{DimType} \KWD{in} \emph{Expr}\\ |
| | 1211 | |
| | 1212 | \emph{DimPrefixOp} &::=& \KWD{square} $|$ \KWD{cubic} $|$ \KWD{inverse} \\ |
| | 1213 | \emph{DimInfixOp} &::=& $\csdot$ $|$ \EXP{/} $|$ \KWD{per} \\ |
| | 1214 | \emph{DimPostfixOp} &::=& \KWD{squared} $|$ \KWD{cubed} \\ |
| | 1215 | |
| | 1216 | \end{tabular} |
| | 1217 | |
| | 1218 | \section{Symbols and Operators} |
| | 1219 | \begin{tabular}{lll} |
| | 1220 | |
| | 1221 | \emph{EncloserPair} &::=& |
| | 1222 | (\emph{LeftEncloser} $|$ \emph{Encloser}) \option{\EXP{\cdot}} |
| | 1223 | (\emph{RightEncloser} $|$ \emph{Encloser})\\ |
| | 1224 | |
| | 1225 | \emph{ExponentOp} &::=& \verb+^T+ $|$ \verb+^+(\emph{Encloser} $|$ \emph{Op})\\ |
| | 1226 | |
| | 1227 | \emph{AssignOp} &::=& \EXP{\ASSIGN} $|$ (\emph{Encloser} $|$ \emph{Op})\EXP{=}\\ |
| | 1228 | |
| | 1229 | \emph{Accumulator} &::=& $\sum$ $|$ $\prod$ $|$ \KWD{BIG} (\emph{Encloser} $|$ \emph{Op})\\ |
| | 1230 | \end{tabular} |
| | 1231 | |
| | 1232 | \section{Identifiers} |
| | 1233 | \begin{tabular}{lll} |
| | 1234 | \emph{BindId} &::=& \emph{Id}\\ |
| | 1235 | &$|$& \KWD{\_}\\ |
| | 1236 | |
| | 1237 | \emph{BindIdList} &::=& \emph{BindId}(\EXP{,} \emph{BindId})$^*$\\ |
| | 1238 | |
| | 1239 | \emph{BindIdOrBindIdTuple} |
| | 1240 | &::=& \emph{BindId}\\ |
| | 1241 | &$|$& \texttt{(} \emph{BindId}\EXP{,} \emph{BindIdList} \texttt{)}\\ |
| | 1242 | |
| | 1243 | \emph{SimpleName} &::=& \emph{Id} \\ |
| | 1244 | &$|$& \KWD{opr} \option{\KWD{BIG}} (\emph{Encloser} $|$ \emph{Op}) \\ |
| | 1245 | &$|$& \KWD{opr} \option{\KWD{BIG}} \emph{EncloserPair} \\ |
| | 1246 | |
| | 1247 | \emph{APIName} &::=& \emph{Id}(\EXP{.}\emph{Id})$^*$\\ |
| | 1248 | |
| | 1249 | \emph{QualifiedName} &::=& \emph{Id}(\EXP{.}\emph{Id})$^*$\\ |
| | 1250 | \end{tabular} |
| | 1251 | |
| | 1252 | \section{Spaces and Comments} |
| | 1253 | \begin{tabular}{lll} |
| | 1254 | \emph{RectSeparator} &::=& \EXP{;}+\\ |
| | 1255 | &$|$& \emph{Whitespace}\\ |
| | 1256 | \end{tabular} |