summaryrefslogtreecommitdiff
path: root/doc/functional_spec.html
blob: 3d84da4c8a2180038f98ce5ce933575de85b7720 (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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<html>
<head>
<title>Mini Ada v1.0 Functional Draft Specification</title>
</head>
<body>

<h2>Mini Ada v1.0 Functional Draft Specification</h2>




<h4>Overview</h4>

<p>Mini Ada is a minimalistic, standalone, portable, libre and open source REPL,
interpreter, JIT, and compiler for the Ada programming language. In that order
of importance.</p>

<p>This spec is not complete. Nor does it discuss algorithms and data structures
used. For those, see the technical spec.</p>




<h4>Scenarios</h4>

<p>Tim is a university student. He has to learn and use Ada for a unit on parallel
computation, but doesn't have much programming experience. He uses the Mini Ada
REPL to get quick feedback, experiment with the language and test what he's
written so far. Then he uses the Mini Ada Compiler to compile his assignments.</p>

<p>James is an Ada developer who wants to write some software for an architecture that
doesn't have an Ada compiler targeting it yet. He downloads and uses the Mini Ada
Interpreter as a stopgap measure, making use of it being written in a language that
has already been ported to every architecture under the sun. He does not have to wait
for a compiler backend to be written.</p>

<p>David is a sysadmin. He wants a scripting language that minimises errors. He uses
the Mini Ada JIT to take advantage of just-in-time compilation speedups and the
design of the Ada language. He's satisfied that the small size of Mini Ada makes
it as easy to deploy as any shell interpreter.</p>




<h4>Non Goals</h4>

<p>The following features will never be supported:</p>
<ul>
  <li>style checks</li>
  <li>self hosting</li>
  <li>error tolerant parser</li>
  <li>TAC/SSA intermediate format</li>
  <li>SPARK proof tools</li>
</ul>

<p>The following will not be supported in version 1:</p>
<ul>
  <li>Ada 83, 95, 2005 modes</li>
  <li>all optional annexes</li>
  <li>any JIT/compiler backend aside from amd64/ELF</li>
</ul>

<p id="tech_issue">What linking is required for FFI and interfacing with already-compiled units?</p>




<h4>Common Elements</h4>

<p>Command line options recognised by all four programs:</p>
<table>
  <tr>
    <th>Short</th>
    <th>Long</th>
    <th>Argument</th>
    <th>Arg Type</th>
    <th>Values</th>
    <th>Description</th>
  </tr>
  <tr>
    <td></td>
    <td>--version</td>
    <td>none</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>Displays the relevant version message then terminates. Any additional options will be ignored.</td>
  </tr>
  <tr>
    <td>-h</td>
    <td>--help</td>
    <td>none</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>Displays the relevant help message then terminates. Any additional options will be ignored.</td>
  </tr>
  <tr>
    <td>-I</td>
    <td></td>
    <td>required</td>
    <td>string</td>
    <td>any valid path</td>
    <td>Specify source files search path.</td>
  </tr>
  <tr>
    <td>-L</td>
    <td></td>
    <td>required</td>
    <td>string</td>
    <td>any valid path</td>
    <td>Specify library files search path.</td>
  </tr>
  <tr>
    <td>-A</td>
    <td>--annex</td>
    <td>required</td>
    <td>string</td>
    <td>Any combination of the characters "abcdefghj".</td>
    <td>Sets the language annexes that will be available during program execution. The default value is "abcdefghj"
    which allows all supported annexes to be used. Informative annexes are not affected by this option.</td>
  </tr>
  <tr>
    <td>-w</td>
    <td>--warning</td>
    <td>required</td>
    <td>character/string</td>
    <td>One of the characters "ens" or one of the strings "error", "normal", "suppress".</td>
    <td>Sets the way warnings are to be treated by the program. Either as an error, as normal, or completely
    suppressed.</td>
  </tr>
  <tr>
    <td>-</td>
    <td>--</td>
    <td>none</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>Terminates the option list and forces all further command line items to be evaluated as arguments.</td>
  </tr>
</table>




<h4>REPL</h4>

<p>This is a read-eval-print-loop interpreter for the Ada programming language. Minor changes have been made to
the accepted grammar to accommodate bare declarations, statements, and expressions, similar to how REPL
interpreters for other languages operate. However the grammar should still accept standard Ada input. This
program can also be used to create informal Ada scripts.</p>

<p>The REPL executable is:</p>
<pre>
marepl
</pre>

<p>Additional command line options are:</p>
<table>
  <tr>
    <th>Short</th>
    <th>Long</th>
    <th>Argument</th>
    <th>Arg Type</th>
    <th>Values</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>-x</td>
    <td></td>
    <td>none</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>Ignores the first line of file input. Doesn't take effect if input is from standard input.</td>
  </tr>
  <tr>
    <td>-i</td>
    <td>--interactive</td>
    <td>none</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>Forces interactive mode after interpreting an input file.</td>
  </tr>
</table>

<p>The version message is:</p>
<pre>
Mini Ada REPL [version in use]
</pre>

<p>The help message is:</p>
<pre>
Usage: marepl [options] [arguments]

The first argument specifies a file to interpret and terminates the option list. All additional
arguments are passed to the interpreted file as command line arguments.

Options:
         --version        displays the REPL version number
-h       --help           displays this help message
-Idir                     specifies source files search path
-Ldir                     specifies library files search path
-Aarg    --annex=arg      specify which language annexes will be allowed
-warg    --warning=arg    how to treat warnings
-        --               terminates option list
-x                        ignores the first line of file input
-i       --interactive    forces interactive mode after interpreting a file
</pre>

<p>The first non-option command line item specifies a file to interpret and terminates the option list.
Any further command line items are passed to the interpreted file as command line arguments. If no file
is supplied to interpret, input is obtained from standard input.</p>

<p>If no file to interpret is supplied, the following message is displayed:</p>
<pre>
Mini Ada REPL [version in use]
Ada [standard in use] mode, [annexes available]
</pre>

<p>Followed by the prompt for input, which is:</p>
<pre>
&gt;
</pre>

<p>A valid input is a repl_unit, described by the following BNF grammar:</p>
<pre>
repl_unit ::= { context_item | library_item | subunit
              | declarative_item | statement | label | expression }
</pre>

<p>If a line of input is the beginning part of a valid input, then further prompts for input will be
supplied until either a syntax error is encountered or a complete valid input is received. The complete
input is then interpreted and evaluated.</p>

<p>The result of a bare expression is displayed after it is evaluated, similar to other REPLs.</p>

<p>If evaluation is successful, the following message is displayed:</p>
<pre>
ok
</pre>

<p>Otherwise, an appropriate error message is displayed. See section on error and warning messages for
information on specific error messages. For the purposes of the error, only the lines of the last complete
input are numbered, starting from one.</p>

<p>If an input file has been supplied to interpret, processing of the file proceeds as above, except without
any messages or prompts aside from error messages and those produced by the interpretation and evaluation of
the contents of the file.</p>

<p>Interpretation is ended and control returned to the operating system when the REPL encounters the
EOF character.</p>




<h4>Interpreter</h4>

<p>The interpreter executable is:</p>
<pre>
mai
</pre>

<p>Additional command line options are:</p>
<table>
  <tr>
    <th>Short</th>
    <th>Long</th>
    <th>Argument</th>
    <th>Arg Type</th>
    <th>Values</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>-x</td>
    <td></td>
    <td>none</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>Ignores the first line of file input. Doesn't take effect if input is from standard input.</td>
  </tr>
</table>

<p>The first non-option command line item specifies a file to interpret and terminates the option list.
Any further command line items are passed to the interpreted file as command line arguments.</p>

<p>The version message is:</p>
<pre>
Mini Ada Interpreter [version number]
</pre>

<p>The help message is:</p>
<pre>
Usage: mai [options] [arguments]

The first argument specifies a file to interpret and terminates the option list. All additional
arguments are passed to the interpreted file as command line arguments.

Options:
         --version        displays the REPL version number
-h       --help           displays this help message
-Idir                     specifies source files search path
-Ldir                     specifies library files search path
-Aarg    --annex=arg      specify which language annexes will be allowed
-warg    --warning=arg    how warnings are to be treated
-        --               terminates option list
-x                        ignores the first line of file input
</pre>

<p>This program expects as file input a valid compilation_unit (RM 10.1.1). The input is interpreted and
evaluated, then (should the input terminate) control is returned to the operating system. At no point is any
platform-specific code generated, except as required by the Ada standard itself.</p>




<h4>Just In Time</h4>

<p>The JIT executable will be</p>
<pre>
majit
</pre>

<p>Additional command line options, version message, and help message are all identical to that of the
Interpreter, with the word "JIT" substituted for "Interpreter".</p>




<h4>Compiler</h4>

<p>The compiler executable will be</p>
<pre>
mac
</pre>




<h4>Error and Warning Messages</h4>

<p>Should any of these programs encounter an error, an error message will be displayed to the standard
error stream. This error message will consist of the following format:</p>
<pre>
Error at line [number], character [number]
</pre>

<p>Should any of these programs encounter a warning, a warning message will be displayed to the standard
error stream. This warning message will consiste of the following format:</p>
<pre>
Warning at line [number], character [number]
</pre>

<p id="tech issue">What sorts of error/warning messages are required by the Ada specification?</p>

</body>
</html>