From dab6f494b187c86afdfd23b2829158fdde70e633 Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Mon, 6 Sep 2021 13:08:31 -0700 Subject: [PATCH] [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. --- grammar/abnf-grammar.txt | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/grammar/abnf-grammar.txt b/grammar/abnf-grammar.txt index 0ce05fc0bb..e13b9b1aac 100644 --- a/grammar/abnf-grammar.txt +++ b/grammar/abnf-grammar.txt @@ -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,