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

syntaxref: in progress

parent 7012fc39
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
| real ; real constant | real ; real constant
| "true" | "false" ; Boolean constant | "true" | "false" ; Boolean constant
| "()" ; empty tuple | "()" ; empty tuple
| qualid ; qualified identifier | qualid ; identifier in a scope
| qualifier? "(" expr ")" ; qualified expression | qualifier? "(" expr ")" ; expression in a scope
| qualifier? "begin" expr "end" ; \textit{idem} | qualifier? "begin" expr "end" ; \textit{idem}
| tight-op expr ; tight operator | tight-op expr ; tight operator
| "{" expr-field+ "}" ; record | "{" (lqualid "=" expr ";")+ "}" ; record
| "{" expr "with" expr-field+ "}" | "{" expr "with" (lqualid "=" expr ";")+ "}"
; record update ; record update
| expr "." lqualid ; record field access | expr "." lqualid ; record field access
| expr "[" expr "]" "'"* ; collection access | expr "[" expr "]" "'"* ; collection access
...@@ -30,7 +30,5 @@ ...@@ -30,7 +30,5 @@
| "ghost" expr ; ghost expression | "ghost" expr ; ghost expression
| expr ("," expr)+ ; tuple | expr ("," expr)+ ; tuple
| expr "<-" expr ; assignment | expr "<-" expr ; assignment
| ... ; continued in Fig.~\ref{fig:bnf:expr2} | ... ; continued in Fig.~\ref{fig:bnf:expr2} %
\
expr-field ::= lqualid "=" expr ";" ; field \texttt{=} value %
\end{syntax} \end{syntax}
\begin{syntax} \begin{syntax}
expr ::= ... ; see Fig.~\ref{fig:bnf:expr1} expr ::= ... ; see Fig.~\ref{fig:bnf:expr1}
| expr spec+ ; added specification
| "if" expr "then" expr ("else" expr)? ; conditional | "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 | expr ";" expr ; sequence
| "let" pattern "=" expr "in" expr ; let-binding | "let" pattern "=" expr "in" expr ; let-binding
| "let" fun-defn "in" expr ; function definition | "let" fun-defn "in" expr ; local function
| "let" "rec" rec-defn "in" expr ; recursive definition | "let" "rec" fun-defn ("with" fun-defn)* "in" expr ; recursive function
| "fun" binder+ spec* "->" spec* expr ; unnamed 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} \end{syntax}
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
| "true" | "false" ; Boolean constant | "true" | "false" ; Boolean constant
| "()" ; empty tuple | "()" ; empty tuple
| qualid ; qualified identifier | qualid ; qualified identifier
| qualifier? "(" term ")" ; qualified term | qualifier? "(" term ")" ; term in a scope
| qualifier? "begin" term "end" ; \textit{idem} | qualifier? "begin" term "end" ; \textit{idem}
| tight-op term ; tight operator | tight-op term ; tight operator
| "{" term-field+ "}" ; record | "{" term-field+ "}" ; record
......
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
\ \
quant-vars ::= quant-cast ("," quant-cast)* quant-vars ::= quant-cast ("," quant-cast)*
\ \
quant-cast ::= bound-var+ (":" type)? quant-cast ::= binder+ (":" type)?
\
binder ::= "_" | bound-var
\ \
bound-var ::= lident attribute* bound-var ::= lident attribute*
\ \
......
\begin{syntax} \begin{syntax}
term ::= ... ; see Fig.~\ref{fig:bnf:term1} and \ref{fig:bnf:term2} term ::= ... ; see Fig.~\ref{fig:bnf:term1} and \ref{fig:bnf:term2}
| "if" term "then" term "else" term ; conditional | "if" term "then" term "else" term ; conditional
| "match" term "with" term-case+ "end" ; pattern matching | "match" term "with" term-case+ "end" ; pattern matching
| "let" pattern "=" term "in" term ; let-binding | "let" pattern "=" term "in" term ; let-binding
| "let" symbol param+ "=" term "in" term ; mapping definition | "let" symbol param+ "=" term "in" term ; mapping definition
| "fun" param+ "->" term ; unnamed mapping | "fun" param+ "->" term ; unnamed mapping
\ \
term-case ::= "|" pattern "->" term term-case ::= "|" pattern "->" term
\ \
pattern ::= "_" ; catch-all pattern ::=
| "()" ; empty tuple binder ; variable or `\texttt{\_}'
| "(" pattern ")" ; parentheses | "()" ; empty tuple
| "{" (lqualid "=" pattern ";")+ "}" ; record pattern | "{" (lqualid "=" pattern ";")+ "}" ; record pattern
| bound-var ; variable | uqualid pattern* ; constructor
| uqualid pattern* ; constructor | "ghost" pattern ; ghost sub-pattern
| "ghost" pattern ; ghost sub-pattern | pattern "as" "ghost"? bound-var ; named sub-pattern
| pattern "as" "ghost"? bound-var ; named sub-pattern | pattern "," pattern ; tuple pattern
| pattern "," pattern ; tuple pattern | pattern "|" pattern ; ``or'' pattern
| pattern "|" pattern ; ``or'' pattern | qualifier? "(" pattern ")" ; pattern in a scope
\ \
symbol ::= lident-ext attribute* ; user-defined symbol symbol ::= lident-ext attribute* ; user-defined symbol
\ \
param ::= param ::=
type-arg ; unnamed typed type-arg ; unnamed typed
| param-name ; (un)named untyped | binder ; (un)named untyped
| "(" "ghost"? type ")" ; unnamed typed | "(" "ghost"? type ")" ; unnamed typed
| "(" "ghost"? param-name ")" ; (un)named untyped | "(" "ghost"? binder ")" ; (un)named untyped
| "(" "ghost"? param-name+ ":" type ")" ; multi-variable typed | "(" "ghost"? binder+ ":" type ")" ; multi-variable typed %
\
param-name ::= "_" ; unnamed parameter
| bound-var ; named parameter %
\end{syntax} \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 @@ ...@@ -8,5 +8,5 @@
| "()" ; unit type | "()" ; unit type
| "(" type ("," type)+ ")" ; tuple type | "(" type ("," type)+ ")" ; tuple type
| "{" type "}" ; snapshot type | "{" type "}" ; snapshot type
| "(" type ")" | qualifier? "(" type ")" ; type in a scope %
\end{syntax} \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