Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1116 - (view) (download) (as text)

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 : jhr 1116 \section{Strand definitions}
11 : jhr 329
12 : jhr 1116 \subsection{Strand state}
13 : jhr 329
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 : jhr 1116 In this section, we describe Diderot's expression syntax.
28 :     The section is organized from lowest to highest precedence.
29 :    
30 : jhr 473 \subsection{Conditional expressions}
31 :     There are three conditional expression forms in Diderot:
32 :     \emph{if-else} expressions, \emph{or-else} expressions, and \emph{and-also}
33 :     expressions.
34 :     The syntax of these is given by the following grammar fragment:
35 :     \begin{Grammar}
36 :     \ExprRULES{}
37 :     \TestExprRULES{}
38 :     \AndExprRULES{}
39 :     \end{Grammar}%
40 :    
41 :     \subsubsection{If-else expressions}
42 :     The if-else expression has the following typing rule:
43 :     \begin{displaymath}
44 :     \infer{
45 :     \HasTy{\ENV}{e_1\;\mkw{if}\;e_2\;\mkw{else}\;e_3}{\tau}
46 :     }{
47 :     \HasTy{\ENV}{e_1}{\tau} \quad
48 :     \HasTy{\ENV}{e_2}{\TYbool} \quad
49 :     \HasTy{\ENV}{e_3}{\tau} \quad
50 :     }
51 :     \end{displaymath}%
52 :     Its semantics are that it evaluates $e_2$ first.
53 :     If the value is true, then it evaluate $e_1$, otherwise it evaluates $e_3$.
54 :    
55 :     \subsubsection{Or-else expressions}
56 :     \begin{displaymath}
57 :     \infer{
58 :     \HasTy{\ENV}{e_1\;\mkw{||}\;e_2}{\TYbool}
59 :     }{
60 :     \HasTy{\ENV}{e_1}{\TYbool} \quad
61 :     \HasTy{\ENV}{e_2}{\TYbool}
62 :     }
63 :     \end{displaymath}%
64 :     The or-else form is derived from the if-else form as follows:
65 :     \begin{displaymath}
66 :     e_1\;\mkw{||}\;e_2 \quad \equiv \quad \mkw{true}\;\mkw{if}\;e_1\;\mkw{else}\;e_2
67 :     \end{displaymath}%
68 :    
69 :     \subsubsection{If-else expressions}
70 :     \begin{displaymath}
71 :     \infer{
72 :     \HasTy{\ENV}{e_1\;\mkw{\&\&}\;e_2}{\TYbool}
73 :     }{
74 :     \HasTy{\ENV}{e_1}{\TYbool} \quad
75 :     \HasTy{\ENV}{e_2}{\TYbool}
76 :     }
77 :     \end{displaymath}%
78 :     The and-also form is derived from the if-else form as follows:
79 :     \begin{displaymath}
80 :     e_1\;\mkw{\&\&}\;e_2 \quad \equiv \quad e_2\;\mkw{if}\;e_1\;\mkw{else}\;\mkw{false}
81 :     \end{displaymath}%
82 :    
83 :     \subsection{Binary expressions}
84 :     \begin{Grammar}
85 :     \CmpExprRULES{}
86 : jhr 1116 \CmpOpRULES{}
87 : jhr 473 \AddExprRULES{}
88 : jhr 1116 \AddOpRULES{}
89 : jhr 473 \MulExprRULES{}
90 :     \MulOpRULES{}
91 : jhr 1116 \PowerExprRULES{}
92 : jhr 473 \ProbeExprRULES{}
93 :     \end{Grammar}%
94 :    
95 : jhr 1116 \subsection{Prefix-operator expressions}
96 : jhr 473 \begin{Grammar}
97 :     \PrefixExprRULES{}
98 :     \end{Grammar}%
99 :    
100 : jhr 1116 \subsection{Suffix-operator expressions}
101 : jhr 473 \begin{Grammar}
102 : jhr 1116 \SuffixExprRULES{}
103 :     \SuffixRULES{}
104 : jhr 473 \IndexRULES{}
105 :     \end{Grammar}%
106 :    
107 : jhr 1116 \subsection{Derivative expressions}
108 :     \begin{Grammar}
109 :     \DerivExprRULES{}
110 :     \end{Grammar}%
111 :    
112 : jhr 473 \subsection{Atomic expressions}
113 :     \begin{Grammar}
114 : jhr 1116 \AtomExprRULES{}
115 : jhr 473 \ArgumentsRULES{}
116 :     \end{Grammar}%

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0