kdl icon indicating copy to clipboard operation
kdl copied to clipboard

Disallowing "r#" at the beginning of identifiers

Open zkat opened this issue 3 years ago • 2 comments

Discussed in https://github.com/kdl-org/kdl/discussions/200

Originally posted by garrisonhh September 23, 2021 As far as I can tell from the spec, r##### is a perfectly valid identifier. At the moment, given a sequence of characters representing a single kdl value or identifer, all types of values can be identified solely based upon their first two characters except for raw strings because of this particular case. For consistency, I'd also be in favor of disallowing # altogether from identifiers.

This is a tiny nitpick, but it makes sense to me from an implementer perspective!

zkat avatar Oct 06 '21 13:10 zkat

So I suggested this specifically, and like it better than disallowing # entirely from idents; I like KDL's generally quite wide-open ident grammar.

Having given it thought overnight, I think this can be understood as the same as the current prohibition of "looking like a number" that prevents you from starting an ident with 0 or +0, but allows signs and digits anywhere else in the ident. Similarly, idents would be prevented from "looking like a raw string".

This would also satisfy @garrisonhh's suggested invariant that all token types can be identified in their first two characters.

tabatkins avatar Oct 06 '21 17:10 tabatkins

(#241 fixes this; I name-dropped the discussion rather than this issue in the PR.)

tabatkins avatar Oct 17 '21 15:10 tabatkins

This has been fixed because raw strings now start with a plain #", without the re

zkat avatar Dec 13 '23 05:12 zkat