summaryrefslogtreecommitdiff
path: root/src/Transfer/Core/Doc.tex
blob: c3f95fedcc2cde9cf7d17a46aa3713522ccb8aba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
\batchmode
%This Latex file is machine-generated by the BNF-converter

\documentclass[a4paper,11pt]{article}
\author{BNF-converter}
\title{The Language Core}
\setlength{\parindent}{0mm}
\setlength{\parskip}{1mm}
\begin{document}

\maketitle

\newcommand{\emptyP}{\mbox{$\epsilon$}}
\newcommand{\terminal}[1]{\mbox{{\texttt {#1}}}}
\newcommand{\nonterminal}[1]{\mbox{$\langle \mbox{{\sl #1 }} \! \rangle$}}
\newcommand{\arrow}{\mbox{::=}}
\newcommand{\delimit}{\mbox{$|$}}
\newcommand{\reserved}[1]{\mbox{{\texttt {#1}}}}
\newcommand{\literal}[1]{\mbox{{\texttt {#1}}}}
\newcommand{\symb}[1]{\mbox{{\texttt {#1}}}}

This document was automatically generated by the {\em BNF-Converter}. It was generated together with the lexer, the parser, and the abstract syntax module, which guarantees that the document matches with the implementation of the language (provided no hand-hacking has taken place).

\section*{The lexical structure of Core}

\subsection*{Literals}
String literals \nonterminal{String}\ have the form
\terminal{"}$x$\terminal{"}, where $x$ is any sequence of any characters
except \terminal{"}\ unless preceded by \verb6\6.


Integer literals \nonterminal{Int}\ are nonempty sequences of digits.





TMeta literals are recognized by the regular expression
\(\mbox{`?'} {\nonterminal{digit}}+\)

CIdent literals are recognized by the regular expression
\(({\nonterminal{letter}} \mid \mbox{`\_'}) ({\nonterminal{letter}} \mid {\nonterminal{digit}} \mid \mbox{`\_'} \mid \mbox{`''})*\)


\subsection*{Reserved words and symbols}
The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions.

The reserved words used in Core are the following: \\

\begin{tabular}{lll}
{\reserved{Type}} &{\reserved{case}} &{\reserved{data}} \\
{\reserved{in}} &{\reserved{let}} &{\reserved{of}} \\
{\reserved{where}} & & \\
\end{tabular}\\

The symbols used in Core are the following: \\

\begin{tabular}{lll}
{\symb{;}} &{\symb{:}} &{\symb{\{}} \\
{\symb{\}}} &{\symb{{$=$}}} &{\symb{(}} \\
{\symb{)}} &{\symb{\_}} &{\symb{$\backslash$}} \\
{\symb{{$-$}{$>$}}} &{\symb{.}} & \\
\end{tabular}\\

\subsection*{Comments}
Single-line comments begin with {\symb{{$-$}{$-$}}}. \\Multiple-line comments are  enclosed with {\symb{\{{$-$}}} and {\symb{{$-$}\}}}.

\section*{The syntactic structure of Core}
Non-terminals are enclosed between $\langle$ and $\rangle$. 
The symbols  {\arrow}  (production),  {\delimit}  (union) 
and {\emptyP} (empty rule) belong to the BNF notation. 
All other symbols are terminals.\\

\begin{tabular}{lll}
{\nonterminal{Module}} & {\arrow}  &{\nonterminal{ListDecl}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ListDecl}} & {\arrow}  &{\emptyP} \\
 & {\delimit}  &{\nonterminal{Decl}}  \\
 & {\delimit}  &{\nonterminal{Decl}} {\terminal{;}} {\nonterminal{ListDecl}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Decl}} & {\arrow}  &{\terminal{data}} {\nonterminal{CIdent}} {\terminal{:}} {\nonterminal{Exp}} {\terminal{where}} {\terminal{\{}} {\nonterminal{ListConsDecl}} {\terminal{\}}}  \\
 & {\delimit}  &{\nonterminal{CIdent}} {\terminal{:}} {\nonterminal{Exp}}  \\
 & {\delimit}  &{\nonterminal{CIdent}} {\terminal{{$=$}}} {\nonterminal{Exp}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ConsDecl}} & {\arrow}  &{\nonterminal{CIdent}} {\terminal{:}} {\nonterminal{Exp}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ListConsDecl}} & {\arrow}  &{\emptyP} \\
 & {\delimit}  &{\nonterminal{ConsDecl}}  \\
 & {\delimit}  &{\nonterminal{ConsDecl}} {\terminal{;}} {\nonterminal{ListConsDecl}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ListPattern}} & {\arrow}  &{\emptyP} \\
 & {\delimit}  &{\nonterminal{Pattern}} {\nonterminal{ListPattern}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Pattern}} & {\arrow}  &{\terminal{(}} {\nonterminal{CIdent}} {\nonterminal{ListPattern}} {\terminal{)}}  \\
 & {\delimit}  &{\nonterminal{PatternVariable}}  \\
 & {\delimit}  &{\terminal{\{}} {\nonterminal{ListFieldPattern}} {\terminal{\}}}  \\
 & {\delimit}  &{\terminal{Type}}  \\
 & {\delimit}  &{\nonterminal{String}}  \\
 & {\delimit}  &{\nonterminal{Integer}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{FieldPattern}} & {\arrow}  &{\nonterminal{CIdent}} {\terminal{{$=$}}} {\nonterminal{Pattern}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ListFieldPattern}} & {\arrow}  &{\emptyP} \\
 & {\delimit}  &{\nonterminal{FieldPattern}}  \\
 & {\delimit}  &{\nonterminal{FieldPattern}} {\terminal{;}} {\nonterminal{ListFieldPattern}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{PatternVariable}} & {\arrow}  &{\nonterminal{CIdent}}  \\
 & {\delimit}  &{\terminal{\_}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Exp}} & {\arrow}  &{\terminal{let}} {\terminal{\{}} {\nonterminal{ListLetDef}} {\terminal{\}}} {\terminal{in}} {\nonterminal{Exp}}  \\
 & {\delimit}  &{\terminal{case}} {\nonterminal{Exp}} {\terminal{of}} {\terminal{\{}} {\nonterminal{ListCase}} {\terminal{\}}}  \\
 & {\delimit}  &{\nonterminal{Exp1}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{LetDef}} & {\arrow}  &{\nonterminal{CIdent}} {\terminal{:}} {\nonterminal{Exp}} {\terminal{{$=$}}} {\nonterminal{Exp}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ListLetDef}} & {\arrow}  &{\emptyP} \\
 & {\delimit}  &{\nonterminal{LetDef}}  \\
 & {\delimit}  &{\nonterminal{LetDef}} {\terminal{;}} {\nonterminal{ListLetDef}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Exp2}} & {\arrow}  &{\terminal{$\backslash$}} {\nonterminal{PatternVariable}} {\terminal{{$-$}{$>$}}} {\nonterminal{Exp}}  \\
 & {\delimit}  &{\terminal{(}} {\nonterminal{PatternVariable}} {\terminal{:}} {\nonterminal{Exp}} {\terminal{)}} {\terminal{{$-$}{$>$}}} {\nonterminal{Exp}}  \\
 & {\delimit}  &{\nonterminal{Exp3}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Exp3}} & {\arrow}  &{\nonterminal{Exp3}} {\nonterminal{Exp4}}  \\
 & {\delimit}  &{\nonterminal{Exp4}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Exp4}} & {\arrow}  &{\nonterminal{Exp4}} {\terminal{.}} {\nonterminal{CIdent}}  \\
 & {\delimit}  &{\nonterminal{Exp5}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Exp5}} & {\arrow}  &{\terminal{\{}} {\terminal{\}}}  \\
 & {\delimit}  &{\terminal{\{}} {\nonterminal{ListFieldType}} {\terminal{\}}}  \\
 & {\delimit}  &{\terminal{\{}} {\nonterminal{ListFieldValue}} {\terminal{\}}}  \\
 & {\delimit}  &{\nonterminal{CIdent}}  \\
 & {\delimit}  &{\terminal{Type}}  \\
 & {\delimit}  &{\nonterminal{String}}  \\
 & {\delimit}  &{\nonterminal{Integer}}  \\
 & {\delimit}  &{\nonterminal{TMeta}}  \\
 & {\delimit}  &{\terminal{(}} {\nonterminal{Exp}} {\terminal{)}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Exp1}} & {\arrow}  &{\nonterminal{Exp2}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{Case}} & {\arrow}  &{\nonterminal{Pattern}} {\terminal{{$-$}{$>$}}} {\nonterminal{Exp}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ListCase}} & {\arrow}  &{\emptyP} \\
 & {\delimit}  &{\nonterminal{Case}}  \\
 & {\delimit}  &{\nonterminal{Case}} {\terminal{;}} {\nonterminal{ListCase}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{FieldType}} & {\arrow}  &{\nonterminal{CIdent}} {\terminal{:}} {\nonterminal{Exp}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ListFieldType}} & {\arrow}  &{\nonterminal{FieldType}}  \\
 & {\delimit}  &{\nonterminal{FieldType}} {\terminal{;}} {\nonterminal{ListFieldType}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{FieldValue}} & {\arrow}  &{\nonterminal{CIdent}} {\terminal{{$=$}}} {\nonterminal{Exp}}  \\
\end{tabular}\\

\begin{tabular}{lll}
{\nonterminal{ListFieldValue}} & {\arrow}  &{\nonterminal{FieldValue}}  \\
 & {\delimit}  &{\nonterminal{FieldValue}} {\terminal{;}} {\nonterminal{ListFieldValue}}  \\
\end{tabular}\\



\end{document}