Names in FEEL.
A FEEL name is a sequence of tokens, not a string: it may contain spaces and
the characters . / - ' + * (and the typographic apostrophe), so Phone Number
and Phone Number are the same name, and so are a-b and a - b. White space
is not part of a name's token list, so the identity of a name is its token
list (DMN 1.6, sections 10.3.1.4 and 10.3.1.6).
A name is represented as a string in its canonical form: the tokens joined with a single space only between two adjacent word tokens, and no space around the symbols. Context keys, scope entries, and binding keys all use canonical names, and the library canonicalizes the names it is given at its boundaries. This is the reading recommended for the specification's silence on how names become keys.
The canonical form is computed from the two small character sets that matter
here, white space and the additional name symbols, so it does not depend on
the lexer. It assumes it is given a name; it does not check that the text is
one. A text that may be no name, such as a string used as a context key, is
first asked of Feel.Syntax.Lexer.name_tokens/1 (D-213).
Summary
Functions
Whether a text is no name at all, which is the text that canonical/1 raises for: it has no character that is not white space.
Returns the canonical form of a name.
Returns the canonical name for the texts of a name's tokens, as the lexer split them.
Returns true when two names are the same token list.
Types
@type t() :: String.t()
A name in canonical form.
Functions
Whether a text is no name at all, which is the text that canonical/1 raises for: it has no character that is not white space.
iex> {Feel.Name.blank?(""), Feel.Name.blank?(" "), Feel.Name.blank?("a")}
{true, true, false}
Returns the canonical form of a name.
Names that are the same token list have the same canonical form. Raises
ArgumentError when the name has no characters other than white space.
iex> Feel.Name.canonical(" Phone Number ")
"Phone Number"
iex> Feel.Name.canonical("a - b")
"a-b"
iex> Feel.Name.canonical("Profit and loss")
"Profit and loss"
Returns the canonical name for the texts of a name's tokens, as the lexer split them.
Words are never adjacent without white space between them, so the only question
is whether a space was there, and canonically there is one between two words and
none next to a symbol. This gives the same result as canonical/1 on the source
text.
iex> Feel.Name.join(["date", "and", "time"])
"date and time"
iex> Feel.Name.join(["a", "-", "b"])
"a-b"
Returns true when two names are the same token list.
iex> Feel.Name.same?("a-b", "a - b")
true
iex> Feel.Name.same?("first name", "first-name")
false