Expand description
Lexical helpers over Nix text, shared by the source and target observations.
No Nix parser is embedded: these scanners know comments, strings,
bracket depth, let … in, and attribute tokens, which is what a
presence judgement needs and no more. Where they cannot judge, the
callers report a manual pair rather than a guess.
Functions§
- attribute_
range - The byte range of the attribute
name’s value intext, asattribute_valueslices it. - attribute_
value - The value of the attribute
namewheretextbinds it, asname = <value>;or through a pathname.<rest> = <value>;: the text after the=up to the;that closes the binding. - binding_
value - The text of one binding’s value, up to the
;that closes it. - input_
declaration - The declaration of the flake input
inputinside a flake text. - is_
default_ package_ path - Whether
textbinds a default package path atindex. - is_
ident - Whether a byte can continue a Nix identifier.
- names_
attribute - Whether
textbinds the attributename: the name as a whole token, bare or quoted, followed by=. - scrub
- Nix text with block comments, line comments, and string contents blanked, so a word inside any of them never reads as syntax.
- without_
let_ bindings - The text with every
let … inbinding list blanked, so a local binding never reads as an attribute of the value the expression returns.