On this page
Varc lexical structure
Varc files are UTF-8. Identifiers, keywords, literals and punctuation are tokens; whitespace and comments separate them. Newlines do not terminate statements. Simple statements and most nonbraced declarations end with ;; { ... } delimit compound forms.
Names
Names begin with a letter or underscore and continue with letters, digits, combining marks and accepted identifier connector characters. Unicode letters are accepted. Unlike Vada, leading/trailing/repeated underscores are not rejected solely by Ada identifier rules.
point Point buffer_2 _internal source_name
Varc distinguishes source names by case where supported, including local point and Point. Translation can mangle names that Ada cannot distinguish. Mixed/public APIs still need spelling and collision discipline across the actual extraction/translation boundary; avoid designing an interface whose only distinction is case.
_ alone is a special token, used as a match wildcard or a pipe placeholder in the specified contexts. It is not an ordinary mutable local identifier.
A raw identifier prefixes a name with r#:
var r#match: Integer = 0;
The prefix lets a reserved or contextual spelling be used as an identifier where names are accepted. It does not rename a library declaration. Raw tokens also avoid contextual interpretation such as result in its special contract position.
Reserved and contextual words
The complete reserved words are case-sensitive and lowercase:
abs abstract aliased as assert assume break const else enum exception
exists fn for forall generic ghost if impl import in init inout let
limited loop match new null others out override package private pub ref
renames return reverse struct subtype tagged throw type use var when while with
Several additional words are contextual, not globally reserved. The parser recognizes them at particular positions:
| Context | Contextual spellings |
|---|---|
| Contract clauses | requires ensures cases throws decreases |
| Contract values | result old |
| Loop proof annotation | invariant decreases |
| Scalar type definitions | range mod digits delta |
| Interfaces/constraints | interface synchronized and not all |
| Package visibility/body/subunit forms | child body separate |
| Tasking/time | task protected entry delay until |
| Exception blocks | try catch finally |
| Loops | continue step_by |
| Representation clauses | record at range mod |
| Operators-as-names | operator |
| Pipeline syntax | map filter take_while zip enumerate sum product count reduce collect all any find first last |
Contextual words can be ordinary names elsewhere, but choose raw names or less ambiguous identifiers when a spelling begins a recognized form. True and False are predefined Boolean literals reached through the shared environment; true/false are not alternate keyword tokens.
Comments
// starts a line comment. /* ... */ is a block comment, and block comments nest:
// a line comment
/* outer /* inner */ outer again */
Comment delimiters inside strings are ordinary characters. Every nested /* needs its own */. Unterminated comments receive a lexical diagnostic. Comments are retained for formatting and translation, but source layout or attachment can change during package split/merge.
Numbers
Decimal integers allow separating underscores: 1_000. Decimal exponent notation is accepted: 12e3. Reals have digits on both sides of a point, optionally followed by an exponent: 1.0, 0.125, 1.25e-3. A signed value is a prefix expression; a sign is not part of the numeric token.
Based integer prefixes are 0x/0X for hexadecimal, 0o/0O for octal and 0b/0B for binary:
let mask = 0xFF;
let bits = 0b1010_1010;
let mode = 0o755;
These declarations are syntax fragments. Digits must be valid in the base and underscore placement must be valid. No C integer-width suffix is implied by the literal's spelling. Based real notation and Ada 16#FF# are not Varc's forms.
An integer literal cannot have a negative exponent: write 1.0e-3 rather than 1e-3. A compile-time number can be represented before a concrete type is chosen; the final destination and arithmetic remain subject to finite integer bounds.
Strings and characters
Strings use double quotes and characters use single quotes. The recognized escapes are:
| Escape | Character |
|---|---|
\n, \t, \r |
Newline, tab, carriage return |
\0 |
Zero byte |
\\, \", \' |
Backslash and quotes |
\xHH |
Two hexadecimal digits |
\u{H...} |
Hexadecimal code point, still subject to value-type limits |
let text: String = "say \"hello\"";
let newline: Character = '\n';
A literal takes its type from its context: Character and String hold Latin-1, so a character outside Latin-1 is an error there (B0005), while Wide_Wide_Character and Wide_Wide_String hold any code point. A string must end on its source line; join values with ++ for multi-line construction. There are no Python f-strings or arbitrary raw-string delimiters.
A string literal is interpreted as copyable Text when an expected Text type selects that surface form; otherwise it remains the applicable String form. Varc retains Ada-style String as a separate type. See string types.
Every symbol token
| Tokens | Use |
|---|---|
( ) [ ] { } |
Calls/grouping, indexing/array forms, blocks |
, ; : . :: |
Lists, termination, annotations/selections/attributes |
.. ... ..= ..< |
Unconstrained-index marker, two inclusive spellings, and half-open ranges |
=> -> |
Arms/lambdas/associations and result types |
= == != < <= > >= |
Assignment, equality and ordering |
<> |
Box/default notation |
+ ++ - * ** / % %% |
Arithmetic, concatenation, exponentiation, remainder/modulus |
& && | || ^ ! |
Mutable mark, bitwise/Boolean operators and negation |
|> |
Pipe |
@ _ |
Annotation/target name and contextual wildcard/placeholder |
+= -= *= /= %= &= |= ^= |
Compound assignments |
? -- |
Recognized symbols without general expression/statement support |
The single | in that table is also a match/exception choice separator. & at an actual parameter is a mutable-argument mark rather than a general address-of operator. @ before a name starts an annotation/pragma; in a supported expression position it is the target name. ++ concatenates and does not increment. The lexer recognizes -- for a targeted diagnostic; it is not a comment starter or supported decrement statement.
There is no %%= token for modulus assignment, &&=/||= operator, ternary ?:, shift operator or Rust ? error-propagation syntax. Use the supported library operations and explicit control flow.
Foreign-looking mistakes
count++;, switch and do ... while receive targeted diagnostics. /= is divide-and-assign in Varc; it is not Vada inequality. Use != for inequality and == for equality. A typo can be recovered for a useful follow-up diagnostic; recovery does not make the input accepted.
See expression precedence before relying on C's bitwise/comparison precedence or assuming exponentiation follows Python's unparenthesized prefix convention.