Commit Graph

263 Commits

Author SHA1 Message Date
d0cd
2a9cc42493
Merge pull request #1950 from AleoHQ/remove-unused-errors
Remove unused errors
2022-07-23 10:28:04 -07:00
Alessandro Coglio
ba6c239964 [ABNF] Add inclusive loop bound.
This is now part of the Leo compiler, so we need to update the grammar
accordingly.
2022-07-21 13:35:39 -07:00
Alessandro Coglio
f93ed1b15f [ABNF] Fix rule for circuit declarations.
The identifier had been neglected.
2022-07-20 18:36:23 -07:00
Mazdak Farrokhzad
db42194d49 remove unused errors 2022-07-20 20:19:00 +02:00
collin
1e5142a8a2 prepare for testnet3 as repo branch 2022-07-18 18:28:23 -07:00
Alessandro Coglio
97d26a879a [ABNF] Actually exclude 1-tuples.
Thanks to @bendyarm for noticing and reporting this.
2022-07-11 21:38:05 +02:00
Alessandro Coglio
9c3d2e0941 [ABNF] Add tuples.
This adds tuple types, tuple expressions (which build tuples from components),
and tuple component expressions (which access tuple components).

Based on previous discussions on this topic, 1-tuples are excluded. This
exclusion is done at the grammar level, since it is the kind of requirement that
is easily captured in a context-free grammar.
2022-07-10 18:28:31 +02:00
Alessandro Coglio
6bfe530922 [ABNF] Improve some rule names.
Based on a recent discussion on Slack, and on some related slight terminological
changes in the documentation of the Aleo instructions, this commit similarly
improves the Leo nomenclature for expressions involving the logical operators.

The attribute 'bitwise' for `&` and `|` and `^` has been dropped, since the
operations also operate on booleans besides integers.

Given that the operation and method names `or` and `xor` for inclusive and
exclusive disjunctions (as opposed to `ior` and `xor`), the unqualified
'disjunction' now refers to the inclusive one.

The non-strict `&&` and `||` are now called 'conditional' (as done in other
languages), and thus the ternary one has been expanded to 'conditional ternary'.

This does not change the Leo language; it just improves the nomenclature derived
from the grammar.
2022-07-04 15:45:11 -07:00
Alessandro Coglio
884d46abe4 [ABNF] Revert previous accidentally pushed commit. 2022-07-04 15:36:43 -07:00
Alessandro Coglio
c35b977207 [ABNF] Improve some rule names.
Based on a recent discussion on Slack, and on some related slight terminological
changes in the documentation of the Aleo instructions, this commit similarly
improves the Leo nomenclature for expressions involving the logical operators.

The attribute 'bitwise' for `&` and `|` and `^` has been dropped, since the
operations also operate on booleans besides integers.

Given that the operation and method names `or` and `xor` for inclusive and
exclusive disjunctions (as opposed to `ior` and `xor`), the unqualified
'disjunction' now refers to the inclusive one.

The non-strict `&&` and `||` are now called 'conditional' (as done in other
languages), and thus the ternary one has been expanded to 'conditional ternary'.

This does not change the Leo language; it just improves the nomenclature derived
from the grammar.
2022-07-04 15:26:10 -07:00
Eric McCarthy
71bd874b69 [abnf grammar] fix a few typos 2022-07-02 22:34:50 -07:00
collin
0a4069fe39 merge testnet3 2022-07-02 14:08:02 -07:00
Collin Chin
9e2641b321
Merge pull request #1885 from AleoHQ/core-circuits
Core circuits
2022-06-27 09:08:26 -10:00
Alessandro Coglio
557cdf15c3 [ABNF] Add syntax for record types. 2022-06-27 11:26:34 -07:00
Alessandro Coglio
f8f944da39 [ABNF] Add forgotten symbols.
These are for the recently added shift and bitwise logical operators. They
should have been also included in the rule `symbol` for symbol tokens. This
commit remedies that.
2022-06-25 15:24:53 -07:00
Alessandro Coglio
93e9686972 [ABNF] Prohibit empty circuits.
These would flatten to nothing, component-wise.

