package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4361e1324b7754a4c08ab5b505df32061f3ce0cea60443fd0d3699e0fa796b32
sha512=fcc756d2f160ba90a9aa1131f2ab22ed7f45466ccd658c21cf9df6868a6aab0cee7f404719d698a379958802f9820398f2fe0685ecc4dda018ca4f653294e39b
doc/wax-lib.conversion/Wax_conversion/Namespace/index.html
Module Wax_conversion.NamespaceSource
A namespace manages a set of unique names, avoiding collisions with reserved keywords and previously allocated names.
The Wax bare-word keywords (the `Regular reserved set). Kept in sync with the lexer by the keyword-consistency test; reused for editor keyword completion so it does not drift.
Create a new namespace. kind determines the set of reserved words (default `Regular):
`Regular: Standard reserved keywords (e.g., "if", "loop").`Label: No reserved words (empty).`Type: Reserved keywords plus abstract heap types (e.g., "func", "any").
dup t returns a copy of the namespace t. Changes to the new namespace will not affect t.
add t name registers name in the namespace t. If name is already taken or reserved, a unique suffix is appended (e.g., "name_1", "name_2"). Returns the unique name that was actually registered.
type outcome = | Available(*
*)namewas free and registered as-is.| Renamed of {reserved : bool;previous : Wax_utils.Ast.location option;
}(*
*)namewas taken and a suffix was appended.reservedis true when the requested name is a reserved word, false when it collided with another registered name.previousis the location the colliding name was first claimed from, when one was recorded (alwaysNonefor a reserved word).
Like add, but also reports whether the name was renamed and, if so, whether the collision was with a reserved word and where the colliding name was previously claimed. loc records this name's source location, so a later collision with it can point back here.
is_reserved t name is true when name is one of the namespace's reserved words (a Wax keyword), independent of any names already added. Used to skip an inferred name (an export or import name) that is a keyword, since the suffixed rename it would force reads worse than a generated default.