Home My Page Projects Code Snippets Project Openings diderot

SCM Repository

[diderot] Annotation of /trunk/doc/report/lang.tex
 [diderot] / trunk / doc / report / lang.tex

Annotation of /trunk/doc/report/lang.tex

 1 : jhr 329 %!TEX root = report.tex 2 : % 3 : \chapter{The Diderot Language} 4 : \label{chap:lang} 5 : 6 : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 : \section{Global declarations} 8 : 9 : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 : \section{Actor definitions} 11 : 12 : \subsection{Actor state} 13 : 14 : \subsection{The update method} 15 : 16 : \subsection{The stabilize method} 17 : 18 : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 : \section{Initialization} 20 : jhr 330 21 : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 : \section{Statements} 23 : jhr 473 24 : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 25 : \section{Expressions} 26 : 27 : \subsection{Conditional expressions} 28 : There are three conditional expression forms in Diderot: 29 : \emph{if-else} expressions, \emph{or-else} expressions, and \emph{and-also} 30 : expressions. 31 : The syntax of these is given by the following grammar fragment: 32 : \begin{Grammar} 33 : \ExprRULES{} 34 : \TestExprRULES{} 35 : \AndExprRULES{} 36 : \end{Grammar}% 37 : 38 : \subsubsection{If-else expressions} 39 : The if-else expression has the following typing rule: 40 : \begin{displaymath} 41 : \infer{ 42 : \HasTy{\ENV}{e_1\;\mkw{if}\;e_2\;\mkw{else}\;e_3}{\tau} 43 : }{ 44 : \HasTy{\ENV}{e_1}{\tau} \quad 45 : \HasTy{\ENV}{e_2}{\TYbool} \quad 46 : \HasTy{\ENV}{e_3}{\tau} \quad 47 : } 48 : \end{displaymath}% 49 : Its semantics are that it evaluates $e_2$ first. 50 : If the value is true, then it evaluate $e_1$, otherwise it evaluates $e_3$. 51 : 52 : \subsubsection{Or-else expressions} 53 : \begin{displaymath} 54 : \infer{ 55 : \HasTy{\ENV}{e_1\;\mkw{||}\;e_2}{\TYbool} 56 : }{ 57 : \HasTy{\ENV}{e_1}{\TYbool} \quad 58 : \HasTy{\ENV}{e_2}{\TYbool} 59 : } 60 : \end{displaymath}% 61 : The or-else form is derived from the if-else form as follows: 62 : \begin{displaymath} 63 : e_1\;\mkw{||}\;e_2 \quad \equiv \quad \mkw{true}\;\mkw{if}\;e_1\;\mkw{else}\;e_2 64 : \end{displaymath}% 65 : 66 : \subsubsection{If-else expressions} 67 : \begin{displaymath} 68 : \infer{ 69 : \HasTy{\ENV}{e_1\;\mkw{\&\&}\;e_2}{\TYbool} 70 : }{ 71 : \HasTy{\ENV}{e_1}{\TYbool} \quad 72 : \HasTy{\ENV}{e_2}{\TYbool} 73 : } 74 : \end{displaymath}% 75 : The and-also form is derived from the if-else form as follows: 76 : \begin{displaymath} 77 : e_1\;\mkw{\&\&}\;e_2 \quad \equiv \quad e_2\;\mkw{if}\;e_1\;\mkw{else}\;\mkw{false} 78 : \end{displaymath}% 79 : 80 : \subsection{Binary expressions} 81 : \begin{Grammar} 82 : \CmpExprRULES{} 83 : \AddExprRULES{} 84 : \MulExprRULES{} 85 : \CmpOpRULES{} 86 : \AddOpRULES{} 87 : \MulOpRULES{} 88 : \end{Grammar}% 89 : 90 : \subsection{Field-probe expressions} 91 : \begin{Grammar} 92 : \ProbeExprRULES{} 93 : \end{Grammar}% 94 : 95 : \subsection{Unary expressions} 96 : \begin{Grammar} 97 : \PrefixExprRULES{} 98 : \end{Grammar}% 99 : 100 : \subsection{Tensor-slice expressions} 101 : \begin{Grammar} 102 : \SliceExprRULES{} 103 : \IndexRULES{} 104 : \end{Grammar}% 105 : 106 : \subsection{Atomic expressions} 107 : \begin{Grammar} 108 : \AtomExpRULES{} 109 : \ArgumentsRULES{} 110 : \end{Grammar}%