expr1.bnf 1.58 KB
Newer Older
1 2 3 4 5
\begin{syntax}
  expr ::= integer            ; integer constant
    | real                    ; real constant
    | "true" | "false"        ; Boolean constant
    | "()"                    ; empty tuple
6 7
    | qualid                  ; identifier in a scope
    | qualifier? "(" expr ")"        ; expression in a scope
8 9
    | qualifier? "begin" expr "end"  ; \textit{idem}
    | tight-op expr           ; tight operator
10 11
    | "{" (lqualid "=" expr ";")+ "}"     ; record
    | "{" expr "with" (lqualid "=" expr ";")+ "}"
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
                              ; record update
    | expr "." lqualid        ; record field access
    | expr "[" expr "]" "'"*  ; collection access
    | expr "[" expr "<-" expr "]" "'"*  ; collection update
    | expr "[" expr ".." expr "]" "'"*  ; collection slice
    | expr "[" expr ".." "]" "'"*  ; right-open slice
    | expr "[" ".." expr "]" "'"*  ; left-open slice
    | expr expr+              ; application
    | prefix-op expr          ; prefix operator
    | expr infix-op-4 expr    ; infix operator 4
    | expr infix-op-3 expr    ; infix operator 3
    | expr infix-op-2 expr    ; infix operator 2
    | expr infix-op-1 expr    ; infix operator 1
    | "not" expr              ; negation
    | expr "&&" expr          ; lazy conjunction
    | expr "||" expr          ; lazy disjunction
    | expr ":" type           ; type cast
    | attribute+ expr         ; attributes
    | "ghost" expr            ; ghost expression
    | expr ("," expr)+        ; tuple
    | expr "<-" expr          ; assignment
33
    | ...                     ; continued in Fig.~\ref{fig:bnf:expr2} %
34
\end{syntax}