Section 3.1 - Ada Lexical Elements

Now that we've seen a little about the ``big picture'' of Ada structure -- essentially Ada from the ``top down'' -- let's look at Ada from the other direction -- ``bottom up.''

Ada compilation units are, at the lowest level, composed of a sequence of lexical elements. Lexical elements include identifiers (such as the name of a procedure), reserved words, and various punctuation marks. Reserved words include ``procedure'', ``package'', ``end'', ``if'', and so on.

Ada is a free-form language like Pascal, C, and C++; line breaks and spaces can go essentially wherever you like between lexical elements. If identifiers or keywords are next to each other, they must be explicitly separated by one or more spaces and/or end-of-line markers.

Ada is also case-insensitive; except for the contents of strings (which are inside quotes), upper and lower case keywords and identifiers are equivalent.

Ada as a language permits a great deal of freedom, but some consistency of capitalization and indentation are helpful for reading later. The style used in this tutorial is the style suggested in the Software Productivity Consortia's (SPC) Ada Quality and Style: A Guide to Professional Programmers (which is the recommended style guide by the Ada Joint Program Office). In this style keywords are in lower case, identifiers have initial capitals, and there is at most one statement per line. If an identifier has more than one word in it, each word should have an initial capital letter and the words should have underscores (``_'') between them.


From a compiler's point of view, are procedures 1 and 2 identical or not?

Procedure 1:

 with Text_IO;
 procedure Hello is
  Text_IO.Put("This is a test!");
 end Hello;

Procedure 2:

 WITH TEXT_IO; PROCEDURE hello IS           BeGiN
 TEXT_IO.put("This is a test!"); END hello;
  1. They are identical to the compiler.
  2. They are different to the compiler.

You may also:

PREVIOUS Go back to the previous section

NEXT     Skip to the next section

OUTLINE  Go up to lesson 3 outline

David A. Wheeler (

The master copy of this file is at "".