term1.bnf 2.36 KB
Newer Older
1 2 3 4 5
\begin{syntax}
  term ::= integer            ; integer constant
    | real                    ; real constant
    | "true" | "false"        ; Boolean constant
    | "()"                    ; empty tuple
6
    | qualid                  ; qualified identifier
Andrei Paskevich's avatar
Andrei Paskevich committed
7
    | qualifier? "(" term ")"        ; term in a scope
8
    | qualifier? "begin" term "end"  ; \textit{idem}
9
    | tight-op term           ; tight operator
10 11 12 13
    | "{" term-field+ "}"     ; record
    | "{" term "with" term-field+ "}"
                              ; record update
    | term "." lqualid        ; record field access
14 15 16 17 18
    | term "[" term "]" "'"*  ; collection access
    | term "[" term "<-" term "]" "'"*  ; collection update
    | term "[" term ".." term "]" "'"*  ; collection slice
    | term "[" term ".." "]" "'"*  ; right-open slice
    | term "[" ".." term "]" "'"*  ; left-open slice
19 20 21 22 23 24 25 26 27 28 29 30
    | term term+              ; application
    | prefix-op term          ; prefix operator
    | term infix-op-4 term    ; infix operator 4
    | term infix-op-3 term    ; infix operator 3
    | term infix-op-2 term    ; infix operator 2
    | term "at" uident        ; past value
    | "old" term              ; initial value
    | term infix-op-1 term    ; infix operator 1
    | ...                     ; continued in Fig.~\ref{fig:bnf:term2}
  \
  term-field ::= lqualid "=" term ";" ; field \texttt{=} value
  \
31
  qualid ::= qualifier? (lident-ext | uident)  ; qualified identifier
32
  \
33 34 35
  lident-ext ::= lident                   ; lowercase identifier
               | "(" ident-op ")"         ; operator identifier
               | "(" ident-op ")" ("_" | "'") alpha suffix* ; associated identifier
36
  \
37 38 39 40 41 42 43 44 45 46 47 48
  ident-op ::=  infix-op-1              ;   infix operator 1
              | infix-op-2              ;   infix operator 2
              | infix-op-3              ;   infix operator 3
              | infix-op-4              ;   infix operator 4
              | prefix-op "_"           ;   prefix operator
              | tight-op "_"?           ;   tight operator
              | "[" "]" "'" *           ;   collection access
              | "[" "<-" "]" "'"*       ;   collection update
              | "[" "]" "'"* "<-"       ;   in-place update
              | "[" ".." "]" "'"*       ;   collection slice
              | "[" "_" ".." "]" "'"*   ;   right-open slice
              | "[" ".." "_" "]" "'"*   ;   left-open slice %
49
\end{syntax}