Identifiers and Keywords
Grammar
name ::= letter constituent* | "_" constituent*
constituent ::= letter | digit | "_" | "'"
quals ::= (name ".")+
qualname ::= name | quals name
symbol ::= symstartchar symchar*
qualsymbol ::= symbol | quals symbol | "`" qualname "`"
fieldid ::= decimal | name
symstartchar ::= "+" | "-" | "*" | "/" | "%" | "=" | "!" | ">" | "<" | "|" | "&" | "^"
symchar ::= symstartchar | "."
constructor ::= "#" name
Description
Many elements in Wyn are named. When defining something, we give it an unqualified name (name). When referencing something inside a module, we use a qualified name (qualname). We can also use symbols (symbol, qualsymbol), which are treated as infix operators by the grammar.
Constructor names of sum types are identifiers prefixed with #, with no space afterwards. Record fields are named with fieldid - note that a fieldid can be a decimal number.
Wyn has three distinct namespaces:
- Terms: Variables, functions, and modules
- Module types: Module type definitions
- Types: Type names and type constructors
Modules (including parametric modules) and values both share the term namespace.
Reserved Names
A reserved name or symbol may be used only when explicitly present in the grammar. In particular, they cannot be bound in definitions.
Reserved identifiers:
true, false, if, then, else, def, let, loop, in, val, for, do, with, local,
open, include, import, type, module, while, assert, match, case
Reserved symbols:
=