Commit Graph

88 Commits

Author SHA1 Message Date
Alessandro Coglio
ba65b4f4d5 [ABNF] Improve rules for array expressions.
Extending array dimensions for types to allow underscore has the unintended
effect of allowing that also for expressions. This is not necessarily an error,
as the static semantics can rule out underscores from array expressions.
However, it is a simple syntactic constraint that is best captured by the
grammar.

This commit differentiate array dimensions for types and array dimensions for
expressions, using them in the appropriate places.
2021-09-09 11:55:30 -07:00
Alessandro Coglio
593aac5636 [ABNF] Incorporate change for unspecified array sizes.
That change was made on master concurrently with this PR. This commit integrates
the concurrent changes.
2021-09-06 13:10:55 -07:00
Alessandro Coglio
dab6f494b1 [ABNF] Improve formulation of rule for types.
As discussed on GitHub, list identifiers separately from Self.

Also adapt and improve some of the documentation comments.
2021-09-06 13:08:31 -07:00
Alessandro Coglio
b45a722d6b [ABNF] Move two rules within file.
No content change, just layout change.

Prepares for next change to the file.
2021-09-06 13:02:20 -07:00
Alessandro Coglio
1c18f4c56d [ABNF] Improve nomenclature.
Replace 'circuit-or-alias-type' with 'identifier-or-self-type'.

This makes the nomenclature for types more clear and extensible:

- A type may be an identifier, which may be the name of a circuit type or the
  name of a type alias.

- In the future, an identifier used as a type could refer to other kinds of
  types that we may add, such as enumerations.

- While both 'alias type' and 'type alias' could be acceptable terms, it seems
  best to standardize on 'type alias': the latter describes an alias of a type
  (which is the right concept), while the former suggests a type of the "alias"
  kind (cf. 'circuit type', 'field type', 'integer type', etc.). Type aliases
  are not another kind of types like the other: they are aliases of (any of)
  those kinds of types. So by not having 'circuit-or-alias-type' we avoid
  suggesting a notion of 'alias type'.

This does not change the language described by the grammar, it merely changes
some nomenclature in the grammar. Thus, no change to the parser is
needed. Aligning the nomenclature in the abstract syntax and parser to the ABNF
would be good, but entirely optional at this point.
2021-09-02 21:54:42 -07:00
Alessandro Coglio
cdde46e2f3 [ABNF] Remove keywords 'true' and 'false' again.
These were removed in a previous commit, because they are already classified as
(boolean) literals, but they were accidentally re-introduced, presumably due to
the type alias RFC referencing the previous version of the keyword grammar rule.
2021-08-27 10:31:02 -07:00
gluaxspeed
abd2919891 include grammar changes from pr 1290, regenerate md 2021-08-25 08:05:48 -07:00
gluaxspeed
e90228b295 type aliases 2021-08-19 06:04:44 -07:00
Alessandro Coglio
80e2b14c8c [ABNF] Fix rule for conditional expressions.
The test of the expression should have been a disjunctive expression. This was
an oversight when the rules were written.
2021-08-16 18:06:27 -07:00
Alessandro Coglio
33831779c7 [ABNF] Rename digit => decimal-digit.
Since, with the introduction of (ASCII and Unicode escapes for) characters, we
now have digits in base 10, 8, and 16, it seems worth being more explicit in the
naming of decimal digits in the grammar.

Just a nonterminal name change, not a structural change to the grammar.
2021-08-02 17:59:13 -07:00
Alessandro Coglio
14f0163d2c [ABNF] Move a rule and update some comments.
Move the rule for 'digit' just before the ones for 'octal-digit' and
'hexadecimal-digit'.

Update the comments accordingly.

No real change to the grammar here.
2021-08-02 17:56:47 -07:00
Alessandro Coglio
6f03b9df26 [ABNF] Add a notion of lexeme.
This is just for nomenclature. It does not change the language or anything.
2021-07-28 16:33:14 -07:00
Alessandro Coglio
ecadb3c321 [ABNF] Make the lexical grammar slightly less ambiguous.
Before this commit, 'true' and 'false' were both keywords and boolean literals,
making the grammar slightly more ambiguous than it needs to be. This manifests
in the formal specification of lexing and parsing, which would need an
additional extra-grammatical predicate requiring 'true' and 'false' to be
boolean literals and not keywords. By making 'true' and 'false' just boolean
literals, we obviate that need.

Extend the comment about identifiers and package names not being keywords or
aleo1... to also exclude boolean literals.

This is similar to the grammar of Java, in which 'true', 'false', and 'null' are
not keywords.

This does not necessitate any change to the lexer/parser, which already performs
its own procedural disambiguation of this and other aspects of the grammar.
2021-07-26 21:12:30 -07:00
gluaxspeed
8ae89149a9 ABNF grammar update 2021-07-23 17:36:27 -07:00
gluaxspeed
dd67004af7 remove old abnf comments, format abnf 2021-07-21 14:42:25 -07:00
gluaxspeed
a9593971b9 format string and grammar changes 2021-07-20 14:52:35 -07:00
Alessandro Coglio
bceefa621d [ABNF] Fix typo in comments. 2021-07-15 21:44:27 -07:00
Alessandro Coglio
baace61e21 [ABNF] Add some comments.
Add to the rule for package names, as a comment, the same exclusion added to the
rule for identifiers. Also add a few lines to describe it.

Also discuss the disambiguation of identifiers and package names.
2021-07-14 22:09:28 -07:00
gluaxspeed
d983467b01 Fix package-name in abnf 2021-07-06 11:57:24 -07:00
gluax
bcb50ae27f change equality_expressions 2021-07-01 13:40:29 -07:00
gluax
eee9cfc1be fix parser to match abnf conditional 2021-06-30 22:20:06 -07:00
Alessandro Coglio
7d21990db1 [ABNF] Tweak documentation. 2021-05-12 19:13:23 -07:00
Alessandro Coglio
566365e501 [ABNF] Move a rule a bit within the file.
No changes to rules.

