2 Synthesis‎ > ‎Computing‎ > ‎Programming‎ > ‎Ada‎ > ‎Ada Language‎ > ‎

Lexical Elements

These examples have comments which start with double minus -- . Also they may be spread over a few lines. i.e.

12    56      100    --Here are some numbers
2.7   3.142   99.2   --Here are some more numbers

Examples of comments:

-- the last sentence above echoes the Algol 68 report
-- processing of Line is complete
-- a long comment may be split onto
-- two or more consecutive lines
---------------- the first two hyphens start the comment the rest are padding

Examples of identifiers:

Get_Symbol   Count   X    
Snobol_4   X1   Page_Count
Πλάτων   -- Plato a Comment
Чайковский   -- Tchaikovsky a Comment
θ   φ   -- Angles a Comment

Examples of decimal literals:

Note that in Ada putting underscores in numbers is allowed so 12_034 is the same as writing 12034.

12   0   1E6   123_456   -- integer literals
3.14159_26   12.0   0.0   0.456   -- real literals

Examples of based literals:

Numbers written in bases other than 10 are written <base>#<digits>#

2#1111_1111#   16#FF#   016#0ff#   -- integer literals of value 255
16#E#E1   2#1110_0000#   -- integer literals of value 224
16#F.FF#E+2   2#1.1111_1111_1110#E11   -- real literals of value 4095.0

Examples of character literals:

'A'   '*'   '''   ' '

'L'   'Л'   'Λ'   -- Various els.

Examples of string literals:

To include quote in a string literal use two quotes as in the first example
"Archimedes said ""Εύρηκα"""
"Message of the day"
""   -- a null string literal
" "   "A"   """"  -- three string literals of length 1
"Characters such as $, %, and } are allowed in string literals"
"Volume of cylinder (πr2h) = "

Examples of pragmas:

Pragmas direct the compilation process.
pragma List(Off); -- turn off listing generation
pragma Optimize(Off); -- turn off optional optimizations
pragma Inline(Set_Mask); -- generate code for Set_Mask inline
pragma Import(C, Put_Char, External_Name => "putchar"); -- import C putchar function

Reserved Words

The following are the reserved words. Within a program, some or all of the letters of a reserved word may be in upper case, and one or more characters in category other_format may be inserted within or at the end of the reserved word.

A-  abortabs abstract accept access aliased all and array at
B- begin
C- case
D- declare
delay delta digits do
E- else
elsif end entry exception exit
F- for
G- generic
I- if
in interface is
L- limited
M- mod
N- new
not null
O- of
or others out overriding
P- package
pragma private procedure protected
R- raise
range record rem renames requeue return reverse
S- select
separate subtype synchronized
T- tagged
task terminate then type
U- until
W- when
while with
X- xor

The reserved words appear in lower case boldface in this International Standard, except when used in the designator of an attribute (see 4.1.4 ARM). Lower case boldface is also used for a reserved word in a string_literal used as an operator_symbol. This is merely a convention — programs may be written in whatever typeface is desired and available.