Merge pull request #882 from AleoHQ/feature/abnf-mod-txt-gen-md

Feature/abnf mod txt gen md
This commit is contained in:
Collin Chin 2021-04-20 15:58:43 -07:00 committed by GitHub
commit daa23b7311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 65 deletions

View File

@ -1,18 +1,20 @@
// Copyright (C) 2019-2021 Aleo Systems Inc. Copyright (C) 2019-2021 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
// it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. (at your option) any later version.
The Leo library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
-------- --------
@ -451,7 +453,7 @@ described above.
newline = line-feed / carriage-return / carriage-return line-feed newline = line-feed / carriage-return / carriage-return line-feed
``` ```
Go to: _[line-feed](#user-content-line-feed), [carriage-return](#user-content-carriage-return)_; Go to: _[carriage-return](#user-content-carriage-return), [line-feed](#user-content-line-feed)_;
Line terminators form whitespace, along with spaces and horizontal tabs. Line terminators form whitespace, along with spaces and horizontal tabs.
@ -461,7 +463,7 @@ Line terminators form whitespace, along with spaces and horizontal tabs.
whitespace = space / horizontal-tab / newline whitespace = space / horizontal-tab / newline
``` ```
Go to: _[newline](#user-content-newline), [space](#user-content-space), [horizontal-tab](#user-content-horizontal-tab)_; Go to: _[space](#user-content-space), [horizontal-tab](#user-content-horizontal-tab), [newline](#user-content-newline)_;
There are two kinds of comments in Leo, as in other languages. There are two kinds of comments in Leo, as in other languages.
@ -479,7 +481,7 @@ the ones used in the Java language reference.
comment = block-comment / end-of-line-comment comment = block-comment / end-of-line-comment
``` ```
Go to: _[end-of-line-comment](#user-content-end-of-line-comment), [block-comment](#user-content-block-comment)_; Go to: _[block-comment](#user-content-block-comment), [end-of-line-comment](#user-content-end-of-line-comment)_;
<a name="block-comment"></a> <a name="block-comment"></a>
@ -496,7 +498,7 @@ rest-of-block-comment = "*" rest-of-block-comment-after-star
/ not-star rest-of-block-comment / not-star rest-of-block-comment
``` ```
Go to: _[not-star](#user-content-not-star), [rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star), [rest-of-block-comment](#user-content-rest-of-block-comment)_; Go to: _[rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star), [not-star](#user-content-not-star), [rest-of-block-comment](#user-content-rest-of-block-comment)_;
<a name="rest-of-block-comment-after-star"></a> <a name="rest-of-block-comment-after-star"></a>
@ -506,7 +508,7 @@ rest-of-block-comment-after-star = "/"
/ not-star-or-slash rest-of-block-comment / not-star-or-slash rest-of-block-comment
``` ```
Go to: _[rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star), [not-star-or-slash](#user-content-not-star-or-slash), [rest-of-block-comment](#user-content-rest-of-block-comment)_; Go to: _[rest-of-block-comment](#user-content-rest-of-block-comment), [not-star-or-slash](#user-content-not-star-or-slash), [rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star)_;
<a name="end-of-line-comment"></a> <a name="end-of-line-comment"></a>
@ -639,7 +641,7 @@ format-string-element = not-double-quote-or-open-brace
/ format-string-container / format-string-container
``` ```
Go to: _[not-double-quote-or-open-brace](#user-content-not-double-quote-or-open-brace), [format-string-container](#user-content-format-string-container), [not-double-quote-or-close-brace](#user-content-not-double-quote-or-close-brace)_; Go to: _[not-double-quote-or-open-brace](#user-content-not-double-quote-or-open-brace), [not-double-quote-or-close-brace](#user-content-not-double-quote-or-close-brace), [format-string-container](#user-content-format-string-container)_;
<a name="format-string"></a> <a name="format-string"></a>
@ -800,7 +802,7 @@ atomic-literal = untyped-literal
/ address-literal / address-literal
``` ```
Go to: _[product-group-literal](#user-content-product-group-literal), [untyped-literal](#user-content-untyped-literal), [signed-literal](#user-content-signed-literal), [field-literal](#user-content-field-literal), [boolean-literal](#user-content-boolean-literal), [address-literal](#user-content-address-literal), [unsigned-literal](#user-content-unsigned-literal)_; Go to: _[unsigned-literal](#user-content-unsigned-literal), [field-literal](#user-content-field-literal), [product-group-literal](#user-content-product-group-literal), [address-literal](#user-content-address-literal), [signed-literal](#user-content-signed-literal), [untyped-literal](#user-content-untyped-literal), [boolean-literal](#user-content-boolean-literal)_;
After defining the (mostly) alphanumeric tokens above, After defining the (mostly) alphanumeric tokens above,
@ -873,7 +875,7 @@ token = keyword
/ symbol / symbol
``` ```
Go to: _[package-name](#user-content-package-name), [annotation-name](#user-content-annotation-name), [atomic-literal](#user-content-atomic-literal), [format-string](#user-content-format-string), [keyword](#user-content-keyword), [symbol](#user-content-symbol), [identifier](#user-content-identifier)_; Go to: _[format-string](#user-content-format-string), [annotation-name](#user-content-annotation-name), [symbol](#user-content-symbol), [keyword](#user-content-keyword), [atomic-literal](#user-content-atomic-literal), [identifier](#user-content-identifier), [package-name](#user-content-package-name)_;
@ -909,7 +911,7 @@ signed-type = %s"i8" / %s"i16" / %s"i32" / %s"i64" / %s"i128"
integer-type = unsigned-type / signed-type integer-type = unsigned-type / signed-type
``` ```
Go to: _[unsigned-type](#user-content-unsigned-type), [signed-type](#user-content-signed-type)_; Go to: _[signed-type](#user-content-signed-type), [unsigned-type](#user-content-unsigned-type)_;
The integer types, along with the field and group types, The integer types, along with the field and group types,
@ -930,7 +932,7 @@ group-type = %s"group"
arithmetic-type = integer-type / field-type / group-type arithmetic-type = integer-type / field-type / group-type
``` ```
Go to: _[integer-type](#user-content-integer-type), [field-type](#user-content-field-type), [group-type](#user-content-group-type)_; Go to: _[group-type](#user-content-group-type), [field-type](#user-content-field-type), [integer-type](#user-content-integer-type)_;
The arithmetic types, along with the boolean and address types, The arithmetic types, along with the boolean and address types,
@ -951,7 +953,7 @@ address-type = %s"address"
scalar-type = boolean-type / arithmetic-type / address-type scalar-type = boolean-type / arithmetic-type / address-type
``` ```
Go to: _[address-type](#user-content-address-type), [boolean-type](#user-content-boolean-type), [arithmetic-type](#user-content-arithmetic-type)_; Go to: _[arithmetic-type](#user-content-arithmetic-type), [address-type](#user-content-address-type), [boolean-type](#user-content-boolean-type)_;
Circuit types are denoted by identifiers and the keyword 'Self'. Circuit types are denoted by identifiers and the keyword 'Self'.
@ -968,7 +970,7 @@ self-type = %s"Self"
circuit-type = identifier / self-type circuit-type = identifier / self-type
``` ```
Go to: _[self-type](#user-content-self-type), [identifier](#user-content-identifier)_; Go to: _[identifier](#user-content-identifier), [self-type](#user-content-self-type)_;
A tuple type consists of zero, two, or more component types. A tuple type consists of zero, two, or more component types.
@ -991,7 +993,7 @@ or a tuple of one or more dimensions.
array-type = "[" type ";" array-dimensions "]" array-type = "[" type ";" array-dimensions "]"
``` ```
Go to: _[array-dimensions](#user-content-array-dimensions), [type](#user-content-type)_; Go to: _[type](#user-content-type), [array-dimensions](#user-content-array-dimensions)_;
<a name="array-dimensions"></a> <a name="array-dimensions"></a>
@ -1100,7 +1102,7 @@ primary-expression = identifier
/ circuit-expression / circuit-expression
``` ```
Go to: _[identifier](#user-content-identifier), [literal](#user-content-literal), [array-expression](#user-content-array-expression), [expression](#user-content-expression), [tuple-expression](#user-content-tuple-expression), [circuit-expression](#user-content-circuit-expression)_; Go to: _[literal](#user-content-literal), [array-expression](#user-content-array-expression), [tuple-expression](#user-content-tuple-expression), [identifier](#user-content-identifier), [expression](#user-content-expression), [circuit-expression](#user-content-circuit-expression)_;
Tuple expressions construct tuples. Tuple expressions construct tuples.
@ -1153,7 +1155,7 @@ Go to: _[expression](#user-content-expression)_;
array-repeat-construction = "[" expression ";" array-dimensions "]" array-repeat-construction = "[" expression ";" array-dimensions "]"
``` ```
Go to: _[expression](#user-content-expression), [array-dimensions](#user-content-array-dimensions)_; Go to: _[array-dimensions](#user-content-array-dimensions), [expression](#user-content-expression)_;
<a name="array-construction"></a> <a name="array-construction"></a>
@ -1161,7 +1163,7 @@ Go to: _[expression](#user-content-expression), [array-dimensions](#user-content
array-construction = array-inline-construction / array-repeat-construction array-construction = array-inline-construction / array-repeat-construction
``` ```
Go to: _[array-repeat-construction](#user-content-array-repeat-construction), [array-inline-construction](#user-content-array-inline-construction)_; Go to: _[array-inline-construction](#user-content-array-inline-construction), [array-repeat-construction](#user-content-array-repeat-construction)_;
<a name="array-expression"></a> <a name="array-expression"></a>
@ -1247,7 +1249,7 @@ postfix-expression = primary-expression
/ postfix-expression "[" [expression] ".." [expression] "]" / postfix-expression "[" [expression] ".." [expression] "]"
``` ```
Go to: _[circuit-type](#user-content-circuit-type), [natural](#user-content-natural), [postfix-expression](#user-content-postfix-expression), [primary-expression](#user-content-primary-expression), [identifier](#user-content-identifier), [function-arguments](#user-content-function-arguments), [expression](#user-content-expression)_; Go to: _[primary-expression](#user-content-primary-expression), [expression](#user-content-expression), [postfix-expression](#user-content-postfix-expression), [natural](#user-content-natural), [identifier](#user-content-identifier), [function-arguments](#user-content-function-arguments), [circuit-type](#user-content-circuit-type)_;
Unary operators have the highest operator precedence. Unary operators have the highest operator precedence.
@ -1261,7 +1263,7 @@ unary-expression = postfix-expression
/ "-" unary-expression / "-" unary-expression
``` ```
Go to: _[postfix-expression](#user-content-postfix-expression), [unary-expression](#user-content-unary-expression)_; Go to: _[unary-expression](#user-content-unary-expression), [postfix-expression](#user-content-postfix-expression)_;
Next in the operator precedence is exponentiation, Next in the operator precedence is exponentiation,
@ -1275,7 +1277,7 @@ exponential-expression = unary-expression
/ unary-expression "**" exponential-expression / unary-expression "**" exponential-expression
``` ```
Go to: _[unary-expression](#user-content-unary-expression), [exponential-expression](#user-content-exponential-expression)_; Go to: _[exponential-expression](#user-content-exponential-expression), [unary-expression](#user-content-unary-expression)_;
Next in precedence come multiplication and division, both left-associative. Next in precedence come multiplication and division, both left-associative.
@ -1327,7 +1329,7 @@ equality-expression = ordering-expression
/ equality-expression "!=" ordering-expression / equality-expression "!=" ordering-expression
``` ```
Go to: _[equality-expression](#user-content-equality-expression), [ordering-expression](#user-content-ordering-expression)_; Go to: _[ordering-expression](#user-content-ordering-expression), [equality-expression](#user-content-equality-expression)_;
Next come conjunctive expressions, left-associative. Next come conjunctive expressions, left-associative.
@ -1338,7 +1340,7 @@ conjunctive-expression = equality-expression
/ conjunctive-expression "&&" equality-expression / conjunctive-expression "&&" equality-expression
``` ```
Go to: _[equality-expression](#user-content-equality-expression), [conjunctive-expression](#user-content-conjunctive-expression)_; Go to: _[conjunctive-expression](#user-content-conjunctive-expression), [equality-expression](#user-content-equality-expression)_;
Next come disjunctive expressions, left-associative. Next come disjunctive expressions, left-associative.
@ -1362,7 +1364,7 @@ conditional-expression = disjunctive-expression
":" conditional-expression ":" conditional-expression
``` ```
Go to: _[conditional-expression](#user-content-conditional-expression), [expression](#user-content-expression), [disjunctive-expression](#user-content-disjunctive-expression)_; Go to: _[disjunctive-expression](#user-content-disjunctive-expression), [conditional-expression](#user-content-conditional-expression), [expression](#user-content-expression)_;
Those above are all the expressions. Those above are all the expressions.
@ -1394,7 +1396,7 @@ statement = expression-statement
/ block / block
``` ```
Go to: _[return-statement](#user-content-return-statement), [variable-definition-statement](#user-content-variable-definition-statement), [assignment-statement](#user-content-assignment-statement), [console-statement](#user-content-console-statement), [expression-statement](#user-content-expression-statement), [loop-statement](#user-content-loop-statement), [conditional-statement](#user-content-conditional-statement), [block](#user-content-block)_; Go to: _[assignment-statement](#user-content-assignment-statement), [block](#user-content-block), [variable-definition-statement](#user-content-variable-definition-statement), [return-statement](#user-content-return-statement), [loop-statement](#user-content-loop-statement), [console-statement](#user-content-console-statement), [conditional-statement](#user-content-conditional-statement), [expression-statement](#user-content-expression-statement)_;
<a name="block"></a> <a name="block"></a>
@ -1437,7 +1439,7 @@ variable-definition-statement = ( %s"let" / %s"const" )
[ ":" type ] "=" expression ";" [ ":" type ] "=" expression ";"
``` ```
Go to: _[type](#user-content-type), [identifier-or-identifiers](#user-content-identifier-or-identifiers), [expression](#user-content-expression)_; Go to: _[identifier-or-identifiers](#user-content-identifier-or-identifiers), [expression](#user-content-expression), [type](#user-content-type)_;
<a name="identifier-or-identifiers"></a> <a name="identifier-or-identifiers"></a>
@ -1482,7 +1484,7 @@ The body is a block.
loop-statement = %s"for" identifier %s"in" expression ".." expression block loop-statement = %s"for" identifier %s"in" expression ".." expression block
``` ```
Go to: _[identifier](#user-content-identifier), [expression](#user-content-expression), [block](#user-content-block)_; Go to: _[block](#user-content-block), [identifier](#user-content-identifier), [expression](#user-content-expression)_;
An assignment statement is straightforward. An assignment statement is straightforward.
@ -1499,7 +1501,7 @@ assignment-operator = "=" / "+=" / "-=" / "*=" / "/=" / "**="
assignment-statement = expression assignment-operator expression ";" assignment-statement = expression assignment-operator expression ";"
``` ```
Go to: _[assignment-operator](#user-content-assignment-operator), [expression](#user-content-expression)_; Go to: _[expression](#user-content-expression), [assignment-operator](#user-content-assignment-operator)_;
Console statements start with the 'console' keyword, Console statements start with the 'console' keyword,
@ -1586,7 +1588,7 @@ function-declaration = *annotation %s"function" identifier
block block
``` ```
Go to: _[function-parameters](#user-content-function-parameters), [block](#user-content-block), [type](#user-content-type), [identifier](#user-content-identifier)_; Go to: _[block](#user-content-block), [function-parameters](#user-content-function-parameters), [identifier](#user-content-identifier), [type](#user-content-type)_;
<a name="function-parameters"></a> <a name="function-parameters"></a>
@ -1634,7 +1636,7 @@ member-declaration = member-variable-declaration
/ member-function-declaration / member-function-declaration
``` ```
Go to: _[member-variable-declaration](#user-content-member-variable-declaration), [member-function-declaration](#user-content-member-function-declaration)_; Go to: _[member-function-declaration](#user-content-member-function-declaration), [member-variable-declaration](#user-content-member-variable-declaration)_;
<a name="member-variable-declaration"></a> <a name="member-variable-declaration"></a>
@ -1642,7 +1644,7 @@ Go to: _[member-variable-declaration](#user-content-member-variable-declaration)
member-variable-declaration = identifier ":" type member-variable-declaration = identifier ":" type
``` ```
Go to: _[identifier](#user-content-identifier), [type](#user-content-type)_; Go to: _[type](#user-content-type), [identifier](#user-content-identifier)_;
<a name="member-function-declaration"></a> <a name="member-function-declaration"></a>
@ -1662,7 +1664,7 @@ circuit-declaration = *annotation %s"circuit" identifier
"{" member-declaration *( "," member-declaration ) "}" "{" member-declaration *( "," member-declaration ) "}"
``` ```
Go to: _[member-declaration](#user-content-member-declaration), [identifier](#user-content-identifier)_; Go to: _[identifier](#user-content-identifier), [member-declaration](#user-content-member-declaration)_;
An import declaration consists of the 'import' keyword An import declaration consists of the 'import' keyword
@ -1691,7 +1693,7 @@ package-path = "*"
/ "(" package-path *( "," package-path ) [","] ")" / "(" package-path *( "," package-path ) [","] ")"
``` ```
Go to: _[package-path](#user-content-package-path), [identifier](#user-content-identifier), [package-name](#user-content-package-name)_; Go to: _[package-path](#user-content-package-path), [package-name](#user-content-package-name), [identifier](#user-content-identifier)_;
Finally, we define a file as a sequence of zero or more declarations. Finally, we define a file as a sequence of zero or more declarations.
@ -1703,7 +1705,7 @@ declaration = import-declaration
/ circuit-declaration / circuit-declaration
``` ```
Go to: _[import-declaration](#user-content-import-declaration), [circuit-declaration](#user-content-circuit-declaration), [function-declaration](#user-content-function-declaration)_; Go to: _[import-declaration](#user-content-import-declaration), [function-declaration](#user-content-function-declaration), [circuit-declaration](#user-content-circuit-declaration)_;
<a name="file"></a> <a name="file"></a>
@ -1720,7 +1722,7 @@ Format Note
The ABNF standard requires grammars to consist of lines terminated by CR LF The ABNF standard requires grammars to consist of lines terminated by CR LF
(i.e. carriage return followed by line feed, DOS/Windows-style), (i.e. carriage return followed by line feed, DOS/Windows-style),
as explained in the background on ABNF later in this file. as explained in the background on ABNF earlier in this file.
This file's lines are therefore terminated by CR LF. This file's lines are therefore terminated by CR LF.
To avoid losing this requirement across systems, To avoid losing this requirement across systems,
this file is marked as 'text eol=crlf' in .gitattributes: this file is marked as 'text eol=crlf' in .gitattributes:
@ -1732,3 +1734,4 @@ It does not apply to the lines of the languages described by the grammar.
ABNF grammars may describe any kind of languages, ABNF grammars may describe any kind of languages,
with any kind of line terminators, with any kind of line terminators,
or even without line terminators at all (e.g. for "binary" languages). or even without line terminators at all (e.g. for "binary" languages).

View File

@ -1,26 +1,18 @@
; Leo Library ; Copyright (C) 2019-2021 Aleo Systems Inc.
; ; This file is part of the Leo library.
; Copyright (C) 2021 Aleo Systems Inc.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The Leo library is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
; Format Note ; The Leo library is distributed in the hope that it will be useful,
; ----------- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
; The ABNF standard requires grammars to consist of lines terminated by CR LF ; You should have received a copy of the GNU General Public License
; (i.e. carriage return followed by line feed, DOS/Windows-style), ; along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
; as explained in the background on ABNF later in this file.
; This file's lines are therefore terminated by CR LF.
; To avoid losing this requirement across systems,
; this file is marked as 'text eol=crlf' in .gitattributes:
; this means that the file is textual, enabling visual diffs,
; but its lines will always be terminated by CR LF on any system.
; Note that this CR LF requirement only applies to the grammar files themselves.
; It does not apply to the lines of the languages described by the grammar.
; ABNF grammars may describe any kind of languages,
; with any kind of line terminators,
; or even without line terminators at all (e.g. for "binary" languages).
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -1021,3 +1013,23 @@ declaration = import-declaration
/ circuit-declaration / circuit-declaration
file = *declaration file = *declaration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Format Note
; -----------
; The ABNF standard requires grammars to consist of lines terminated by CR LF
; (i.e. carriage return followed by line feed, DOS/Windows-style),
; as explained in the background on ABNF earlier in this file.
; This file's lines are therefore terminated by CR LF.
; To avoid losing this requirement across systems,
; this file is marked as 'text eol=crlf' in .gitattributes:
; this means that the file is textual, enabling visual diffs,
; but its lines will always be terminated by CR LF on any system.
; Note that this CR LF requirement only applies to the grammar files themselves.
; It does not apply to the lines of the languages described by the grammar.
; ABNF grammars may describe any kind of languages,
; with any kind of line terminators,
; or even without line terminators at all (e.g. for "binary" languages).