[ABNF] Improve formulation of rule for types.

As discussed on GitHub, list identifiers separately from Self.

Also adapt and improve some of the documentation comments.
This commit is contained in:
Alessandro Coglio 2021-09-06 13:08:31 -07:00
parent b45a722d6b
commit dab6f494b1

View File

@ -673,21 +673,28 @@ array-type = "[" type ";" array-dimensions "]"
array-dimensions = natural
/ "(" natural *( "," natural ) ")"
; Circuit types are denoted by identifiers and the keyword `Self`;
; the latter is only allowed inside a circuit definition,
; to denote the circuit type being defined.
; The keyword `Self` denotes the enclosing circuit type.
; It is only allowed inside a circuit type declaration.
self-type = %s"Self"
; Circuit types are denoted by identifiers and by `Self`.
; Identifiers may also be type aliases;
; syntactically (i.e. without a semantic analysis),
; they cannot be distinguished from circuit types.
self-type = %s"Self"
; Scalar types, tuple types, array types,
; identifiers (which may be circuit types or type aliases),
; and the `Self` type
; form all the types.
type = scalar-type / tuple-type / array-type / identifier / self-type
; It is convenient to introduce a rule for types that are
; either identifiers or `Self`, as this is used in other rules.
identifier-or-self-type = identifier / self-type
; Scalar and the remaining types form all the types.
type = scalar-type / tuple-type / array-type / identifier-or-self-type
; The lexical grammar given earlier defines product group literals.
; The other kind of group literal is a pair of integer coordinates,
; which are reduced modulo the prime to identify a point,