package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=41b580846af8d41bdf6c3f005f62e38feda3e60fe2e9e4aa440db34ce515a153
sha512=4b3a181fcc7d743194a8647260870fb5190770066a197bcc48104c2b77fd40c643228b795c2bcd6b29a120820e969eb42a37a9bcec98b3f608d13f152d9f6579
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.