Closed mingodad closed 4 months ago
And here is the EBNF
for mlb.grm
:
// From: https://github.com/MPLLang/mpl/blob/master/mlton/front-end/mlb.grm
mlb ::= basdecs
basdecs ::= basdecsnode
basdecsnode ::=
| SEMICOLON basdecs
| basdec basdecs
basdec ::= basdecnode
basdecnode
::= FUNCTOR fctbinds
| SIGNATURE sigbinds
| STRUCTURE strbinds
| BASIS basbinds
| LOCAL basdecs IN basdecs END
| OPEN basids
| FILE
| STRING
| PRIM
| ANN annPlus IN basdecs END
fctbinds ::= fctid EQUALOP fctbinds_prime
| fctid fctbinds_prime_prime
fctbinds_prime ::= fctid fctbinds_prime_prime
fctbinds_prime_prime ::= /*empty*/
| AND fctbinds
sigbinds ::= sigid EQUALOP sigbinds_prime
| sigid sigbinds_prime_prime
sigbinds_prime ::= sigid sigbinds_prime_prime
sigbinds_prime_prime ::= /*empty*/
| AND sigbinds
strbinds ::= strid EQUALOP strbinds_prime
| strid strbinds_prime_prime
strbinds_prime ::= strid strbinds_prime_prime
strbinds_prime_prime ::= /*empty*/
| AND strbinds
basbinds ::= basid EQUALOP basbinds_prime
basbinds_prime ::= basexp basbinds_prime_prime
basbinds_prime_prime ::= /*empty*/
| AND basbinds
basexp ::= basexpnode
basexpnode ::= BAS basdecs END
| basid
| LET basdecs IN basexp END
basid ::= id
basids ::= basid
| basid basids
fctid ::= id
sigid ::= id
strid ::= id
id ::= ID
ann ::= STRING
annPlus ::= ann annStar
annStar ::= /*empty*/
| annPlus
// Tokens
//<INITIAL>\("[^"]+"\) => (tok (Tokens.\([^,]+\),.+
PRIM ::= "_prim"
COMMA ::= ","
SEMICOLON ::= ";"
EQUALOP ::= "="
AND ::= "and"
ANN ::= "ann"
BAS ::= "bas"
BASIS ::= "basis"
END ::= "end"
FUNCTOR ::= "functor"
IN ::= "in"
LET ::= "let"
LOCAL ::= "local"
OPEN ::= "open"
SIGNATURE ::= "signature"
STRUCTURE ::= "structure"
Thanks for sharing. This is cool but doesn't seem like an issue so I'm going to close for now.
Using a bit of search and replace on the grammar with and adding some of the tokens from the lexer we can have a nice navigable railroad diagram.
Copy and paste the
EBNF
shown bellow on https://www.bottlecaps.de/rr/ui on the tabEdit Grammar
the click on the tabView Diagram
to see/download a navigable railroad diagram.Search and replace with
Lua
patterns inSquiLu
(https://github.com/mingodad/squilu):