Commit Graph

263 Commits

Author SHA1 Message Date
Alessandro Coglio
db823bf34d [ABNF] Keep file to 80 columns. 2022-04-29 22:01:54 -07:00
Alessandro Coglio
8b5c10a61f [ABNF] Improve doc comment.
Given that the Leo Reference explains well that the format string grammar
applies to the character sequence after processing escapes, we do not need to
say this here. Instead, we just explain the rule similarly to what we do for
others.
2022-04-29 21:58:34 -07:00
gluax
124e6b2e9b
[Impl] Ast Visitor (#1769)
* visitor pattern

* merge upstream, regen grammar readme

* rename reducer to passes

* update comments to properly reflect visitor

* fmt and clippy fixes

* fix comments

Co-authored-by: collin <16715212+collinc97@users.noreply.github.com>
2022-04-22 16:05:50 -07:00
Alessandro Coglio
a8c674a881 [ABNF] Improve doc comment about bidi exclusions.
This mentions embeddings and isolates besides overrides, in accordance with the
official terminology at https://www.unicode.org/reports/tr9/.

This update was discussed and agreed with @bendyarm.

Note: The Leo Reference includes text explaining these exclusions, with links to
the document above as well to the web site and paper about Trojan source
exploits.
2022-04-21 20:02:25 -07:00
Collin Chin
23fca6af47
Merge pull request #1751 from AleoHQ/abnf-bidi-overrides
[ABNF] disallow bidi override codepoints
2022-04-20 09:34:00 -07:00
Eric McCarthy
0611ddd94f [ABNF] fix merge of #1759 2022-04-19 13:34:56 -07:00
Eric McCarthy
3f9a51041f [ABNF] merge #1759 2022-04-19 13:28:51 -07:00
Eric McCarthy
ac005628fe [ABNF] merge #1752 2022-04-19 11:59:22 -07:00
Alessandro Coglio
cb30765ab5 [ABNF] Add rule for numeric literals.
This does not change the language. It just factors things better and introduces
more nomenclature in the grammar.
2022-04-18 17:35:14 -07:00
Collin Chin
92ddc88477
Merge pull request #1755 from AleoHQ/abnf-input-files
[ABNF] Add (first draft of) input grammar.
2022-04-18 14:38:08 -07:00
Alessandro Coglio
29f797efae [ABNF] Add (first draft of) input grammar.
This is the (sub)grammar for input files. It is an initial draft, written based
on the Notion page 'Leo Input File Doc/Spec'. This should be compared with the
currently implemented parser of input (i.e. .in) files.

As the Leo Reference will describe (that part has not been written yet), the
input grammar is based on the lexical grammar, i.e. an input file consists of
tokens, comments, and whitespace. However, only some tokens (compared to the
syntactic grammar for Leo code files) are used, namely the ones reachable from
the `input-file` nonterminal.

Currently (i.e. im this initial version of Leo) `input-type` is (any) `type` and
`input-expression` is just a `literal`, but these may evolve as we extend the
language (e.g. we'll probably disallow circuit types and allow tuple and array
constructions). The intent is that `input-type` will be a subset of `type` and
that `input-expression` will be a subset of `expression`.
2022-04-15 19:54:41 -07:00
Alessandro Coglio
7691e35d86 [ABNF] Add rule for binary expressions.
This does not change the language. It just adds a rule to name binary
expressions explicitly. This makes the relation with ternary expressions
clearer, and as usual it explicates more terminology.
2022-04-14 22:26:25 -07:00
Eric McCarthy
447e50f8b4 [ABNF] disallow bidi override codepoints 2022-04-14 02:04:20 -07:00
Alessandro Coglio
515e471c8b
[ABNF] Add a rule for function calls. (#1747)
* [ABNF] Add a rule for function calls.

This does not change the language. It just slightly reformulates the grammar for
greater clarity and to help establish a nomenclature for constructs.

Also remove a trailing space.

* [ABNF] Re-generate markdown.

Co-authored-by: collin <16715212+collinc97@users.noreply.github.com>
2022-04-13 12:22:04 -07:00
gluax
168080942b better match pattern for catching more error situations 2022-04-12 11:52:12 -07:00
gluax
304044546c add constant keyword to grammar, change parameter grammar 2022-04-11 10:01:54 -07:00
Alessandro Coglio
dc3363a858 [ABNF] Factor integer literals into a rule.
This mirrors the structure of the rules for types, where there is an
`integer-type` consisting of `unsigned-type` and `signed-type`.

There is no change to the language.
2022-04-08 19:08:47 +02:00
Alessandro Coglio
822da8009c [ABNF] Add public to keywords. 2022-04-07 22:07:37 +02:00
gluax
8482430299 update abnf to reflect recent changes 2022-04-06 10:41:18 -07:00
gluax
a5b692a765 merge upstream testnet3 2022-04-06 10:25:26 -07:00
gluax
1604170adc update grammar 2022-04-05 09:38:21 -07:00
Alessandro Coglio
c0ffe443c1 [ABNF] Add numerals to tokens.
In the currently restricted version of Leo, this is necessary for the numerals
in affine group literals to be tokens.

No change necessary to the lexer/parser, which already handle this properly.
2022-04-04 20:47:57 -07:00
Alessandro Coglio
0a35ad8006 [ABNF] Re-generate markdown. 2022-04-01 21:26:30 -07:00
Alessandro Coglio
52d820ad7b [ABNF] Also remove rule for expression statements.
Expression statements were removed from the rule for statements, but the rule
for expression statements itself had not been removed. This commit fixes that.
2022-04-01 21:25:37 -07:00
collin
4dce7a86cc Merge branch 'testnet3-dev' of https://github.com/AleoHQ/leo into abnf-expression-statements 2022-04-01 14:17:37 -07:00
collin
f60cf07fad fix merge conflict 2022-04-01 12:20:21 -07:00
collin
1025ab5b19 fix merge conflict 2022-04-01 12:04:37 -07:00
Alessandro Coglio
d08a4f814a [ABNF] Remove expression statements.
Since we do not have tuple in this version of Leo, we cannot have expression
statements, because normally expressions used as statements would have to return
the empty tuple, since we disallow throwing away values in Leo.
2022-03-29 21:20:26 -07:00
Alessandro Coglio
4cce09d5c8 [ABNF] Require function output type.
Since this pre-testnet3 version of Leo does not support tuple types, and since a
missing function type is meant to be interpreted as the empty tuple type `()` in
future versions of Leo, it seems appropriate to require a function output type
in this version of Leo. We could instead default to a different type
(e.g. bool), but it seems cleaner to require it for now, and make it optional
later.
2022-03-28 12:26:36 -07:00
gluax
398e6f5469 merge upstream testnet3 2022-03-28 06:21:17 -07:00
Eric McCarthy
45c731f74d [ABNF] remove extra comment on not-brace 2022-03-24 17:29:06 -07:00
Eric McCarthy
a96e44c49b [ABNF] trim down comments, which will move to the Leo Reference 2022-03-24 17:26:10 -07:00
Eric McCarthy
e6752d67a0 [ABNF] fix the code point range in the format string grammar, along with a note on what the code points mean 2022-03-24 17:13:58 -07:00
Eric McCarthy
3840e04f00 [ABNF] remove Unicode codepoints that can not occur 2022-03-24 11:55:35 -07:00
Alessandro Coglio
e3f87ad322 [ABNF] Remove some stray documentation comments.
Documentation comments were all removed from this grammar file, as readers of
this file in this branch are already familiar with Leo.
2022-03-21 17:49:38 -07:00
Alessandro Coglio
7b13ba58e4 [ABNF] Re-classify function call expressions.
This mirrors, in pre-testnet3, the change in PR #1699 in testnet3.

Since in pre-testnet3 we have fewer kinds expressions, the category of postfix
expressions disappears altogether with this re-classification.
2022-03-21 17:41:41 -07:00
collin
d388b74b7f pull latest testnet3 2022-03-21 13:49:16 -07:00
Alessandro Coglio
b1eae61527 [ABNF] Improve some rule names.
This does not change the language. It only renames two related rule names:

function-input => named-parameter
function-inputs => named-parameters

According to the new nomenclature, there are function parameters, which are self
parameters and named parameters: the nomenclature is clear and "symmetric".

The problem with the previous nomenclature is that both self and named
parameters are inputs, not just the named ones.
2022-03-19 21:19:19 -07:00
Alessandro Coglio
7d39937330 [ABNF] Fix typo found by @bendyarm. 2022-03-18 22:30:48 -07:00
Alessandro Coglio
1719e3d598 [ABNF] Add two extra-grammatical requirements.
These are needed to make parsing unambiguous. They require the test of a
conditional statement and the ending bound of a loop statement to not be or
start with a circuit expression.
2022-03-18 17:41:56 -07:00
Eric McCarthy
227b887a71 [ABNF] add parens in group-coordinate for readability; fix indentation of format-string-element to make consistent with other indentation 2022-03-16 22:42:30 -07:00
Alessandro Coglio
5c1efa81f7 [ABNF] Grammar for pre-testnet3 version.
This is obtained by removing features from the grammar currently in the testnet3
branch.

The documentation comments have been removed to keep the file smaller and
simpler to read, as readers of this file should be already familiar with Leo.
Furthermore, that documentation material is being moved to the Leo Language
Reference.

This commit also folds the format string grammar (for console print strings)
into (a separate section of) the same file, again for simplicity. The previous
separate small file (and generated markdown) for format strings has thus been
removed.
2022-03-16 21:39:17 -07:00
Alessandro Coglio
729dbaceec [ABNF] Allow trailing commas everywhere.
Also disallow 1-tuple array dimensions.
2022-03-16 20:40:06 -07:00
Collin Chin
07d03b0ff1
Merge pull request #1684 from AleoHQ/abnf-numeral-is-token
[ABNF] Add numerals to tokens.
2022-03-15 14:50:56 -07:00
Collin Chin
f886890e2b
Merge pull request #1679 from AleoHQ/abnf-doc-fix-b
[ABNF] Update some documentation
2022-03-15 10:22:54 -07:00
Alessandro Coglio
efffcc98dc [ABNF] Add numerals to tokens.
Given that arithmetic literals are now all typed in the grammar, we need
numerals to be listed as tokens. Otherwise, array dimensions and tuple indices
would not be tokens, but they must be.
2022-03-14 22:05:42 -07:00
Eric McCarthy
572d59d67f [ABNF] regenerate README.md 2022-03-14 12:35:56 -07:00
Eric McCarthy
ffa8200d92 [ABNF] update some documentation 2022-03-14 12:29:19 -07:00
Alessandro Coglio
3f6b17646c [ABNF] Add a clarification to the documentation.
No grammar change in this commit.
2022-03-10 15:31:31 -08:00
Alessandro Coglio
ca3ae89a3e [ABNF] Rename 'natural' to 'numeral'.
This applies both to the rule name and to the terminology used for that, namely
for a non-empty sequence of decimal digits.

While 'natural' was meant to describe a natural number (i.e. a non-negative
integer: 0, 1, 2, ...), it is perhaps not a familiar term to many users.

On the other hand, 'integer', while often used in programming languages for this
kind of thing, is not ideal as integers may be negative.

Also, assuming type inference, a lone numeral like `17` may actually not denote
an integer number at all, because it may actually denote a group element if type
inference turns it into `17group`, and group elements are not integers.

All in all, 'numeral' seems like a good term, also according to its dictionary
definition. It is used in the Java grammar to denote this kind of thing, for
instance.

If, in the future, we want to allow hexadecimal, octal, or binary notation, we
could rename this to `decimal-numeral`, introduce `hexadecimal-numeral`,
`octal-numeral`, and `binary-numeral`, and `numeral` as the union of these.
2022-03-10 15:23:58 -08:00
Collin Chin
4dd70474f5
Merge pull request #1669 from AleoHQ/abnf-integer-fix
[ABNF] Fix use of integers in literals.
2022-03-10 12:02:10 -08:00
Alessandro Coglio
f735ca8864 [ABNF] Update some documentation.
This does not change the grammar. It merely updates some text in the comments,
which shows a rule that was changed at some point but its copy in the comments
was not properly updated.

Thanks to @bendyarm for noticing this.
2022-03-08 23:23:38 -08:00
Alessandro Coglio
7e930d8670 [ABNF] Fix use of integers in literals.
This removes the rule for `integer` and uses `natural` for all numeric literals.

Otherwise, lexing would be context-dependent for no good reason.

This is consistent with the lexer and parser of the Leo compiler.

Note that, for instance, `-1field` is not a literal, but rather a unary
expression where `-` is applied to the literal `1field`. This is consistent with
other languages too.
2022-03-08 21:08:59 -08:00
Collin Chin
5e2ba78750
Merge pull request #1656 from AleoHQ/remove/unsized-array
Remove/unsized array
2022-03-07 17:14:03 -08:00
Alessandro Coglio
6cbf206f86 [ABNF] Require types to avoid type inference.
Types are now required in variable and constant declarations (including for loop
variables), and for literals (i.e. there are no longer untyped literals).
2022-03-05 23:52:34 -08:00
Alessandro Coglio
6aca970b88 [ABNF] Re-generate markdown.
(Forgot to do this in the previous commit.)
2022-03-04 19:51:14 -08:00
Alessandro Coglio
c30df925ef [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.)
2022-03-04 19:42:42 -08:00
collin
10bea676a8 remove unsized arrays 2022-03-04 12:23:46 -08:00
collin
22f605349c merge testnet3 2022-02-28 09:42:37 -08:00
collin
e263e64279 restructure compiler and delete unused code 2022-02-22 15:12:52 -08:00
Alessandro Coglio
7f9b6b09da
Merge pull request #1414 from AleoHQ/rfc/static-circuit-members
[RFC] Add a way to define static members to circuits to accesses RFC
2021-10-27 21:46:34 -07:00
gluaxspeed
870dfe8a9d fix typo 2021-10-26 09:09:47 -07:00
Alessandro Coglio
582dfed17d [RFC] Make change suggested by Damir. 2021-10-25 21:23:06 -07:00
gluaxspeed
8600c13dd3 make agreed upon changes 2021-10-25 06:43:09 -07:00
Alessandro Coglio
ae26d4c7d4 [RFC] Add an RFC for const functions.
The purpose of this RFC is to:
- Provide user documentation for this feature in a more accessible way than
  in the text for https://github.com/AleoHQ/leo/pull/1410, particularly after
  that PR is closed.
- Record the discussion in a recent meeting about broadening the notion of const
  function to map const arguments to const results rather than requiring const
  arguments, as a possible future extension.
2021-10-24 22:19:33 -07:00
gluaxspeed
a34f36b9c1 add example for static constant 2021-10-21 11:31:40 -07:00
gluaxspeed
5654e8a7a6 add a way to define static members to circuits to accesses rfc 2021-10-21 11:27:02 -07:00
Alessandro Coglio
6e3900dfa2
Merge pull request #1380 from AleoHQ/rfc-import
[RFC] Some minor edits and some additions to the imports RFC
2021-10-07 09:12:16 -07:00
Alessandro Coglio
f3a1352ec2 [RFC] Minor edits to the text. 2021-10-05 21:01:47 -07:00
Alessandro Coglio
aa29ce30d4 [RFC] Move some text to explicit background section.
According to new template, background is at the same level as (and before)
design.
2021-10-05 20:54:59 -07:00
Alessandro Coglio
7d4198fe43 [RFC] Change some headling levels.
In accordance with new template.
2021-10-05 20:53:20 -07:00
Alessandro Coglio
93210e7879 [RFC] Revise the background on pacakges and imports.
Starting to establish precise nomenclature and definitions for these Leo
concepts.
2021-10-04 19:04:11 -07:00
Alessandro Coglio
bc9658b972 [RFC] Improve some wording. 2021-10-04 18:51:48 -07:00
Alessandro Coglio
ebc213342b
Merge pull request #1377 from AleoHQ/rfc-recursion
[RFC] Clarify bounded recursion RFC
2021-10-01 20:06:07 -07:00
Alessandro Coglio
5b77e1e283 [RFC] Add a background section. 2021-10-01 10:58:45 -07:00
Alessandro Coglio
b37de11116 [RFC] Minor edits (just form, no change of substance). 2021-10-01 10:46:06 -07:00
Alessandro Coglio
8d26cc5676 [RFC] Adjust heading levels according to new template. 2021-10-01 10:38:16 -07:00
Alessandro Coglio
d134548d0e
Merge pull request #1373 from AleoHQ/rfc-strings
[RFC] Clarify structure of character/string RFC
2021-09-30 22:13:53 -07:00
Alessandro Coglio
b91864828f
Merge pull request #1372 from AleoHQ/rfc-template
[RFC] Extend template.
2021-09-30 22:13:19 -07:00
Alessandro Coglio
a5de1d6ee3
Merge pull request #1368 from AleoHQ/rfc-rec-trans
[RFC] Updates to record/transaction model
2021-09-30 22:12:53 -07:00
Alessandro Coglio
aca438aaba [RFC] Move some text under future extensions. 2021-09-30 10:15:15 -07:00
Alessandro Coglio
8b39f54165 [RFC] Move inlining examples to background section. 2021-09-30 10:10:23 -07:00
Alessandro Coglio
d633f93f6f [RFC] Use header levels consistent with (new) template. 2021-09-30 09:55:52 -07:00
Alessandro Coglio
87c8ec2923 [RFC] Move future extensions under future extensions.
Also add subsections for each future feature.

Also tweak/improve some wording.
2021-09-29 10:26:53 -07:00
Alessandro Coglio
6340929f28 [RFC] Move future extensions section to the end. 2021-09-29 10:17:09 -07:00
Alessandro Coglio
4bbbac131e [RFC] Use heading levels accoring to template. 2021-09-29 10:15:46 -07:00
Alessandro Coglio
b966b1833c [RFC] Generalize some text. 2021-09-29 10:13:24 -07:00
Alessandro Coglio
c3dab6a153 [RFC] Move future extensions section last.
Since it may refer to something discussed under alternatives, it makes more
sense to put this after that.
2021-09-29 10:05:22 -07:00
Alessandro Coglio
2e43c0c58f [RFC] Extend template. 2021-09-28 22:46:38 -07:00
Alessandro Coglio
9daeaf41e0 [RFC] Add some text about input/output files. 2021-09-27 14:25:35 -07:00
Alessandro Coglio
acd217036d [RFC] Move some text under 'alternatives'. 2021-09-27 14:14:18 -07:00
Alessandro Coglio
8f6d1a2d89 [RFC] Add subsection about transaction I/O access. 2021-09-27 13:49:51 -07:00
Alessandro Coglio
da66672a6f [RFC] Add subsection for entry point I/O types. 2021-09-27 13:39:23 -07:00
Alessandro Coglio
012770c2c0
Merge pull request #1361 from AleoHQ/rfc-scalar-methods
[RFC] Some updates to the RFC for scalar methods.
2021-09-27 13:13:26 -07:00
Alessandro Coglio
52eedad24c [RFC] Put transaction inputs/outputs into subsection. 2021-09-27 13:05:42 -07:00
Alessandro Coglio
f525d34922 [RFC] Move text on multiple entry points to subsection.
Also improve that text.
2021-09-27 12:47:54 -07:00
Alessandro Coglio
eb84e27018
Merge pull request #1360 from AleoHQ/rfc-statuses
[RFC] Update some statuses.
2021-09-27 12:45:34 -07:00
Alessandro Coglio
184243b471 [RFC] Make title and summary more precise.
We are improving the current model, not creating a new one.
2021-09-27 12:38:24 -07:00
Alessandro Coglio
4c95d41c31 [RFC] Move background to new section. 2021-09-27 12:30:13 -07:00
Alessandro Coglio
5ee579005c [RFC] Add link to Zexe paper.
Other small improvements to the text.
2021-09-27 12:27:18 -07:00