Commit Graph

275 Commits

Author SHA1 Message Date
d0cd
297128af6d
Merge pull request #2024 from AleoHQ/abnf-console
[ABNF] Revise console statements.
2022-08-18 16:28:29 -07:00
Pranav Gaddamadugu
eb4ee1428c Cleanup out dated docs 2022-08-18 15:45:30 -07:00
Alessandro Coglio
eab2e4466d [ABNF] Revise console statements.
Add `console.assert_eq` and `console.assert_neq`.

Remove `console.log` and `console.error`.

Remove the format string grammar, since it was only used for console print
calls, which have been removed.

This matches #2023.
2022-08-17 21:45:40 -07:00
Alessandro Coglio
ce2d8f8a51 [ABNF] Add annotations.
This is to match the recent introduction of the `@program` annotation for
external functions (i.e. functions that may be called externally, passing to
them inputs through the input files).

This PR adds not just that annotation, but a more general notion of annotation
as a new kind of token of the form `@<identifier>`, and with the ability to
precede each function declaration with zero or more such annotations.

The fact that it has been added as a token to the lexical grammar, means that
there cannot be any whitespace or comments between the `@` and the identifier.
If that is undesired, we can add it to the syntactic grammar instead, defining
an annotation as consisting of the (new) symbol token `@` followed by an
identifier token.

We can of course extend annotations with arguments at some point, if needed.
2022-08-09 20:45:54 -07:00
collin
5f0a6573a5 Merge branch 'testnet3' of github.com:AleoHQ/leo into remove-unsafe 2022-08-05 11:52:09 -07:00
Alessandro Coglio
79bef6627a [ABNF] Add compound assignments. 2022-08-04 21:01:05 -07:00
Mazdak Farrokhzad
a77d3b4092 forbid unsafe_code in all crates 2022-08-05 00:36:41 +02:00
d0cd
140c2b31ad
Create operators.md 2022-08-03 12:04:39 -07:00
Alessandro Coglio
f5b62e913b [ABNF] Add the remainder operator. 2022-07-28 14:25:01 -07:00
d0cd
9bd4db47fb
Merge pull request #1962 from AleoHQ/grammar-add-record-name-and-inner-rule
[grammar] add missing record name identifier; factor circuit-componen…
2022-07-24 21:53:24 -07:00
Eric McCarthy
9756714fd2 [grammar] add missing record name identifier; factor circuit-component-declarations into separate grammar rule 2022-07-23 23:32:17 -07:00
Alessandro Coglio
949aac14db [ABNF] Generalize input type. 2022-07-23 21:05:19 -07:00
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