mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-29 13:14:05 +03:00
[ABNF] Improve rules for array expressions.
Extending array dimensions for types to allow underscore has the unintended effect of allowing that also for expressions. This is not necessarily an error, as the static semantics can rule out underscores from array expressions. However, it is a simple syntactic constraint that is best captured by the grammar. This commit differentiate array dimensions for types and array dimensions for expressions, using them in the appropriate places.
This commit is contained in:
parent
3b52459f85
commit
ba65b4f4d5
@ -669,12 +669,13 @@ tuple-type = "(" [ type 1*( "," type ) ] ")"
|
||||
; or a tuple of one or more dimensions.
|
||||
; Each dimension is either a natural or is unspecified.
|
||||
|
||||
array-type = "[" type ";" array-dimensions "]"
|
||||
array-type = "[" type ";" array-type-dimensions "]"
|
||||
|
||||
array-dimension = natural / "_"
|
||||
array-type-dimension = natural / "_"
|
||||
|
||||
array-dimensions = array-dimension
|
||||
/ "(" array-dimension *( "," array-dimension ) ")"
|
||||
array-type-dimensions = array-type-dimension
|
||||
/ "(" array-type-dimension
|
||||
*( "," array-type-dimension ) ")"
|
||||
|
||||
; The keyword `Self` denotes the enclosing circuit type.
|
||||
; It is only allowed inside a circuit type declaration.
|
||||
@ -767,7 +768,10 @@ array-inline-construction = "["
|
||||
|
||||
array-inline-element = expression / "..." expression
|
||||
|
||||
array-repeat-construction = "[" expression ";" array-dimensions "]"
|
||||
array-repeat-construction = "[" expression ";" array-expression-dimensions "]"
|
||||
|
||||
array-expression-dimensions = natural
|
||||
/ "(" natural *( "," natural ) ")"
|
||||
|
||||
array-construction = array-inline-construction / array-repeat-construction
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user