yamleam/scalar
Plain scalar resolution.
Converts the verbatim text of a plain (unquoted) scalar into a typed
YamlNode according to YAML 1.2 resolution rules. Quoted scalars are
always strings and bypass this layer entirely.
Resolution priority (first match wins):
- Empty / “null” / “Null” / “NULL” / “~” → YamlNull
- “true” / “True” / “TRUE” → YamlBool(True)
- “false” / “False” / “FALSE” → YamlBool(False)
- Decimal integer (optional sign) → YamlInt
- Decimal float (optional sign, exponent) → YamlFloat
- Otherwise → YamlString
classify sorts the text into these kinds and keeps a number’s text
(ExactNumber); resolve_number turns that text into YamlInt or
YamlFloat. resolve is the two together.
Following YAML 1.2, the YAML 1.1 boolean variants (“yes”, “no”, “on”, “off”) and leading-zero octals (“0777”) resolve as strings. Hex and octal integers (“0x1F”, “0o17”) and the special floats (“.inf”, “.nan”) currently resolve as strings too.
Values
pub fn classify(text: String) -> node.ExactNode
Sort a plain scalar into null, bool, number or string. A number keeps
its text: it is an ExactNumber exactly when resolve would make it a
YamlInt or a YamlFloat.
pub fn resolve(text: String) -> node.YamlNode
pub fn resolve_number(text: String) -> node.YamlNode
The YamlInt or YamlFloat for a number’s text, which classify
accepted as an ExactNumber. Any other text is a YamlString.