SCM Repository
View of /trunk/doc/report/lang.tex
Parent Directory
|
Revision Log
Revision 473 -
(download)
(as text)
(annotate)
Thu Nov 4 15:34:51 2010 UTC (10 years, 3 months ago) by jhr
File size: 2839 byte(s)
Thu Nov 4 15:34:51 2010 UTC (10 years, 3 months ago) by jhr
File size: 2839 byte(s)
Working on language description
%!TEX root = report.tex % \chapter{The Diderot Language} \label{chap:lang} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Global declarations} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Actor definitions} \subsection{Actor state} \subsection{The update method} \subsection{The stabilize method} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Initialization} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Statements} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Expressions} \subsection{Conditional expressions} There are three conditional expression forms in Diderot: \emph{if-else} expressions, \emph{or-else} expressions, and \emph{and-also} expressions. The syntax of these is given by the following grammar fragment: \begin{Grammar} \ExprRULES{} \TestExprRULES{} \AndExprRULES{} \end{Grammar}% \subsubsection{If-else expressions} The if-else expression has the following typing rule: \begin{displaymath} \infer{ \HasTy{\ENV}{e_1\;\mkw{if}\;e_2\;\mkw{else}\;e_3}{\tau} }{ \HasTy{\ENV}{e_1}{\tau} \quad \HasTy{\ENV}{e_2}{\TYbool} \quad \HasTy{\ENV}{e_3}{\tau} \quad } \end{displaymath}% Its semantics are that it evaluates $e_2$ first. If the value is true, then it evaluate $e_1$, otherwise it evaluates $e_3$. \subsubsection{Or-else expressions} \begin{displaymath} \infer{ \HasTy{\ENV}{e_1\;\mkw{||}\;e_2}{\TYbool} }{ \HasTy{\ENV}{e_1}{\TYbool} \quad \HasTy{\ENV}{e_2}{\TYbool} } \end{displaymath}% The or-else form is derived from the if-else form as follows: \begin{displaymath} e_1\;\mkw{||}\;e_2 \quad \equiv \quad \mkw{true}\;\mkw{if}\;e_1\;\mkw{else}\;e_2 \end{displaymath}% \subsubsection{If-else expressions} \begin{displaymath} \infer{ \HasTy{\ENV}{e_1\;\mkw{\&\&}\;e_2}{\TYbool} }{ \HasTy{\ENV}{e_1}{\TYbool} \quad \HasTy{\ENV}{e_2}{\TYbool} } \end{displaymath}% The and-also form is derived from the if-else form as follows: \begin{displaymath} e_1\;\mkw{\&\&}\;e_2 \quad \equiv \quad e_2\;\mkw{if}\;e_1\;\mkw{else}\;\mkw{false} \end{displaymath}% \subsection{Binary expressions} \begin{Grammar} \CmpExprRULES{} \AddExprRULES{} \MulExprRULES{} \CmpOpRULES{} \AddOpRULES{} \MulOpRULES{} \end{Grammar}% \subsection{Field-probe expressions} \begin{Grammar} \ProbeExprRULES{} \end{Grammar}% \subsection{Unary expressions} \begin{Grammar} \PrefixExprRULES{} \end{Grammar}% \subsection{Tensor-slice expressions} \begin{Grammar} \SliceExprRULES{} \IndexRULES{} \end{Grammar}% \subsection{Atomic expressions} \begin{Grammar} \AtomExpRULES{} \ArgumentsRULES{} \end{Grammar}%
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |