DEVELOPMENT EDITION · 769442725406
Vada syntax
On this page

Vada lexical structure

Vada source is UTF-8. Tokens consist of identifiers, reserved words, numeric/character/string literals and delimiters. Spaces and line breaks separate tokens without defining blocks. A declaration or statement normally ends with ;; a line ending is not a substitute.

Identifiers and case

An identifier begins with a letter. Letters, digits and single separating underscores may follow. Unicode letters are accepted in identifiers. A leading/trailing underscore or a pair of adjacent underscores is rejected.

Counter       Items_Seen       Sensor_2

Count, COUNT and count refer to the same Vada name. Source spelling is retained in diagnostics. An identifier's case does not create an overload. Selected names use dots: Ada.Text_IO.Put_Line selects a declaration through packages; Point.X selects a field. See name and scope rules.

The lexer recognizes Ada reserved words without case sensitivity. They cannot be declared as identifiers even when their associated construct is excluded. Result, Pre, Post, Natural and Integer are names rather than reserved words; their meaning comes from context and declarations.

Reserved words

The complete reserved-word set is:

abort abs abstract accept access aliased all and array at
begin body case constant declare delay delta digits do else
elsif end entry exception exit for function generic goto if
in interface is limited loop mod new not null of or others
out overriding package parallel pragma private procedure protected
raise range record rem renames requeue return reverse select separate
some subtype synchronized tagged task terminate then type until use
when while with xor

For example, parallel is reserved although parallel constructs are excluded. Do not interpret this list as a support table for every construct named by a keyword.

Comments

-- starts a comment extending to the end of the line. Comments do not nest and do not need a closing delimiter. Vada has no C-style block comments. Two minus characters are a comment starter, not a decrement operator.

Count := Count + 1;  -- advance after the successful call

Comment markers within string literals are ordinary string characters. The formatter and translator preserve comments, although splitting or merging specifications and bodies can move or duplicate a declaration comment. Use documentation-generation conventions for API comments; a comment by itself does not declare a contract.

Numeric literals

A decimal integer literal has digits, optional single separating underscores, and an optional exponent:

0
1_000
12E3

A real literal contains a decimal point with digits on both sides, optionally followed by an exponent: 1.0, 0.125, 1.25E-3. A sign is an operator rather than part of the literal. An integer literal cannot have a negative exponent: use a real spelling such as 1.0E-3. 1..10 contains the range delimiter; it is not a malformed real literal.

Based literals give a base from 2 through 16, then #-delimited digits. Digits above 9 use A through F without case significance. A based real has a point within the delimiters.

16#FF#
2#1010_1010#
16#A.8#E1

The exponent scales by the stated base. Digits must belong to that base, and underscores cannot begin/end a digit sequence or occur consecutively. The obsolescent spelling with : in place of # is diagnosed. Literal magnitude can be represented during compilation beyond a machine integer, but using the literal as a typed runtime value still has range rules: integer ranges, numeric types.

Character and string literals

A character literal has single quotes: 'A'. A string uses double quotes: "Hello, Verada". A quote inside a string is doubled:

Message : constant String := "say ""hello""";

A literal takes its type from its context. A Character or String holds Latin-1, so a literal with a character outside Latin-1 is an error there (B0005); a Wide_Wide_Character or Wide_Wide_String holds any code point, so Greeting : constant Wide_Wide_String := "héllo ☕"; is legal. There are no backslash escapes: "\n" contains a backslash and the letter n, not a newline. Use a character constant from Ada.Characters.Latin_1 or an appropriate I/O operation when an actual control character is needed.

A string literal ends on the line where it begins. Join strings with & to build a value from multiple source lines. "" is the empty string. Percent-delimited strings are obsolescent and diagnosed.

Apostrophes also introduce attributes and qualified expressions, so the surrounding token context matters. Natural'Last is an attribute; Character'('A') qualifies a character literal. Put normal whitespace between separate tokens; do not rely on a quote run to make lexical intent clear.

Delimiters and operators

Every delimiter recognized by this lexer is listed below. Recognition does not establish legality in every context.

Tokens Main roles
( ) Calls, indexing, conversions, grouping, constraints, record aggregates
[ ] Array/value-sequence aggregates
, ; : . Lists, terminators, type introductions, selections
' Attributes and qualification
:= Assignment and initialization
=> Named associations, case arms, iterated aggregate values
.. Inclusive ranges
+ - * / ** & Arithmetic, exponentiation and concatenation
= /= < <= > >= Comparisons
| Choice separators
<> Box/default notation in the supported contexts
@ Target-name expression in a supported assignment context
<< >> Recognized only to diagnose excluded statement labels

The words and, or, xor, not, abs, mod and rem are also operators. and then, or else and not in each consist of two tokens. The lexer selects multi-character delimiters such as := and ** before their shorter components.

C-family ==, !=, &&, || and assignment = are not Vada's equivalent spellings. Some mistakes receive targeted fix-its; recovery after a diagnostic does not make the spelling valid. Vada has no ++ increment, -- decrement, ternary ?:, or standalone address-of &.

Grouping and precedence

See the full expression grammar and precedence table. One common trap is unary minus: in Vada -7 mod 3 means -(7 mod 3). Write (-7) mod 3 to use −7 as the left operand; the value is then 2. A minus in a numeric example is not inherently part of the number token.

Lexical failures and recovery

Malformed identifiers/numbers, invalid UTF-8, non-Latin-1 literals, invalid characters and unterminated strings have numbered diagnostics. A tool may recover to show later errors in the same file. Recovered text is not valid source; repair the first lexical failure before interpreting a cascade of parser messages.

This chapter defines source tokens. It does not imply that all characters permitted in a name are valid foreign symbol names or file paths. Unit filenames and external names follow their own project and interface rules.