# Ada Programming/Lexical elements
## Character set

The character set used in Ada programs is composed of:
* Upper-case letters: A, ..., Z and lower-case letters: a, ..., z.
* Digits: 0, ..., 9.
* Special characters.
Take into account that in Ada 95 the letter range includes accented characters and other letters used in Western Europe languages, those belonging to the ISO Latin-1 character set, as ç, ñ, ð, etc.
In Ada 2005 the character set has been extended to the full Unicode set, so the identifiers and comments can be written in almost any language in the world.
Ada is a case-insensitive language, i. e. the upper-case set is equivalent to the lower-case set except in character string literals and character literals.

## Lexical elements

In Ada we can find the following lexical elements:
* Identifiers
* Numeric Literals
* Character Literals
* String Literals
* Delimiters
* Comments
* Reserved Words
Example:
This line contains 5 lexical elements:
* The identifier Temperature_In_Room.
* The compound delimiter :=.
* The number 25.
* The single delimiter ;.
* The comment -- Temperature to be preserved in the room..

### Identifiers

Definition in BNF:
From this definition we must exclude the keywords that are reserved words in the language and cannot be used as identifiers.
Examples:
The following words are legal Ada identifiers:
The following ones are NOT legal Ada identifiers:
Exercise: could you give the reason for not being legal for each one of them?

### Numbers

The numeric literals are composed of the following characters:
* digits 0 .. 9
* the decimal separator .,
* the exponentiation sign e or E,
* the negative sign - (in exponents only) and
* the underscore _.
The underscore is used as separator for improving legibility for humans, but it is ignored by the compiler. You can separate numbers following any rationale, e.g. decimal integers in groups of three digits, or binary integers in groups of eight digits.
For example, the real number such as 98.4 can be represented as: 9.84E1, 98.4e0, 984.0e-1 or 0.984E+2, but not as 984e-1.
For integer numbers, for example 1900, it could be written as 1900, 19E2, 190e+1 or 1_900E+0.
A numeric literal could also be expressed in a base different to 10, by enclosing the number between # characters, and preceding it by the base, which can be a number between 2 and 16. For example, 2#101# is 101$_2$, that is 5$_{10}$; a hexadecimal number with exponent is 16#B#E2, that is 11 × 16² = 2,816.
Note that there are no negative literals; e.g. -1 is not a literal, rather it is the literal 1 preceded by the unary minus operator.

### Character literals

Their type is Standard.Character, Wide_Character or Wide_Wide_Character. They are delimited by an apostrophe (').
Examples:

### String literals

String literals are of type Standard.String, Wide_String or Wide_Wide_String. They are delimited by the quotation mark (").
Example:

### Delimiters

Single delimiters are one of the following special characters:
Compound delimiters are composed of two special characters, and they are the following ones:
You can see a full reference of the delimiters in Ada Programming/Delimiters.

### Comments

Comments in Ada start with two consecutive hyphens (--) and end in the end of line.
A comment can appear where an end of line can be inserted.

### Reserved words

Reserved words are equivalent in upper-case and lower-case letters, although the typical style is the one from the Reference Manual, that is to write them in all lower-case letters.
In Ada some keywords have a different meaning depending on context. You can refer to Ada Programming/Keywords and the following pages for each keyword.

## See also
### Wikibook

* Ada Programming
* Ada Programming/Delimiters
* Ada Programming/Keywords

### Ada Reference Manual

* Section 2: Lexical Elements
* 2.1: Character Set
* 2.2: Lexical Elements, Separators, and Delimiters