Commit 9b06e38e authored by Andrei Paskevich's avatar Andrei Paskevich

syntaxref: in progress

parent 7012fc39
......@@ -3,12 +3,12 @@
| real ; real constant
| "true" | "false" ; Boolean constant
| "()" ; empty tuple
| qualid ; qualified identifier
| qualifier? "(" expr ")" ; qualified expression
| qualid ; identifier in a scope
| qualifier? "(" expr ")" ; expression in a scope
| qualifier? "begin" expr "end" ; \textit{idem}
| tight-op expr ; tight operator
| "{" expr-field+ "}" ; record
| "{" expr "with" expr-field+ "}"
| "{" (lqualid "=" expr ";")+ "}" ; record
| "{" expr "with" (lqualid "=" expr ";")+ "}"
; record update
| expr "." lqualid ; record field access
| expr "[" expr "]" "'"* ; collection access
......@@ -30,7 +30,5 @@
| "ghost" expr ; ghost expression
| expr ("," expr)+ ; tuple
| expr "<-" expr ; assignment
| ... ; continued in Fig.~\ref{fig:bnf:expr2}
\
expr-field ::= lqualid "=" expr ";" ; field \texttt{=} value %
| ... ; continued in Fig.~\ref{fig:bnf:expr2} %
\end{syntax}
\begin{syntax}
expr ::= ... ; see Fig.~\ref{fig:bnf:expr1}
| expr spec+ ; added specification
| "if" expr "then" expr ("else" expr)? ; conditional
| "match" expr "with" expr-case+ "end" ; pattern matching
| "match" expr "with" ("|" pattern "->" expr)+ "end" ; pattern matching
| qualifier? "begin" spec+ expr "end" ; abstract block
| expr ";" expr ; sequence
| "let" pattern "=" expr "in" expr ; let-binding
| "let" fun-defn "in" expr ; function definition
| "let" "rec" rec-defn "in" expr ; recursive definition
| "fun" binder+ spec* "->" spec* expr ; unnamed function
| "let" fun-defn "in" expr ; local function
| "let" "rec" fun-defn ("with" fun-defn)* "in" expr ; recursive function
| "fun" param+ spec* "->" spec* expr ; unnamed function
| "any" result spec* ; arbitrary value
\
prototype ::= lident-ext attribute* binder+
fun-defn ::= fun-head spec* "=" spec* expr ; function definition
\
expr-case ::= "|" pattern "->" expr
fun-head ::= "ghost"? kind? symbol param+ (":" result)? ; function header
\
rec-defn ::= fun-defn ("with" fun-defn)* ;
kind ::= "function" | "predicate" | "lemma" ; function kind
\
fun-defn ::= "ghost"? kind? lident-ext attribute* fun-body ;
result ::= ret-type ;
| "(" ret-type ("," ret-type)* ")" ;
| "(" ret-name ("," ret-name)* ")" ;
\
kind ::= "function" | "predicate" | "lemma" ;
ret-type ::= "ghost"? type ; unnamed result
\
fun-body ::= binder+ (":" ret-type)? spec* "=" spec* expr %
ret-name ::= "ghost"? binder ":" type ; named result
\
spec ::=
"requires" "{" term "}" ; pre-condition
| "ensures" "{" term "}" ; post-condition
| "returns" "{" ("|" pattern "->" term)+ "}" ; post-condition
| "raises" "{" ("|" pattern "->" term)+ "}" ; exceptional post-c.
| "raises" "{" uqualid ("," uqualid)* "}" ; raised exceptions
| "reads" "{" lqualid ("," lqualid)* "}" ; external reads
| "writes" "{" path ("," path)* "}" ; memory writes
| "alias" "{" alias ("," alias)* "}" ; memory aliases
| "variant" "{" variant ("," variant)* "}" ; termination variant
| "diverges" ; may not terminate
| ("reads" | "writes" | "alias") "{" "}" ; empty effect
\
path ::= lqualid ("." lqualid)* ; \texttt{v.field1.field2}
\
alias ::= path "with" path ; \texttt{arg1 with result}
\
variant ::= term ("with" lqualid)? ; variant + WF-order %
\end{syntax}
This diff is collapsed.
......@@ -4,7 +4,7 @@
| "true" | "false" ; Boolean constant
| "()" ; empty tuple
| qualid ; qualified identifier
| qualifier? "(" term ")" ; qualified term
| qualifier? "(" term ")" ; term in a scope
| qualifier? "begin" term "end" ; \textit{idem}
| tight-op term ; tight operator
| "{" term-field+ "}" ; record
......
......@@ -19,7 +19,9 @@
\
quant-vars ::= quant-cast ("," quant-cast)*
\
quant-cast ::= bound-var+ (":" type)?
quant-cast ::= binder+ (":" type)?
\
binder ::= "_" | bound-var
\
bound-var ::= lident attribute*
\
......
......@@ -8,33 +8,23 @@
\
term-case ::= "|" pattern "->" term
\
pattern ::= "_" ; catch-all
pattern ::=
binder ; variable or `\texttt{\_}'
| "()" ; empty tuple
| "(" pattern ")" ; parentheses
| "{" (lqualid "=" pattern ";")+ "}" ; record pattern
| bound-var ; variable
| 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
\
symbol ::= lident-ext attribute* ; user-defined symbol
\
param ::=
type-arg ; unnamed typed
| param-name ; (un)named untyped
| binder ; (un)named untyped
| "(" "ghost"? type ")" ; unnamed typed
| "(" "ghost"? param-name ")" ; (un)named untyped
| "(" "ghost"? param-name+ ":" type ")" ; multi-variable typed
\
param-name ::= "_" ; unnamed parameter
| bound-var ; named parameter %
| "(" "ghost"? binder ")" ; (un)named untyped
| "(" "ghost"? binder+ ":" type ")" ; multi-variable typed %
\end{syntax}
% | lqualid ; unnamed sort-typed
% | "'" lident ; unnamed variable-typed
% | "(" type ("," type)+ ")" ; unnamed tuple-typed
% | "{" type "}" ; unnamed snapshot-typed
% | "(" "ghost"? type ")" ; unnamed typed
% | "(" "ghost"? (bound-var | "_")+ (":" type)? ")" ; multi-variable param %
......@@ -8,5 +8,5 @@
| "()" ; unit type
| "(" type ("," type)+ ")" ; tuple type
| "{" type "}" ; snapshot type
| "(" type ")"
| qualifier? "(" type ")" ; type in a scope %
\end{syntax}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment