Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Side by Side Diff: doc/definition/strong-dart.tex

Issue 1205173003: Syntax and subtyping for strong dart (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « doc/definition/strong-dart.pdf ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 \documentclass[fleqn]{article}
2 \usepackage{proof, amsmath}
3
4 % types
5 \newcommand{\Arrow}[2]{#1 \rightarrow #2}
6 \newcommand{\Bool}{\mathbf{bool}}
7 \newcommand{\Bottom}{\mathbf{bottom}}
8 \newcommand{\Dynamic}{\mathbf{dynamic}}
9 \newcommand{\Null}{\mathbf{Null}}
10 \newcommand{\Num}{\mathbf{num}}
11 \newcommand{\Object}{\mathbf{Object}}
12 \newcommand{\TApp}[2]{#1\mathrm{<}#2\mathrm{>}}
13 \newcommand{\Type}{\mathbf{Type}}
14
15 % expressions
16 \newcommand{\eapp}[2]{#1(#2)}
17 \newcommand{\eas}[2]{#1\ \mathbf{as}\ #2}
18 \newcommand{\eassign}[2]{#1 = #2}
19 \newcommand{\eff}{\mathrm{ff}}
20 \newcommand{\eis}[2]{#1\ \mathbf{is}\ #2}
21 \newcommand{\elambda}[2]{(#1) \Rightarrow #2}
22 \newcommand{\enew}[3]{\mathbf{new}\,\TApp{#1}{#2}(#3)}
23 \newcommand{\enull}{\mathbf{null}}
24 \newcommand{\eprimapp}[2]{\eapp{#1}{#2}}
25 \newcommand{\eproj}[2]{#1.#2}
26 \newcommand{\esend}[3]{\eapp{\eproj{#1}{#2}}{#3}}
27 \newcommand{\esuper}{\mathbf{super}}
28 \newcommand{\ethis}{\mathbf{this}}
29 \newcommand{\ett}{\mathrm{tt}}
30
31 % keywords
32 \newcommand{\kwclass}{\mathbf{class}}
33 \newcommand{\kwextends}{\mathbf{extends}}
34 \newcommand{\kwelse}{\mathbf{else}}
35 \newcommand{\kwif}{\mathbf{if}}
36 \newcommand{\kwin}{\mathbf{in}}
37 \newcommand{\kwlet}{\mathbf{let}}
38 \newcommand{\kwreturn}{\mathbf{return}}
39 \newcommand{\kwthen}{\mathbf{then}}
40 \newcommand{\kwvar}{\mathbf{var}}
41
42 % declarations
43 \newcommand{\dclass}[3]{\kwclass\ #1\ \kwextends\ #2\ \{#3\}}
44 \newcommand{\dfun}[4]{#1\ #2(#3)\ #4}
45 \newcommand{\dvar}[2]{\kwvar\ #1\ =\ #2}
46
47 % statements
48 \newcommand{\sifthenelse}[3]{\kwif\ (E1)\ \kwthen\ #2\ \kwelse\ #3}
49 \newcommand{\sreturn}[1]{\kwreturn\ #1}
50
51 % programs
52 \newcommand{\program}[2]{\kwlet\ #1\ \kwin\ #2}
53
54 % relational operators
55 \newcommand{\sub}{\mathop{<:}}
56
57 % utilities
58 \newcommand{\many}[1]{\overrightarrow{#1}}
59 \newcommand{\alt}{\ \mathop{|}\ }
60
61 % inference rules
62 \newcommand{\axiom}[1]{\infer{#1}{}}
63 \newcommand{\infrule}[2]{\infer{#2}{#1}}
64
65 % relations
66 \newcommand{\extends}[4][:]{#2[#3\ #1\ #4]}
67 \newcommand{\subst}[2]{[#1/#2]}
68 \newcommand{\subtypeOf}[3]{#1 \vdash\ #2 \sub\ #3}
69
70 \title{Dart strong mode definition}
71
72 \begin{document}
73
74 \section*{Syntax}
75
76
77 \[
78 \begin{array}{lcl}
79 \text{Type identifiers} & ::= & C, G, T, S, \ldots \\
80 %
81 \text{Types $\tau, \sigma$} & ::= &
82 T \alt \Dynamic \alt \Object \alt \Null \alt \Type \alt \Num \alt \Bool \\ &&
83 \alt \Arrow{\many{\tau}}{\sigma} \alt \TApp{C}{\many{\tau}} \\
84 %
85 \text{Term identifiers} & ::= & a, b, x, y, m, n, \ldots \\
86 %
87 \text{Primops ($\phi$)} & ::= & \mathrm{+}, \mathrm{-} \ldots \mathrm{||} \ldots \\
88 %
89 \text{lhs ($l$)} & ::= & x \alt \eproj{e}{m} \\
90 %
91 \text{Expressions $e$} & ::= &
92 x \alt i \alt \ett \alt \eff \alt \enull \alt \ethis \alt \esuper
93 \alt \elambda{\many{x:\tau}}{e} \alt \enew{C}{\many{\tau}}{\many{e}} \\&&
94 \alt \eprimapp{\phi}{\many{e}} \alt \eapp{e}{\many{e}}
95 \alt \eproj{e}{m} \alt \eassign{l}{e} \\&&
96 \alt \eas{e}{\tau} \alt \eis{e}{\tau} \\
97 %
98 \text{Declaration ($\mathit{vd}$)} & ::= &
99 \dvar{x}{e} \alt \dvar{x:\tau}{e} \alt \dfun{\tau}{f}{\many{x:\tau}}{b} \\
100 %
101 \text{Statements ($s$)} & ::= & \mathit{vd} \alt e \alt \sifthenelse{e}{b_1}{b_2 }
102 \alt \sreturn{e} \alt s;s \\
103 %
104 \text{Blocks ($b$)} & ::= & \{s;\} \\
105 %
106 \text{Class decl ($\mathit{cd}$)} & ::= & \dclass{\TApp{C}{\many{T}}}{\TApp{G}{\ many{S}}}{\many{\mathit{vd}}} \\
107 %
108 \text{Toplevel decl ($\mathit{td}$)} & ::= & \mathit{vd} \alt \mathit{cd}\\
109 %
110 \text{Program ($P$)} & ::= & \program{\many{\mathit{td}}}{b}
111 \end{array}
112 \]
113
114
115
116 \[
117 \begin{array}{lcl}
118 \text{Class signature ($\mathit{Sig}$)} & ::= & \dclass{\TApp{C}{\many{T}}}{\TA pp{G}{\many{S}}}{\many{x:\tau}} \\
119 \text{Type context ($\Delta$)} & ::= & \epsilon \alt \Delta, X \sub \tau \\
120 \text{Class hierarchy ($\Phi$)} & ::= & \epsilon \alt \Phi, C\ :\ \mathit{Sig}
121 \end{array}
122 \]
123
124
125 \section*{Subtyping}
126 \[
127 \begin{array}{ccc}
128 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\Dynamic}} &
129 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\Object}} \\\\
130 %
131 \axiom{\subtypeOf{\Phi, \Delta}{\Bottom}{\tau}} &
132 \axiom{\subtypeOf{\Phi, \Delta}{\tau}{\tau}} \\\\
133 %
134 \infrule{\Delta = \extends[\sub]{\Delta'}{S}{\sigma} &
135 \subtypeOf{\Phi, \Delta}{\sigma}{\tau}}
136 {\subtypeOf{\Phi, \Delta}{S}{\tau}} \\\\
137 %
138 \infrule{\subtypeOf{\Phi, \Delta}{\sigma_i}{\tau_i} & i \in 0, \ldots, n &
139 \subtypeOf{\Phi, \Delta}{\tau_r}{\sigma_r}}
140 {\subtypeOf{\Phi, \Delta}
141 {\Arrow{\tau_0, \ldots, \tau_n}{\tau_r}}
142 {\Arrow{\sigma_0, \ldots, \sigma_n}{\sigma_r}}} \\\\
143 %
144 \infrule{\subtypeOf{\Phi, \Delta}{\tau_i}{\sigma_i} & i \in 0, \ldots, n}
145 {\subtypeOf{\Phi, \Delta}
146 {\TApp{C}{\tau_0, \ldots, \tau_n}}
147 {\TApp{C}{\sigma_0, \ldots, \sigma_n}}}\\\\
148 %
149 \infrule{\Phi = \extends{\Phi'}{C}{\dclass{\TApp{C}{T_0,\ldots,T_n}}{\TApp{C'}{\ upsilon_0, \ldots, \upsilon_k}}{\ldots}} \\
150 \subtypeOf{\Phi, \Delta}{\subst{\tau_0, \ldots, \tau_n}{T_0, \ldots, T_ n}{\TApp{C'}{\upsilon_0, \ldots, \upsilon_k}}}{\TApp{G}{\sigma_0, \ldots, \sigma _m}}}
151 {\subtypeOf{\Phi, \Delta}
152 {\TApp{C}{\tau_0, \ldots, \tau_n}}
153 {\TApp{G}{\sigma_0, \ldots, \sigma_m}}}
154 \end{array}
155 \]
156
157 \end{document}
OLDNEW
« no previous file with comments | « doc/definition/strong-dart.pdf ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698