top two rules unclear
`<list(X, SEP)> ::=
<list1(X, SEP)> ::= X X SEP <list(X, SEP)>`
the first two rules they don’t seem to be part of the standard BNF syntax
e.g. <list(X,SEP)> this looks like a template for a rule, I can’t seem to locate this in the official BNF syntax.
I am trying to parse the grammar in ANTLR4 and it seems to not recognize the first two rules which have this syntax. Typically an BNF rule id is meant to just be a string of chars with ‘-’ or numbers (according to the antlr grammar for BNF this is what an ID is supposed to be made of:
id_ : LT ruleid GT ;
ruleid : ID ;
ID : (‘a’…‘z’|‘A’…‘Z’) (‘a’…‘z’|‘A’…‘Z’|‘0’…‘9’|’-’|’ ')+ ;
and a rule is
rule_ : lhs ASSIGN rhs ;
where the ASSIGN is ::==
ASSIGN : ‘::=’ ;
So a little lost here, what syntax do the first two rules follow, they almost look like meta-rules. Is the tool that generates them something internal or open source?
These syntax descriptions resemble EBNF, but were generated from the menhir grammar in src/mo_frontend/parser.mly.
Menhir also has an option to produce a yacc compatible grammar from the menhir grammar, if I recall correctly. (UPDATE: having looked at the doc, I can't actually find the option anymore).
In any case, http://gallium.inria.fr/~fpottier/menhir/ is the tool we use.
If it helps (not sure it will, unless Rust is familiar), but we are in the process of making another, totally compatible reference implementation in Rust.
This part is relevant for translating that aspect of the existing parser. Very WIP.
Transferring to Motoko repo as this is related to Motoko syntax, not documentation/website content.