Mini Ada v1.0 Functional Draft Specification

Overview

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.

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

Scenarios

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.

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.

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.

Non Goals

The following features will never be supported:

The following will not be supported in version 1:

What linking is required for FFI and interfacing with already-compiled units?

Common Elements

Command line options recognised by all four programs:

Short Long Argument Arg Type Values Description
--version none N/A N/A Displays the relevant version message then terminates. Any additional options will be ignored.
-h --help none N/A N/A Displays the relevant help message then terminates. Any additional options will be ignored.
-I required string any valid path Specify source files search path.
-L required string any valid path Specify library files search path.
-A --annex required string Any combination of the characters "abcdefghj". 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.
-w --warning required character/string One of the characters "ens" or one of the strings "error", "normal", "suppress". Sets the way warnings are to be treated by the program. Either as an error, as normal, or completely suppressed.
- -- none N/A N/A Terminates the option list and forces all further command line items to be evaluated as arguments.

REPL

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.

The REPL executable is:

marepl

Additional command line options are:

Short Long Argument Arg Type Values Description
-x none N/A N/A Ignores the first line of file input. Doesn't take effect if input is from standard input.
-i --interactive none N/A N/A Forces interactive mode after interpreting an input file.

The version message is:

Mini Ada REPL [version in use]

The help message is:

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

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.

If no file to interpret is supplied, the following message is displayed:

Mini Ada REPL [version in use]
Ada [standard in use] mode, [annexes available]

Followed by the prompt for input, which is:

>

A valid input is a repl_unit, described by the following BNF grammar:

repl_unit ::= { context_item | library_item | subunit
              | declarative_item | statement | label | expression }

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.

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

If evaluation is successful, the following message is displayed:

ok

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.

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.

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

Interpreter

The interpreter executable is:

mai

Additional command line options are:

Short Long Argument Arg Type Values Description
-x none N/A N/A Ignores the first line of file input. Doesn't take effect if input is from standard input.

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.

The version message is:

Mini Ada Interpreter [version number]

The help message is:

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

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.

Just In Time

The JIT executable will be

majit

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

Compiler

The compiler executable will be

mac

Error and Warning Messages

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:

Error at line [number], character [number]

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:

Warning at line [number], character [number]

What sorts of error/warning messages are required by the Ada specification?