This requirement actually slighly simplifies the grammar, avoiding the `[ ... ]`
around the circuit component declarations (in a circuit declaration) or the
circuit component initializers (in a circuit expression).
2022-06-23 21:13:24 -07:00
Alessandro Coglio
35485bea25 [ABNF] Add circuits and add associated constants. 2022-06-23 15:06:39 -07:00
Alessandro Coglio
abc50d8c3e [ABNF] Add syntax for static function calls.
Also renames pre-existing (generic) function calls to 'free function calls', now
that we are effectively introducing a new kind of functions, namely (associated)
static functions, distinguished from free (i.e. non-associated) functions.

Also introduces notion of named type, as a type that has a name, which may be
either a keyword (e.g. `u8`, `address`) or an identifier (e.g. `Pedersen64`).
2022-06-20 13:46:43 -07:00
Collin Chin
1971dd0aa1
Merge pull request #1880 from AleoHQ/abnf-new-operators
[ABNF] Add new operators.
2022-06-20 12:24:12 -07:00
Collin Chin
6b064d0227
Merge pull request #1873 from AleoHQ/abnf-operator-calls
[ABNF] Add operator calls.
2022-06-20 12:23:46 -07:00
Alessandro Coglio
5539ce11a6 [ABNF] Improve the grammar for operator calls.
Introduce the notion of postfix expression in the grammar, which will also go
well with some expected upcoming extensions to Leo.

This does not change the Leo language. It does not necessarily involve modifying
the parser. It merely reorganizes some rules slightly.
2022-06-18 15:45:33 -07:00
Alessandro Coglio
5f5124d2d0 [ABNF] Fix overlooked update.
Thanks to @gluax for reporting the issue.
2022-06-16 15:18:59 -07:00
Alessandro Coglio
64307d075c [ABNF] Add new operators.
This adds shift (`<<` `>>`) and bitwise logical (`&` `|` `^`) operators.

Their precedence is between the additive and ordering operations, in this order
(higher to lower):
- ... others, to additive
- `<<` and `>>`
- `&`
- `|`
- `^`
- ... others, from ordering

This is consistent with Rust, but not with C and Java, both of which make the
bitwise logical operators lower-precedence than equalities.

The previous ABNF rule names for `conjunctive-expression` and
`disjunctive-expression` have been renamed to be more consistent with the newly
added ones. Also, the rule names "abbreviate" 'conjunctive' and 'disjunctive'
with 'and' and 'or', otherwise the names were a bit too long.
2022-06-16 14:02:22 -07:00
Alessandro Coglio
846c976c63 [ABNF] Add operator calls.
Since these are a method-like syntax for unary and binary operators (as in fact
these are represented as operators in the AST), the nomenclature 'operator call'
seems appropriate, at least for now. There is no need yet to introduce notions
of associated functions (and constants).

The rules explicitly distinguish between unary and binary ones, corresponding to
unary and binary operators. This lets us exclude right away calls with too many
arguments, and gives us a way to distinguish the two kinds.

A trailing comma is allowed at the end of the one argument of binary operator
calls, if one is really inclined to use it, just for syntactic consistency with
other calls (namely, function calls).
2022-06-13 13:24:05 -07:00
Alessandro Coglio
894e0af225 [ABNF] Fix/improve handling of line terminators.
Prohibit line terminators inside string literals. (This does not prohibit
escapes for line feed and/or carriage return; it prohibits actual line feeds and
carriage returns, which would break the string literal across lines.)

Explicate line terminators in block comments, so that an accurate line count can
be obtained more readily from the CSTs. (This is more relevant to the ACL2
formal development than to the Rust implementation, which does not have explicit
CSTs.)

