Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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.

GroupWords
Security labelsHigh, Low
System itemsstruct, const, MemoryRegion, ProtectionDomain, System, Chan, Sync, Async, via
Program itemsimport, as, Mapping, irq, evt, proc, default, dbg
Process termsSkip, Div
Typesbool, byte, Address, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64
Literalstrue, false
Reserved, unusedvoid

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

LiteralFormNotes
Decimal0, 42Digits only: no _ separators, no leading zeros (07 is an error), no sign. The value must fit an int64.
Hexadecimal0x1000, 0xFE00_0000Lower-case 0x, then hex digits in either case; _ may separate digits after the first. The value must fit a uint64.
Booleantrue, 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.