Just putting two rules close that are somewhat related (as they are used to
define comments).
2021-05-12 19:11:31 -07:00
Alessandro Coglio
7e378545e0 [ABNF] Replace format strings with string literals.
Given that we have string literals now, there is no need for the special notion
of format strings. Some other grammar rules go away as they were only involved
in the definition of format strings.

The well-formedness of containers in format strings is now delegated to the
static semantics of Leo: at the grammar level, any string literals is accepted
in console print calls.
2021-05-12 19:08:02 -07:00
Alessandro Coglio
e304866696 [ABNF] Add string literals.
These are a new kind of literals that denote arrays of characters, which is how
we initially represent strings in Leo.
2021-05-12 19:04:42 -07:00
Alessandro Coglio
d869e17033 [ABNF] Add character literals.
These are a new kind of literals that denote char values.
2021-05-12 18:41:58 -07:00
Alessandro Coglio
19d3bf0125 [ABNF] Add char type.
This is a new scalar type for characters.
2021-05-12 18:22:08 -07:00
Alessandro Coglio
7ac1de7353 [ABNF] Expand some doc and break some lines.
Explain the new syntax for circuit member variables.

Explain the tighter syntax for import declarations.

Keep lines to 80 columns max, so that they fit well in the figures in the LaTeX
document.
2021-05-07 21:33:15 -07:00
gluax
f32a1e9ddb merge master, add a parser test to try and improve code coverage 2021-05-07 13:34:10 -04:00
gluax
29ca0d9a12 no empty import lists, star is a span, grammar fix 2021-05-05 16:10:51 -04:00
gluax
f4c9c2c1f0 update grammar readme after master merge 2021-05-05 13:18:13 -04:00
Alessandro Coglio
8df12668c0 [ABNF] Fix (comment in) rule for identifiers.
Now the comment says that an identifier must not only be distinct from a
keyword, but also not be or start with 'aleo1'. Even though the grammar does not
capture these extra-grammatical requirements, we use comments to at least
mention them prominently.
2021-05-03 21:41:20 -07:00
Alessandro Coglio
5288f2e2f0 [ABNF] Fix rule for import declarations.
The final semicolon was missing.

See https://developer.aleo.org/developer/language/imports.
2021-05-01 18:41:56 -07:00
gluax
c8f1d9913c rename grammar rule as suggested 2021-04-30 12:07:35 -04:00
Alessandro Coglio
2060d0d249 [ABNF] Improve documentation and layout.
Explain better variable and constant declarations.

Leave one blank line between the rules for variable and constant declarations
(not necessary for ABNF, but consistent with the rest of the file and actually
expected by the ABNF-to-LaTeX converter).

Limit lines to 80 columns, by putting the rules for variable and constant
declarations over two lines each, with proper indentation.
2021-04-29 18:16:30 -07:00
gluax
e0cf988261 hacky, but optional comma only allowed on last member variable 2021-04-29 15:22:17 -04:00
gluax
282cbb8840 optional comma at end of member variables 2021-04-29 14:10:22 -04:00
gluax
30d80d191f require comma or semi-colon for now 2021-04-29 14:03:29 -04:00
Alessandro Coglio
ccbf36e6ec Merge and resolve conflict on generated README.md.
(Since the file is generated, I've simply re-generated it to resolve the
conflict.)
2021-04-28 21:57:34 -07:00
Collin Chin
aaa42bba4c
Merge pull request #705 from AleoHQ/feature/485-defines
Feature/485 global consts
2021-04-28 14:06:40 -07:00
gluax
26d569c92a declaration refactor as suggested 2021-04-28 12:41:42 -04:00
Alessandro Coglio
0882100526 [ABNF] Trim some documentation.
The removed text is more of an internal discussion that actual documentation, so
it seems best to keep things slightly more concise.
2021-04-27 22:45:27 -07:00
Alessandro Coglio
244e1a49ee [ABNF] Fix typo in documentation. 2021-04-26 20:30:15 -07:00
gluax
438c20c14d merge master, resolve conflicts, login test is failing 2021-04-26 14:43:21 -04:00
Alessandro Coglio
df6c4d586c [ABNF] Use markdown in doc comments, and a few fixes.
By using markdown in the documentation comments of the grammar, the markdown
file generated from the grammar includes those markdown features in the text,
making it more readable and better-looking.

Also fixed a few typos in the documentation comments.

Also updated a few documentation comments that were out of date after making
changes to the grammar.

Also removed a now-obsolete grammar rule for "input" parameters of functions.
2021-04-21 22:33:52 -07:00
Alessandro Coglio
02f8736d03 [ABNF] Add some documentation.
For both uniformity and clarity of reference from other documentation comments,
add some documentation comments next to every single character definition.

No change to the grammar itself.
2021-04-21 21:56:27 -07:00
Alessandro Coglio
ac5ca5058a [ABNF] Edit some doc comments for consistency.
No change to the grammar, just some edits in comments.
2021-04-21 10:44:40 -07:00
Alessandro Coglio
e08d1f7f36 [ABNF] Move two rules and add some comments.
This does not change the grammar, just its presentation in the file.
2021-04-21 10:39:37 -07:00
Collin Chin
25cabe57e2
Merge branch 'master' into feature/abnf-doc-update 2021-04-21 08:46:01 -07:00
Alessandro Coglio
964883a535 [ABNF] Add full copyright/licensing notice.
Make the change to the .txt file.
2021-04-20 15:52:08 -07:00