Skip to main content

ident

Function ident 

Source
pub(crate) fn ident(name: &str) -> Option<String>
Expand description

The DSL spelling of name as an identifier: the bare form when the tokenizer reads it back as a single non-keyword identifier, else the quoted form ('Unit Price') the grammar gained in plan Step 4a.

Bare is preferred whenever it works, so ordinary formulas keep printing as Price * Quantity rather than 'Price' * 'Quantity'.

None only for the empty name: '' is an explicit parse error (“empty quoted name: ‘’ names nothing”), so an unnamed measure/category is the one name this grammar genuinely cannot spell. Everything else — spaces, slashes, hyphens, parentheses, digits-first, non-ASCII, and the keywords (Over, AND) — is spellable quoted, which is what makes a CSV-derived measure like Unit Price editable instead of read-only.

A literal ' inside the name is escaped by doubling it (Bob''s Rate), matching parser’s tokenizer exactly. There is no other escape to get wrong: the quoted form takes every other character verbatim.