Commit Graph

239 Commits

Author SHA1 Message Date
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
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