Also reorder slightly some rules within the file.
2022-06-11 15:56:49 -07:00
gluax
540fdccffe Update abnf, and give docs over parser keywords 2022-06-09 12:45:52 -07:00
gluax
f6990e75fc fixed some bugs 2022-06-08 06:46:54 -07:00
Collin Chin
2429b72312
Merge pull request #1856 from AleoHQ/abnf-string-type
[ABNF] Add string type.
2022-06-02 12:46:56 -04:00
Collin Chin
53e5dfbb02
Merge pull request #1853 from AleoHQ/abnf-in-out-exprs
[ABNF] Relax input and output expressions.
2022-06-02 11:45:50 -04:00
Alessandro Coglio
354974726c [ABNF] Add string type. 2022-06-01 20:39:27 -07:00
gluax
f34f63cea4 update abnf 2022-06-01 08:48:36 -07:00
Alessandro Coglio
9e1dad2b2a [ABNF] Relax input and output expressions.
In input and output files, literals are actually insufficient to represent the
most negative values of the signed integer types.

Given that we are likely to need richer forms of input and output expressions
anyways, at this point it seems best to allow any expression at the grammatical
level, and add static semantic requirements on the allowed expressions. As done
with all the other requirements, these will be stated in the Leo Reference,
formalized in ACL2, and enforced in the Leo compiler.
2022-05-31 19:20:11 -07:00
Alessandro Coglio
66e84ba689 [ABNF] Minor README fixes and improvements. 2022-05-28 18:47:27 -07:00
Alessandro Coglio
2cdcdb479d [ABNF] Simplify .gitattribute file.
No need to reference a file that's no longer here.
2022-05-28 18:35:03 -07:00
Alessandro Coglio
b16f9ae31e [ABNF] Remove unused rule.
Since character literals were removed, the rule `not-single-quote-or-backslash`
is no longer needed.
2022-05-28 18:31:02 -07:00
gluax
2117ee3ae8 resolve readme conflict 2022-05-25 11:55:23 -07:00
Collin Chin
c4b15ec17b
Merge pull request #1836 from AleoHQ/abnf-output-grammar
[ABNF] Add initial output grammar.
2022-05-25 14:49:36 -04:00
collin
dc08403899 remove readme 2022-05-25 14:40:06 -04:00
collin
8d79193474 merge testnet3 2022-05-25 14:02:10 -04:00
gluax
936360793c slight clean up & handle grammar readme 2022-05-25 10:45:25 -07:00
gluax
c9612625d1 regenerate readme after pulling upstream 2022-05-25 09:24:02 -07:00
gluax
a0abb01abd regenerate readme 2022-05-25 09:22:32 -07:00
gluax
8cb4b19e66 merge upstream changes 2022-05-25 09:21:47 -07:00
Alessandro Coglio
b26ed8e2ef [ABNF] Add initial output grammar.
This is for the current simplified version of Leo. When the main function is
executed, it returns a value. According to this grammar, the output (i.e.
`.out`) file contains a single literal, which describes the output value,
preceded by an `[output]` title. This may be extended in the future.
2022-05-24 23:05:14 -07:00
collin
3979061632 merge testnet3 2022-05-24 12:52:19 -04:00
Mazdak Farrokhzad
0883126fef char removal: update ABNF + adjust examples 2022-05-24 15:51:58 +02:00
Alessandro Coglio
09001004d4 [ABNF] Refine the rule for input titles.
Since we only allow four kinds of input section titles, corresponding to the
public/private/constant/const characterization of function inputs, it seems
beneficial to put this into the grammar, where it is easily captured.

Note that the previous version of the rule, which uses `identifier`, is not
quite right, because, for example, `public` is not an identiifer (it is a
keyword). So the rule would have to be modified anyways.
2022-05-20 21:58:51 -07:00
Alessandro Coglio
a9564552a9 [ABNF] Add scalar type. 2022-05-13 21:32:56 -07:00
collin
8f17d6294a rename scalar -> primitive 2022-05-11 14:09:12 -07:00
gluax
039a71359c merge upstream testnet3, update grammar readme 2022-05-03 15:20:45 -07:00