Lexical Structure
A .fis and a .fi file are ASCII text read with the same lexer. This
chapter fixes the words the grammars use: what separates
tokens, what a name is, which words are reserved, and how literals are
written.
Whitespace and comments
Spaces, tabs and newlines separate tokens and are otherwise ignored. Comments count as whitespace:
// A line comment runs to the end of the line.
/* A block comment runs to the first closing star-slash. */
Block comments do not nest: /* a /* b */ c */ ends at the first */,
and c */ is then read as source.
Identifiers
ident ::= (letter | '_') (letter | digit | '_')* -- not a reserved word
UIdent ::= ident whose first character is an uppercase letter
letter and digit are ASCII. Case matters. A word that merely starts
with a reserved word is an identifier: irq_count and Mapping_x are
names.
UIdent is what a process is called, in its proc declaration and at
each reference to it (Notified, Drain(x)). Everything else (variables,
events, parameters, mappings, memory regions, protection domains,
channels, structs, constants) takes any ident; the upper and lower case
styles in the other chapters are conventions the parser does not check.
Reserved words
A reserved word is not an identifier, so none can name a variable, event, mapping, region, protection domain, channel, struct or constant.
| Group | Words |
|---|---|
| Security labels | High, Low |
| System items | struct, const, MemoryRegion, ProtectionDomain, System, Chan, Sync, Async, via |
| Program items | import, as, Mapping, irq, evt, proc, default, dbg |
| Process terms | Skip, Div |
| Types | bool, byte, Address, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64 |
| Literals | true, false |
| Reserved, unused | void |
void is reserved so it cannot be read as a struct name; Fiducia has no
void type and no pointers (see Types).
sizeof is not on the list: a variable may be named sizeof. In an
expression, sizeof( followed by a type is the size operator (see
Expressions).
microkit, init and notified are ordinary identifiers; they have
meaning only inside an @bind annotation (see
Entry Points). Likewise packed, inside an
@attr annotation (see Data Layer).
Literals
| Literal | Form | Notes |
|---|---|---|
| Decimal | 0, 42 | Digits only: no _ separators, no leading zeros (07 is an error), no sign. The value must fit an int64. |
| Hexadecimal | 0x1000, 0xFE00_0000 | Lower-case 0x, then hex digits in either case; _ may separate digits after the first. The value must fit a uint64. |
| Boolean | true, false | |
| Text | "..." | Printable ASCII, with the escapes \\, \", \n and \t. Used for mapping permissions and debug output. |
A leading - is never part of a literal: -5 is the unary minus applied
to 5, which the compiler folds to one constant. There are no binary,
octal, character or floating-point literals.
An import path is not a text literal: it
is any characters between the quotes, up to the closing " or the end of
the line.
Punctuation
The process algebra’s operators are -> (event prefix), --> and <->
(channel directions), ||| (interleave), [] (choice), ! (send), ?
(receive) and ; (sequence); @ introduces an annotation. The
expression operators and their precedence are in
Expressions.