From c30df925ef48d079aeab7df47e6ae6fc0a4dd3d6 Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Fri, 4 Mar 2022 19:42:42 -0800 Subject: [PATCH 1/2] [ABNF] Adapt ABNF to removal of unsized arrays. This "merges" the two previous slightly different notions of array type dimensions and array expression dimension(s) into one notion of array dimensions, in which the dimensions have to be natural numbers. (Previously, array type dimensions were allowed to be unspecified (via underscores), while array expression dimensions had to be specified.) --- docs/grammar/abnf-grammar.txt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/docs/grammar/abnf-grammar.txt b/docs/grammar/abnf-grammar.txt index 0e75b5ef3d..057c4cb5d9 100644 --- a/docs/grammar/abnf-grammar.txt +++ b/docs/grammar/abnf-grammar.txt @@ -650,15 +650,11 @@ tuple-type = "(" [ type 1*( "," type ) ] ")" ; and an indication of dimensions. ; There is either a single dimension, ; or a tuple of one or more dimensions. -; Each dimension is natural. +; Each dimension is a natural. -array-type = "[" type ";" array-type-dimensions "]" +array-type = "[" type ";" array-dimensions "]" -array-type-dimension = natural / "_" - -array-type-dimensions = array-type-dimension - / "(" array-type-dimension - *( "," array-type-dimension ) [","] ")" +array-dimensions = natural / "(" natural *( "," natural ) ")" ; The keyword `Self` denotes the enclosing circuit type. ; It is only allowed inside a circuit type declaration. @@ -756,10 +752,7 @@ array-inline-construction = "[" array-inline-element = expression / "..." expression -array-repeat-construction = "[" expression ";" array-expression-dimensions "]" - -array-expression-dimensions = natural - / "(" natural *( "," natural ) ")" +array-repeat-construction = "[" expression ";" array-dimensions "]" array-construction = array-inline-construction / array-repeat-construction From 6aca970b88da9f7f45ad7c38e400d62ae82f55f7 Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Fri, 4 Mar 2022 19:51:14 -0800 Subject: [PATCH 2/2] [ABNF] Re-generate markdown. (Forgot to do this in the previous commit.) --- docs/grammar/README.md | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/docs/grammar/README.md b/docs/grammar/README.md index 26032ade6b..063df6180e 100644 --- a/docs/grammar/README.md +++ b/docs/grammar/README.md @@ -1013,34 +1013,24 @@ An array type consists of an element type and an indication of dimensions. There is either a single dimension, or a tuple of one or more dimensions. -Each dimension is natural. +Each dimension is a natural. ```abnf -array-type = "[" type ";" array-type-dimensions "]" +array-type = "[" type ";" array-dimensions "]" ``` -Go to: _[array-type-dimensions](#user-content-array-type-dimensions), [type](#user-content-type)_; +Go to: _[array-dimensions](#user-content-array-dimensions), [type](#user-content-type)_; - + ```abnf -array-type-dimension = natural / "_" +array-dimensions = natural / "(" natural *( "," natural ) ")" ``` Go to: _[natural](#user-content-natural)_; - -```abnf -array-type-dimensions = array-type-dimension - / "(" array-type-dimension - *( "," array-type-dimension ) [","] ")" -``` - -Go to: _[array-type-dimension](#user-content-array-type-dimension)_; - - The keyword `Self` denotes the enclosing circuit type. It is only allowed inside a circuit type declaration. @@ -1214,19 +1204,10 @@ Go to: _[expression](#user-content-expression)_; ```abnf -array-repeat-construction = "[" expression ";" array-expression-dimensions "]" +array-repeat-construction = "[" expression ";" array-dimensions "]" ``` -Go to: _[array-expression-dimensions](#user-content-array-expression-dimensions), [expression](#user-content-expression)_; - - - -```abnf -array-expression-dimensions = natural - / "(" natural *( "," natural ) ")" -``` - -Go to: _[natural](#user-content-natural)_; +Go to: _[array-dimensions](#user-content-array-dimensions), [expression](#user-content-expression)_;