term3.bnf 1.34 KB
Newer Older
1
\begin{syntax}
Andrei Paskevich's avatar
Andrei Paskevich committed
2
  term ::= ...  ; see Fig.~\ref{fig:bnf:term1} and \ref{fig:bnf:term2}
3
    | "if" term "then" term "else" term     ; conditional
4
    | "match" term "with" term-case+ "end"  ; pattern matching
5
    | "let" pattern "=" term "in" term      ; let-binding
Andrei Paskevich's avatar
Andrei Paskevich committed
6 7
    | "let" symbol param+ "=" term "in" term  ; mapping definition
    | "fun" param+ "->" term                ; unnamed mapping
8 9 10
  \
  term-case ::= "|" pattern "->" term
  \
Andrei Paskevich's avatar
Andrei Paskevich committed
11 12 13
  pattern ::=
      binder                            ; variable or `\texttt{\_}'
    | "()"                              ; empty tuple
14
    | "{" (lqualid "=" pattern ";")+ "}"  ; record pattern
Andrei Paskevich's avatar
Andrei Paskevich committed
15 16 17 18 19 20
    | uqualid pattern*                  ; constructor
    | "ghost" pattern                   ; ghost sub-pattern
    | pattern "as" "ghost"? bound-var   ; named sub-pattern
    | pattern "," pattern               ; tuple pattern
    | pattern "|" pattern               ; ``or'' pattern
    | qualifier? "(" pattern ")"        ; pattern in a scope
21
  \
Andrei Paskevich's avatar
Andrei Paskevich committed
22
  symbol ::= lident-ext attribute*      ; user-defined symbol
23 24
  \
  param ::=
Andrei Paskevich's avatar
Andrei Paskevich committed
25 26 27 28 29
      type-arg                          ; unnamed typed
    | binder                            ; (un)named untyped
    | "(" "ghost"? type ")"             ; unnamed typed
    | "(" "ghost"? binder ")"           ; (un)named untyped
    | "(" "ghost"? binder+ ":" type ")" ; multi-variable typed %
30
\end{syntax}