Skip to content

Commit

Permalink
update formal syntax
Browse files Browse the repository at this point in the history
add OOP & imports
  • Loading branch information
xhliu committed Feb 19, 2020
1 parent 63575c8 commit 8b78105
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ Formal Specification
.. math::
\begin{align*}
contract &::= \mathrm{contract}\ \mathrm{ID}\ \{\ [var]^*\ [constructor]\ [function]^*\ [public]^+\ \}\\
program &::= [importDirective]^*\ [contract]^+\\
importDirective &::= \mathrm{import}\ "\mathrm{ID}";\\
contract &::= \mathrm{contract}\ \mathrm{ID}\ \{\ [var]^*\ [constructor]\ [function]^+\ \}\\
var &::= formal;\\
formal &::= \mathrm{TYPE}\ \mathrm{ID}\\
function &::= \mathrm{function}\ \mathrm{ID}(formal[,\ formal]^*)\ \mathrm{returns}\ (\mathrm{TYPE})\ \{\ [stmt]^*\ \mathrm{return}\ expr;\ \}\\
constructor &::= \mathrm{constructor}([formal[,\ formal]^*])\ \{\ [stmt]^*\ \}\\
public &::= \mathrm{public}\ \mathrm{function}\ \mathrm{ID}(formal[,\ formal]^*)\ \{\ [stmt]^*\ \mathrm{require}(expr);\}\\
function &::= \mathrm{[public]}\ \mathrm{function}\ \mathrm{ID}(formal[,\ formal]^*)\ \mathrm{[returns}\ (\mathrm{TYPE]})\ \{\ [stmt]^*\ \mathrm{[return}\ expr;]\ \}\\
stmt &::= \mathrm{TYPE}\ \mathrm{ID} = expr;\\
&\ \ \ |\ \ \mathrm{ID}\ \mathrm{ID} = \mathrm{new}\ \mathrm{ID}(expr^*);\\
&\ \ \ |\ \ \mathrm{ID} = expr;\\
&\ \ \ |\ \ \mathrm{require}(expr);\\
&\ \ \ |\ \ \mathrm{exit}(expr);\\
Expand All @@ -24,6 +26,8 @@ Formal Specification
expr &::= \mathsf{UnaryOp}\ expr\\
&\ \ \ |\ \ expr\ \mathsf{BinaryOp}\ expr\\
&\ \ \ |\ \ \mathrm{ID}(expr[,\ expr]^*)\\
&\ \ \ |\ \ \mathrm{ID}.\mathrm{ID}\\
&\ \ \ |\ \ \mathrm{ID}.\mathrm{ID}(expr[,\ expr]^*)\\
&\ \ \ |\ \ \mathrm{ID}\mathbf{[}expr:expr\mathbf{]}\\
&\ \ \ |\ \ (expr)\\
&\ \ \ |\ \ \mathrm{ID}\\
Expand Down

0 comments on commit 8b78105

Please sign in to comment.