Class CanonicalTextForOf
java.lang.Object
org.ek9lang.compiler.support.literals.CanonicalTextForOf
- All Implemented Interfaces:
BiFunction<String,String, String>, BinaryOperator<String>
🔑 THE canonical text for reconstructing a literal through an
org.ek9.lang _of(String) factory -
the single place that turns a literal's raw source lexeme into text _of(String) can actually read. Any
back end or evaluator that reconstructs a literal by calling _of(String) must go through it.
_of(String) is the RUNTIME string parser for a type; it understands that type's canonical external form
and nothing else, and it is radix-blind. The EK9 GRAMMAR admits richer forms than that - 0xFF,
0777, 1_000_000, 1_000.5 - so the raw source lexeme must be normalised first or the value
is silently wrong:
Integer._of("0xFF")-> UNSET (not 255)Integer._of("0777")-> 777 (not 511) - set, and WRONG, which is worseInteger._of("1_000_000")-> UNSETFloat._of("1_000.5")-> UNSETBits._of("0b1111_0000")-> UNSET
Every other literal type takes its raw source text unchanged, because for those the lexeme already IS the
canonical form (2024-01-15, PT2H, #FF0000, 12.50#USD). Character arrives with its
quotes ALREADY STRIPPED.
The arguments are the fully-qualified EK9 type name (org.ek9.lang::Integer) and the raw literal text as
it appeared in source; the result is text that _of(String) reads back as the intended value.
-
Constructor Details
-
CanonicalTextForOf
public CanonicalTextForOf()
-
-
Method Details
-
apply
-