mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-21 08:31:33 +03:00
mirate grammar from staging
This commit is contained in:
parent
5d3d93efbc
commit
6cd6082100
@ -15,11 +15,11 @@ keywords = [
|
|||||||
categories = [ "cryptography::cryptocurrencies", "web-programming" ]
|
categories = [ "cryptography::cryptocurrencies", "web-programming" ]
|
||||||
include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ]
|
include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ]
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
rust-version = "1.56"
|
||||||
[dependencies.abnf]
|
|
||||||
version = "0.12.0"
|
|
||||||
|
|
||||||
[dependencies.anyhow]
|
[dependencies.anyhow]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
|
[dependencies.abnf]
|
||||||
|
version = "0.12.0"
|
||||||
|
Binary file not shown.
@ -1,4 +1,4 @@
|
|||||||
Copyright (C) 2019-2021 Aleo Systems Inc.
|
Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||||
This file is part of the Leo library.
|
This file is part of the Leo library.
|
||||||
|
|
||||||
The Leo library is free software: you can redistribute it and/or modify
|
The Leo library is free software: you can redistribute it and/or modify
|
||||||
@ -369,7 +369,7 @@ could be equally parsed as two `*` symbol tokens or one `**` symbol token
|
|||||||
As another example, the sequence or characters `<CR><LF>`
|
As another example, the sequence or characters `<CR><LF>`
|
||||||
(i.e. carriage return followed by line feed)
|
(i.e. carriage return followed by line feed)
|
||||||
could be equally parsed as two line terminators or one
|
could be equally parsed as two line terminators or one
|
||||||
(see rule for `newline`).
|
(see rule for `line-terminator`).
|
||||||
|
|
||||||
Thus, as often done in language syntax definitions,
|
Thus, as often done in language syntax definitions,
|
||||||
the lexical grammar is disambiguated by
|
the lexical grammar is disambiguated by
|
||||||
@ -431,8 +431,7 @@ not-star = %x0-29 / %x2B-10FFFF ; anything but *
|
|||||||
|
|
||||||
<a name="not-star-or-slash"></a>
|
<a name="not-star-or-slash"></a>
|
||||||
```abnf
|
```abnf
|
||||||
not-star-or-slash = %x0-29 / %x2B-2E / %x30-10FFFF
|
not-star-or-slash = %x0-29 / %x2B-2E / %x30-10FFFF ; anything but * or /
|
||||||
; anything but * or /
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<a name="not-line-feed-or-carriage-return"></a>
|
<a name="not-line-feed-or-carriage-return"></a>
|
||||||
@ -461,9 +460,9 @@ Note that the latter combination constitutes a single line terminator,
|
|||||||
according to the extra-grammatical requirement of the longest sequence,
|
according to the extra-grammatical requirement of the longest sequence,
|
||||||
described above.
|
described above.
|
||||||
|
|
||||||
<a name="newline"></a>
|
<a name="line-terminator"></a>
|
||||||
```abnf
|
```abnf
|
||||||
newline = line-feed / carriage-return / carriage-return line-feed
|
line-terminator = line-feed / carriage-return / carriage-return line-feed
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to: _[carriage-return](#user-content-carriage-return), [line-feed](#user-content-line-feed)_;
|
Go to: _[carriage-return](#user-content-carriage-return), [line-feed](#user-content-line-feed)_;
|
||||||
@ -473,10 +472,10 @@ Line terminators form whitespace, along with spaces and horizontal tabs.
|
|||||||
|
|
||||||
<a name="whitespace"></a>
|
<a name="whitespace"></a>
|
||||||
```abnf
|
```abnf
|
||||||
whitespace = space / horizontal-tab / newline
|
whitespace = space / horizontal-tab / line-terminator
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to: _[horizontal-tab](#user-content-horizontal-tab), [newline](#user-content-newline), [space](#user-content-space)_;
|
Go to: _[horizontal-tab](#user-content-horizontal-tab), [line-terminator](#user-content-line-terminator), [space](#user-content-space)_;
|
||||||
|
|
||||||
|
|
||||||
There are two kinds of comments in Leo, as in other languages.
|
There are two kinds of comments in Leo, as in other languages.
|
||||||
@ -526,12 +525,9 @@ Go to: _[not-star-or-slash](#user-content-not-star-or-slash), [rest-of-block-com
|
|||||||
|
|
||||||
<a name="end-of-line-comment"></a>
|
<a name="end-of-line-comment"></a>
|
||||||
```abnf
|
```abnf
|
||||||
end-of-line-comment = "//" *not-line-feed-or-carriage-return newline
|
end-of-line-comment = "//" *not-line-feed-or-carriage-return
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to: _[newline](#user-content-newline)_;
|
|
||||||
|
|
||||||
|
|
||||||
Below are the keywords in the Leo language.
|
Below are the keywords in the Leo language.
|
||||||
They cannot be used as identifiers.
|
They cannot be used as identifiers.
|
||||||
|
|
||||||
@ -559,7 +555,6 @@ keyword = %s"address"
|
|||||||
/ %s"in"
|
/ %s"in"
|
||||||
/ %s"input"
|
/ %s"input"
|
||||||
/ %s"let"
|
/ %s"let"
|
||||||
/ %s"mut"
|
|
||||||
/ %s"return"
|
/ %s"return"
|
||||||
/ %s"Self"
|
/ %s"Self"
|
||||||
/ %s"self"
|
/ %s"self"
|
||||||
@ -902,7 +897,7 @@ particularly since it starts with a proper symbol.
|
|||||||
|
|
||||||
<a name="symbol"></a>
|
<a name="symbol"></a>
|
||||||
```abnf
|
```abnf
|
||||||
symbol = "!" / "&&" / "||"
|
symbol = "!" / "&" / "&&" / "||"
|
||||||
/ "==" / "!="
|
/ "==" / "!="
|
||||||
/ "<" / "<=" / ">" / ">="
|
/ "<" / "<=" / ">" / ">="
|
||||||
/ "+" / "-" / "*" / "/" / "**"
|
/ "+" / "-" / "*" / "/" / "**"
|
||||||
@ -1060,7 +1055,7 @@ Go to: _[natural](#user-content-natural)_;
|
|||||||
```abnf
|
```abnf
|
||||||
array-type-dimensions = array-type-dimension
|
array-type-dimensions = array-type-dimension
|
||||||
/ "(" array-type-dimension
|
/ "(" array-type-dimension
|
||||||
*( "," array-type-dimension ) ")"
|
*( "," array-type-dimension ) [","] ")"
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to: _[array-type-dimension](#user-content-array-type-dimension)_;
|
Go to: _[array-type-dimension](#user-content-array-type-dimension)_;
|
||||||
@ -1103,6 +1098,17 @@ identifier-or-self-type = identifier / self-type
|
|||||||
Go to: _[identifier](#user-content-identifier), [self-type](#user-content-self-type)_;
|
Go to: _[identifier](#user-content-identifier), [self-type](#user-content-self-type)_;
|
||||||
|
|
||||||
|
|
||||||
|
A named type is an identifier, the `Self` type, or a scalar type.
|
||||||
|
These are types that are named by identifiers or keywords.
|
||||||
|
|
||||||
|
<a name="named-type"></a>
|
||||||
|
```abnf
|
||||||
|
named-type = identifier / self-type / scalar-type
|
||||||
|
```
|
||||||
|
|
||||||
|
Go to: _[identifier](#user-content-identifier), [scalar-type](#user-content-scalar-type), [self-type](#user-content-self-type)_;
|
||||||
|
|
||||||
|
|
||||||
The lexical grammar given earlier defines product group literals.
|
The lexical grammar given earlier defines product group literals.
|
||||||
The other kind of group literal is a pair of integer coordinates,
|
The other kind of group literal is a pair of integer coordinates,
|
||||||
which are reduced modulo the prime to identify a point,
|
which are reduced modulo the prime to identify a point,
|
||||||
@ -1315,6 +1321,10 @@ instance (i.e. non-static) member function calls, and
|
|||||||
static member function calls.
|
static member function calls.
|
||||||
What changes is the start, but they all end in an argument list.
|
What changes is the start, but they all end in an argument list.
|
||||||
|
|
||||||
|
Accesses to static constants are also postfix expressions.
|
||||||
|
They consist of a named type followed by the constant name,
|
||||||
|
as static constants are associated to named types.
|
||||||
|
|
||||||
<a name="function-arguments"></a>
|
<a name="function-arguments"></a>
|
||||||
```abnf
|
```abnf
|
||||||
function-arguments = "(" [ expression *( "," expression ) ] ")"
|
function-arguments = "(" [ expression *( "," expression ) ] ")"
|
||||||
@ -1330,12 +1340,13 @@ postfix-expression = primary-expression
|
|||||||
/ postfix-expression "." identifier
|
/ postfix-expression "." identifier
|
||||||
/ identifier function-arguments
|
/ identifier function-arguments
|
||||||
/ postfix-expression "." identifier function-arguments
|
/ postfix-expression "." identifier function-arguments
|
||||||
/ identifier-or-self-type "::" identifier function-arguments
|
/ named-type "::" identifier function-arguments
|
||||||
|
/ named-type "::" identifier
|
||||||
/ postfix-expression "[" expression "]"
|
/ postfix-expression "[" expression "]"
|
||||||
/ postfix-expression "[" [expression] ".." [expression] "]"
|
/ postfix-expression "[" [expression] ".." [expression] "]"
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to: _[expression](#user-content-expression), [function-arguments](#user-content-function-arguments), [identifier-or-self-type](#user-content-identifier-or-self-type), [identifier](#user-content-identifier), [natural](#user-content-natural), [postfix-expression](#user-content-postfix-expression), [primary-expression](#user-content-primary-expression)_;
|
Go to: _[expression](#user-content-expression), [function-arguments](#user-content-function-arguments), [identifier](#user-content-identifier), [named-type](#user-content-named-type), [natural](#user-content-natural), [postfix-expression](#user-content-postfix-expression), [primary-expression](#user-content-primary-expression)_;
|
||||||
|
|
||||||
|
|
||||||
Unary operators have the highest operator precedence.
|
Unary operators have the highest operator precedence.
|
||||||
@ -1659,12 +1670,11 @@ Go to: _[print-arguments](#user-content-print-arguments), [print-function](#user
|
|||||||
|
|
||||||
An annotation consists of an annotation name (which starts with `@`)
|
An annotation consists of an annotation name (which starts with `@`)
|
||||||
with optional annotation arguments, which are identifiers.
|
with optional annotation arguments, which are identifiers.
|
||||||
Note that no parentheses are used if there are no arguments.
|
|
||||||
|
|
||||||
<a name="annotation"></a>
|
<a name="annotation"></a>
|
||||||
```abnf
|
```abnf
|
||||||
annotation = annotation-name
|
annotation = annotation-name
|
||||||
[ "(" identifier *( "," identifier ) ")" ]
|
[ "(" *( identifier "," ) [ identifier ] ")" ]
|
||||||
```
|
```
|
||||||
|
|
||||||
Go to: _[annotation-name](#user-content-annotation-name), [identifier](#user-content-identifier)_;
|
Go to: _[annotation-name](#user-content-annotation-name), [identifier](#user-content-identifier)_;
|
||||||
@ -1675,11 +1685,11 @@ The output type is optional, defaulting to the empty tuple type.
|
|||||||
In general, a function input consists of an identifier and a type,
|
In general, a function input consists of an identifier and a type,
|
||||||
with an optional 'const' modifier.
|
with an optional 'const' modifier.
|
||||||
Additionally, functions inside circuits
|
Additionally, functions inside circuits
|
||||||
may start with a `mut self` or `const self` or `self` parameter.
|
may start with a `&self` or `const self` or `self` parameter.
|
||||||
|
|
||||||
<a name="function-declaration"></a>
|
<a name="function-declaration"></a>
|
||||||
```abnf
|
```abnf
|
||||||
function-declaration = *annotation %s"function" identifier
|
function-declaration = *annotation [ %s"const" ] %s"function" identifier
|
||||||
"(" [ function-parameters ] ")" [ "->" type ]
|
"(" [ function-parameters ] ")" [ "->" type ]
|
||||||
block
|
block
|
||||||
```
|
```
|
||||||
@ -1699,7 +1709,7 @@ Go to: _[function-inputs](#user-content-function-inputs), [self-parameter](#user
|
|||||||
|
|
||||||
<a name="self-parameter"></a>
|
<a name="self-parameter"></a>
|
||||||
```abnf
|
```abnf
|
||||||
self-parameter = [ %s"mut" / %s"const" ] %s"self"
|
self-parameter = [ %s"&" / %s"const" ] %s"self"
|
||||||
```
|
```
|
||||||
|
|
||||||
<a name="function-inputs"></a>
|
<a name="function-inputs"></a>
|
||||||
@ -1718,6 +1728,20 @@ function-input = [ %s"const" ] identifier ":" type
|
|||||||
Go to: _[identifier](#user-content-identifier), [type](#user-content-type)_;
|
Go to: _[identifier](#user-content-identifier), [type](#user-content-type)_;
|
||||||
|
|
||||||
|
|
||||||
|
A circuit member constant declaration consists of
|
||||||
|
the `static` and `const` keywords followed by
|
||||||
|
an identifier and a type, then an initializer
|
||||||
|
with a literal terminated by semicolon.
|
||||||
|
|
||||||
|
<a name="member-constant-declaration"></a>
|
||||||
|
```abnf
|
||||||
|
member-constant-declaration = %s"static" %s"const" identifier ":" type
|
||||||
|
"=" literal ";"
|
||||||
|
```
|
||||||
|
|
||||||
|
Go to: _[identifier](#user-content-identifier), [literal](#user-content-literal), [type](#user-content-type)_;
|
||||||
|
|
||||||
|
|
||||||
A circuit member variable declaration consists of
|
A circuit member variable declaration consists of
|
||||||
an identifier and a type, terminated by semicolon.
|
an identifier and a type, terminated by semicolon.
|
||||||
For backward compatibility,
|
For backward compatibility,
|
||||||
@ -1749,7 +1773,9 @@ Go to: _[function-declaration](#user-content-function-declaration)_;
|
|||||||
|
|
||||||
|
|
||||||
A circuit declaration defines a circuit type,
|
A circuit declaration defines a circuit type,
|
||||||
as consisting of member variables and functions.
|
as consisting of member constants, variables and functions.
|
||||||
|
A circuit member constant declaration
|
||||||
|
as consisting of member constants, member variables, and member functions.
|
||||||
To more simply accommodate the backward compatibility
|
To more simply accommodate the backward compatibility
|
||||||
described for the rule `member-variable-declarations`,
|
described for the rule `member-variable-declarations`,
|
||||||
all the member variables must precede all the member functions;
|
all the member variables must precede all the member functions;
|
||||||
@ -1759,7 +1785,8 @@ allowing member variables and member functions to be intermixed.
|
|||||||
<a name="circuit-declaration"></a>
|
<a name="circuit-declaration"></a>
|
||||||
```abnf
|
```abnf
|
||||||
circuit-declaration = %s"circuit" identifier
|
circuit-declaration = %s"circuit" identifier
|
||||||
"{" [ member-variable-declarations ]
|
"{" *member-constant-declaration
|
||||||
|
[ member-variable-declarations ]
|
||||||
*member-function-declaration "}"
|
*member-function-declaration "}"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
; Copyright (C) 2019-2021 Aleo Systems Inc.
|
; Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||||
; This file is part of the Leo library.
|
; This file is part of the Leo library.
|
||||||
|
|
||||||
; The Leo library is free software: you can redistribute it and/or modify
|
; The Leo library is free software: you can redistribute it and/or modify
|
||||||
@ -299,7 +299,7 @@
|
|||||||
; As another example, the sequence or characters `<CR><LF>`
|
; As another example, the sequence or characters `<CR><LF>`
|
||||||
; (i.e. carriage return followed by line feed)
|
; (i.e. carriage return followed by line feed)
|
||||||
; could be equally parsed as two line terminators or one
|
; could be equally parsed as two line terminators or one
|
||||||
; (see rule for `newline`).
|
; (see rule for `line-terminator`).
|
||||||
|
|
||||||
; Thus, as often done in language syntax definitions,
|
; Thus, as often done in language syntax definitions,
|
||||||
; the lexical grammar is disambiguated by
|
; the lexical grammar is disambiguated by
|
||||||
@ -335,8 +335,7 @@ single-quote = %x27 ; '
|
|||||||
|
|
||||||
not-star = %x0-29 / %x2B-10FFFF ; anything but *
|
not-star = %x0-29 / %x2B-10FFFF ; anything but *
|
||||||
|
|
||||||
not-star-or-slash = %x0-29 / %x2B-2E / %x30-10FFFF
|
not-star-or-slash = %x0-29 / %x2B-2E / %x30-10FFFF ; anything but * or /
|
||||||
; anything but * or /
|
|
||||||
|
|
||||||
not-line-feed-or-carriage-return = %x0-9 / %xB-C / %xE-10FFFF
|
not-line-feed-or-carriage-return = %x0-9 / %xB-C / %xE-10FFFF
|
||||||
; anything but <LF> or <CR>
|
; anything but <LF> or <CR>
|
||||||
@ -355,11 +354,11 @@ not-single-quote-or-backslash = %x0-26 / %x28-5B / %x5D-10FFFF
|
|||||||
; according to the extra-grammatical requirement of the longest sequence,
|
; according to the extra-grammatical requirement of the longest sequence,
|
||||||
; described above.
|
; described above.
|
||||||
|
|
||||||
newline = line-feed / carriage-return / carriage-return line-feed
|
line-terminator = line-feed / carriage-return / carriage-return line-feed
|
||||||
|
|
||||||
; Line terminators form whitespace, along with spaces and horizontal tabs.
|
; Line terminators form whitespace, along with spaces and horizontal tabs.
|
||||||
|
|
||||||
whitespace = space / horizontal-tab / newline
|
whitespace = space / horizontal-tab / line-terminator
|
||||||
|
|
||||||
; There are two kinds of comments in Leo, as in other languages.
|
; There are two kinds of comments in Leo, as in other languages.
|
||||||
; One is block comments of the form `/* ... */`,
|
; One is block comments of the form `/* ... */`,
|
||||||
@ -382,7 +381,7 @@ rest-of-block-comment-after-star = "/"
|
|||||||
/ "*" rest-of-block-comment-after-star
|
/ "*" rest-of-block-comment-after-star
|
||||||
/ not-star-or-slash rest-of-block-comment
|
/ not-star-or-slash rest-of-block-comment
|
||||||
|
|
||||||
end-of-line-comment = "//" *not-line-feed-or-carriage-return newline
|
end-of-line-comment = "//" *not-line-feed-or-carriage-return
|
||||||
|
|
||||||
; Below are the keywords in the Leo language.
|
; Below are the keywords in the Leo language.
|
||||||
; They cannot be used as identifiers.
|
; They cannot be used as identifiers.
|
||||||
@ -409,7 +408,6 @@ keyword = %s"address"
|
|||||||
/ %s"in"
|
/ %s"in"
|
||||||
/ %s"input"
|
/ %s"input"
|
||||||
/ %s"let"
|
/ %s"let"
|
||||||
/ %s"mut"
|
|
||||||
/ %s"return"
|
/ %s"return"
|
||||||
/ %s"Self"
|
/ %s"Self"
|
||||||
/ %s"self"
|
/ %s"self"
|
||||||
@ -590,7 +588,7 @@ atomic-literal = untyped-literal
|
|||||||
; it seems appropriate to still consider it a symbol,
|
; it seems appropriate to still consider it a symbol,
|
||||||
; particularly since it starts with a proper symbol.
|
; particularly since it starts with a proper symbol.
|
||||||
|
|
||||||
symbol = "!" / "&&" / "||"
|
symbol = "!" / "&" / "&&" / "||"
|
||||||
/ "==" / "!="
|
/ "==" / "!="
|
||||||
/ "<" / "<=" / ">" / ">="
|
/ "<" / "<=" / ">" / ">="
|
||||||
/ "+" / "-" / "*" / "/" / "**"
|
/ "+" / "-" / "*" / "/" / "**"
|
||||||
@ -674,7 +672,7 @@ array-type-dimension = natural / "_"
|
|||||||
|
|
||||||
array-type-dimensions = array-type-dimension
|
array-type-dimensions = array-type-dimension
|
||||||
/ "(" array-type-dimension
|
/ "(" array-type-dimension
|
||||||
*( "," array-type-dimension ) ")"
|
*( "," array-type-dimension ) [","] ")"
|
||||||
|
|
||||||
; The keyword `Self` denotes the enclosing circuit type.
|
; The keyword `Self` denotes the enclosing circuit type.
|
||||||
; It is only allowed inside a circuit type declaration.
|
; It is only allowed inside a circuit type declaration.
|
||||||
@ -698,6 +696,11 @@ type = scalar-type / tuple-type / array-type / identifier / self-type
|
|||||||
|
|
||||||
identifier-or-self-type = identifier / self-type
|
identifier-or-self-type = identifier / self-type
|
||||||
|
|
||||||
|
; A named type is an identifier, the `Self` type, or a scalar type.
|
||||||
|
; These are types that are named by identifiers or keywords.
|
||||||
|
|
||||||
|
named-type = identifier / self-type / scalar-type
|
||||||
|
|
||||||
; The lexical grammar given earlier defines product group literals.
|
; The lexical grammar given earlier defines product group literals.
|
||||||
; The other kind of group literal is a pair of integer coordinates,
|
; The other kind of group literal is a pair of integer coordinates,
|
||||||
; which are reduced modulo the prime to identify a point,
|
; which are reduced modulo the prime to identify a point,
|
||||||
@ -814,6 +817,10 @@ circuit-expression = circuit-construction
|
|||||||
; static member function calls.
|
; static member function calls.
|
||||||
; What changes is the start, but they all end in an argument list.
|
; What changes is the start, but they all end in an argument list.
|
||||||
|
|
||||||
|
; Accesses to static constants are also postfix expressions.
|
||||||
|
; They consist of a named type followed by the constant name,
|
||||||
|
; as static constants are associated to named types.
|
||||||
|
|
||||||
function-arguments = "(" [ expression *( "," expression ) ] ")"
|
function-arguments = "(" [ expression *( "," expression ) ] ")"
|
||||||
|
|
||||||
postfix-expression = primary-expression
|
postfix-expression = primary-expression
|
||||||
@ -821,7 +828,8 @@ postfix-expression = primary-expression
|
|||||||
/ postfix-expression "." identifier
|
/ postfix-expression "." identifier
|
||||||
/ identifier function-arguments
|
/ identifier function-arguments
|
||||||
/ postfix-expression "." identifier function-arguments
|
/ postfix-expression "." identifier function-arguments
|
||||||
/ identifier-or-self-type "::" identifier function-arguments
|
/ named-type "::" identifier function-arguments
|
||||||
|
/ named-type "::" identifier
|
||||||
/ postfix-expression "[" expression "]"
|
/ postfix-expression "[" expression "]"
|
||||||
/ postfix-expression "[" [expression] ".." [expression] "]"
|
/ postfix-expression "[" [expression] ".." [expression] "]"
|
||||||
|
|
||||||
@ -987,19 +995,18 @@ print-call = print-function print-arguments
|
|||||||
|
|
||||||
; An annotation consists of an annotation name (which starts with `@`)
|
; An annotation consists of an annotation name (which starts with `@`)
|
||||||
; with optional annotation arguments, which are identifiers.
|
; with optional annotation arguments, which are identifiers.
|
||||||
; Note that no parentheses are used if there are no arguments.
|
|
||||||
|
|
||||||
annotation = annotation-name
|
annotation = annotation-name
|
||||||
[ "(" identifier *( "," identifier ) ")" ]
|
[ "(" *( identifier "," ) [ identifier ] ")" ]
|
||||||
|
|
||||||
; A function declaration defines a function.
|
; A function declaration defines a function.
|
||||||
; The output type is optional, defaulting to the empty tuple type.
|
; The output type is optional, defaulting to the empty tuple type.
|
||||||
; In general, a function input consists of an identifier and a type,
|
; In general, a function input consists of an identifier and a type,
|
||||||
; with an optional 'const' modifier.
|
; with an optional 'const' modifier.
|
||||||
; Additionally, functions inside circuits
|
; Additionally, functions inside circuits
|
||||||
; may start with a `mut self` or `const self` or `self` parameter.
|
; may start with a `&self` or `const self` or `self` parameter.
|
||||||
|
|
||||||
function-declaration = *annotation %s"function" identifier
|
function-declaration = *annotation [ %s"const" ] %s"function" identifier
|
||||||
"(" [ function-parameters ] ")" [ "->" type ]
|
"(" [ function-parameters ] ")" [ "->" type ]
|
||||||
block
|
block
|
||||||
|
|
||||||
@ -1007,12 +1014,20 @@ function-parameters = self-parameter
|
|||||||
/ self-parameter "," function-inputs
|
/ self-parameter "," function-inputs
|
||||||
/ function-inputs
|
/ function-inputs
|
||||||
|
|
||||||
self-parameter = [ %s"mut" / %s"const" ] %s"self"
|
self-parameter = [ %s"&" / %s"const" ] %s"self"
|
||||||
|
|
||||||
function-inputs = function-input *( "," function-input )
|
function-inputs = function-input *( "," function-input )
|
||||||
|
|
||||||
function-input = [ %s"const" ] identifier ":" type
|
function-input = [ %s"const" ] identifier ":" type
|
||||||
|
|
||||||
|
; A circuit member constant declaration consists of
|
||||||
|
; the `static` and `const` keywords followed by
|
||||||
|
; an identifier and a type, then an initializer
|
||||||
|
; with a literal terminated by semicolon.
|
||||||
|
|
||||||
|
member-constant-declaration = %s"static" %s"const" identifier ":" type
|
||||||
|
"=" literal ";"
|
||||||
|
|
||||||
; A circuit member variable declaration consists of
|
; A circuit member variable declaration consists of
|
||||||
; an identifier and a type, terminated by semicolon.
|
; an identifier and a type, terminated by semicolon.
|
||||||
; For backward compatibility,
|
; For backward compatibility,
|
||||||
@ -1032,7 +1047,9 @@ member-variable-declarations = *( identifier ":" type ( "," / ";" ) )
|
|||||||
member-function-declaration = function-declaration
|
member-function-declaration = function-declaration
|
||||||
|
|
||||||
; A circuit declaration defines a circuit type,
|
; A circuit declaration defines a circuit type,
|
||||||
; as consisting of member variables and functions.
|
; as consisting of member constants, variables and functions.
|
||||||
|
; A circuit member constant declaration
|
||||||
|
; as consisting of member constants, member variables, and member functions.
|
||||||
; To more simply accommodate the backward compatibility
|
; To more simply accommodate the backward compatibility
|
||||||
; described for the rule `member-variable-declarations`,
|
; described for the rule `member-variable-declarations`,
|
||||||
; all the member variables must precede all the member functions;
|
; all the member variables must precede all the member functions;
|
||||||
@ -1040,7 +1057,8 @@ member-function-declaration = function-declaration
|
|||||||
; allowing member variables and member functions to be intermixed.
|
; allowing member variables and member functions to be intermixed.
|
||||||
|
|
||||||
circuit-declaration = %s"circuit" identifier
|
circuit-declaration = %s"circuit" identifier
|
||||||
"{" [ member-variable-declarations ]
|
"{" *member-constant-declaration
|
||||||
|
[ member-variable-declarations ]
|
||||||
*member-function-declaration "}"
|
*member-function-declaration "}"
|
||||||
|
|
||||||
; An import declaration consists of the `import` keyword
|
; An import declaration consists of the `import` keyword
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
; Copyright (C) 2019-2021 Aleo Systems Inc.
|
; Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||||
; This file is part of the Leo library.
|
; This file is part of the Leo library.
|
||||||
|
|
||||||
; The Leo library is free software: you can redistribute it and/or modify
|
; The Leo library is free software: you can redistribute it and/or modify
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2019-2021 Aleo Systems Inc.
|
// Copyright (C) 2019-2022 Aleo Systems Inc.
|
||||||
// This file is part of the Leo library.
|
// This file is part of the Leo library.
|
||||||
|
|
||||||
// The Leo library is free software: you can redistribute it and/or modify
|
// The Leo library is free software: you can redistribute it and/or modify
|
||||||
|
Loading…
Reference in New Issue
Block a user