Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grammar railroad diagram #802

Open
mingodad opened this issue Feb 8, 2023 · 0 comments
Open

Grammar railroad diagram #802

mingodad opened this issue Feb 8, 2023 · 0 comments

Comments

@mingodad
Copy link

mingodad commented Feb 8, 2023

Using some online tools like https://www.bottlecaps.de/rr/ui and https://www.bottlecaps.de/convert/ we can have a nice navigable railroad diagram.

Copy and paste the EBNF shown bellow on https://www.bottlecaps.de/rr/ui on the tab Edit Grammar the click on the tab View Diagram to see/download a navigable railroad diagram.

/* converted on Wed Feb 8, 2023, 11:55 (UTC+01) by bison-to-w3c v0.62 which is Copyright (c) 2011-2022 by Gunther Rademacher <[email protected]> */

start    ::= KW_MODULE UIDENT '=' autoload ( ( KW_LET LIDENT param_list | KW_LET_REC LIDENT ) '=' exp | KW_TEST test_exp '=' ( exp | test_special_res ) )*
autoload ::= ( KW_AUTOLOAD LIDENT )?
test_exp ::= aexp ( KW_GET | KW_PUT aexp KW_AFTER ) exp
test_special_res
         ::= '?'
           | '*'
exp      ::= KW_LET LIDENT param_list '=' exp KW_IN exp
           | unionexp ( ';' unionexp )*
unionexp ::= ( minusexp | ( '{' tree_branch '}' )+ ) ( '|' minusexp )*
minusexp ::= catexp ( '-' catexp )*
catexp   ::= appexp ( '.' appexp )*
appexp   ::= rexp+
aexp     ::= qid
           | DQUOTED
           | REGEXP
           | '(' exp? ')'
           | '[' exp ']'
rexp     ::= aexp rep?
rep      ::= '*'
           | '+'
           | '?'
qid      ::= LIDENT
           | QIDENT
           | KW_GET
           | KW_PUT
param_list
         ::= param*
param    ::= '(' id ':' type ')'
id       ::= LIDENT
           | KW_GET
           | KW_PUT
type     ::= atype ( ARROW atype )*
atype    ::= KW_STRING
           | KW_REGEXP
           | KW_LENS
           | '(' type ')'
tree_const2
         ::= ( '{' tree_branch '}' )*
tree_branch
         ::= tree_label ( '=' DQUOTED )? tree_const2
tree_label
         ::= DQUOTED?

//Tokens

KW_MODULE ::=  "module"
KW_LET_REC ::=  "let rec"
KW_LET ::= "let"
KW_STRING ::= "string"
KW_REGEXP ::= "regexp"
KW_LENS ::= "lens"
KW_IN ::= "in"
KW_AUTOLOAD ::= "autoload"
  /* tests */
KW_TEST ::= "test"
KW_GET ::= "get"
KW_PUT ::= "put"
KW_AFTER ::= "after"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant