cue/ast: clarify what is a valid identifier
The spec first says:
Identifiers name entities such as fields and aliases. An identifier
is a sequence of one or more letters (which includes _ and $) and
digits, optionally preceded by # or _#. It may not be _ or $.
Which could lead one to believe that "_" is not a valid identifier.
However, it also says:
Top is represented by the underscore character _,
lexically an identifier.
Moreover, the parser uses an ast.Ident node for top, so our parser
and compiler seem to disagree with the first part of the spec,
working under the assumption that an underscore is a valid identifier.
We're not changing the implementation here, and not even the spec,
even if making "identifier" a separate node from "top" would make sense.
However, making the cue/ast docs less ambiguous is easy and useful.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ic610654ff4408f15647e3b2ea3601e562b1be9a4
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/556986
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>